1
1
use rustc_data_structures:: fx:: FxHashSet ;
2
2
use rustc_fs_util:: fix_windows_verbatim_for_gcc;
3
3
use rustc_hir:: def_id:: CrateNum ;
4
- use rustc_middle:: middle:: cstore:: { EncodedMetadata , LibSource , NativeLibrary , NativeLibraryKind } ;
4
+ use rustc_middle:: middle:: cstore:: { EncodedMetadata , LibSource , NativeLib } ;
5
5
use rustc_middle:: middle:: dependency_format:: Linkage ;
6
6
use rustc_session:: config:: { self , CFGuard , CrateType , DebugInfo } ;
7
7
use rustc_session:: config:: { OutputFilenames , OutputType , PrintRequest , Sanitizer } ;
8
8
use rustc_session:: output:: { check_file_is_writeable, invalid_output_for_target, out_filename} ;
9
9
use rustc_session:: search_paths:: PathKind ;
10
+ use rustc_session:: utils:: NativeLibKind ;
10
11
/// For all the linkers we support, and information they might
11
12
/// need out of the shared crate context before we get rid of it.
12
13
use rustc_session:: { filesearch, Session } ;
@@ -327,11 +328,11 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
327
328
// metadata of the rlib we're generating somehow.
328
329
for lib in codegen_results. crate_info . used_libraries . iter ( ) {
329
330
match lib. kind {
330
- NativeLibraryKind :: NativeStatic => { }
331
- NativeLibraryKind :: NativeStaticNobundle
332
- | NativeLibraryKind :: NativeFramework
333
- | NativeLibraryKind :: NativeRawDylib
334
- | NativeLibraryKind :: NativeUnknown => continue ,
331
+ NativeLibKind :: StaticBundle => { }
332
+ NativeLibKind :: StaticNoBundle
333
+ | NativeLibKind :: Framework
334
+ | NativeLibKind :: RawDylib
335
+ | NativeLibKind :: Unspecified => continue ,
335
336
}
336
337
if let Some ( name) = lib. name {
337
338
ab. add_native_library ( name) ;
@@ -430,7 +431,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
430
431
// object files come from where and selectively skip them.
431
432
let skip_object_files = native_libs
432
433
. iter ( )
433
- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
434
+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
434
435
ab. add_rlib (
435
436
path,
436
437
& name. as_str ( ) ,
@@ -858,26 +859,26 @@ enum RlibFlavor {
858
859
StaticlibBase ,
859
860
}
860
861
861
- fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLibrary ] ) {
862
+ fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLib ] ) {
862
863
let lib_args: Vec < _ > = all_native_libs
863
864
. iter ( )
864
865
. filter ( |l| relevant_lib ( sess, l) )
865
866
. filter_map ( |lib| {
866
867
let name = lib. name ?;
867
868
match lib. kind {
868
- NativeLibraryKind :: NativeStaticNobundle | NativeLibraryKind :: NativeUnknown => {
869
+ NativeLibKind :: StaticNoBundle | NativeLibKind :: Unspecified => {
869
870
if sess. target . target . options . is_like_msvc {
870
871
Some ( format ! ( "{}.lib" , name) )
871
872
} else {
872
873
Some ( format ! ( "-l{}" , name) )
873
874
}
874
875
}
875
- NativeLibraryKind :: NativeFramework => {
876
+ NativeLibKind :: Framework => {
876
877
// ld-only syntax, since there are no frameworks in MSVC
877
878
Some ( format ! ( "-framework {}" , name) )
878
879
}
879
880
// These are included, no need to print them
880
- NativeLibraryKind :: NativeStatic | NativeLibraryKind :: NativeRawDylib => None ,
881
+ NativeLibKind :: StaticBundle | NativeLibKind :: RawDylib => None ,
881
882
}
882
883
} )
883
884
. collect ( ) ;
@@ -1647,11 +1648,11 @@ fn add_local_native_libraries(
1647
1648
None => continue ,
1648
1649
} ;
1649
1650
match lib. kind {
1650
- NativeLibraryKind :: NativeUnknown => cmd. link_dylib ( name) ,
1651
- NativeLibraryKind :: NativeFramework => cmd. link_framework ( name) ,
1652
- NativeLibraryKind :: NativeStaticNobundle => cmd. link_staticlib ( name) ,
1653
- NativeLibraryKind :: NativeStatic => cmd. link_whole_staticlib ( name, & search_path) ,
1654
- NativeLibraryKind :: NativeRawDylib => {
1651
+ NativeLibKind :: Unspecified => cmd. link_dylib ( name) ,
1652
+ NativeLibKind :: Framework => cmd. link_framework ( name) ,
1653
+ NativeLibKind :: StaticNoBundle => cmd. link_staticlib ( name) ,
1654
+ NativeLibKind :: StaticBundle => cmd. link_whole_staticlib ( name, & search_path) ,
1655
+ NativeLibKind :: RawDylib => {
1655
1656
// FIXME(#58713): Proper handling for raw dylibs.
1656
1657
bug ! ( "raw_dylib feature not yet implemented" ) ;
1657
1658
}
@@ -1841,7 +1842,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
1841
1842
let native_libs = & codegen_results. crate_info . native_libraries [ & cnum] ;
1842
1843
let skip_native = native_libs
1843
1844
. iter ( )
1844
- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
1845
+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
1845
1846
1846
1847
if ( !are_upstream_rust_objects_already_included ( sess)
1847
1848
|| ignored_for_lto ( sess, & codegen_results. crate_info , cnum) )
@@ -1983,9 +1984,9 @@ fn add_upstream_native_libraries(
1983
1984
continue ;
1984
1985
}
1985
1986
match lib. kind {
1986
- NativeLibraryKind :: NativeUnknown => cmd. link_dylib ( name) ,
1987
- NativeLibraryKind :: NativeFramework => cmd. link_framework ( name) ,
1988
- NativeLibraryKind :: NativeStaticNobundle => {
1987
+ NativeLibKind :: Unspecified => cmd. link_dylib ( name) ,
1988
+ NativeLibKind :: Framework => cmd. link_framework ( name) ,
1989
+ NativeLibKind :: StaticNoBundle => {
1989
1990
// Link "static-nobundle" native libs only if the crate they originate from
1990
1991
// is being linked statically to the current crate. If it's linked dynamically
1991
1992
// or is an rlib already included via some other dylib crate, the symbols from
@@ -1997,8 +1998,8 @@ fn add_upstream_native_libraries(
1997
1998
// ignore statically included native libraries here as we've
1998
1999
// already included them when we included the rust library
1999
2000
// previously
2000
- NativeLibraryKind :: NativeStatic => { }
2001
- NativeLibraryKind :: NativeRawDylib => {
2001
+ NativeLibKind :: StaticBundle => { }
2002
+ NativeLibKind :: RawDylib => {
2002
2003
// FIXME(#58713): Proper handling for raw dylibs.
2003
2004
bug ! ( "raw_dylib feature not yet implemented" ) ;
2004
2005
}
@@ -2007,7 +2008,7 @@ fn add_upstream_native_libraries(
2007
2008
}
2008
2009
}
2009
2010
2010
- fn relevant_lib ( sess : & Session , lib : & NativeLibrary ) -> bool {
2011
+ fn relevant_lib ( sess : & Session , lib : & NativeLib ) -> bool {
2011
2012
match lib. cfg {
2012
2013
Some ( ref cfg) => rustc_attr:: cfg_matches ( cfg, & sess. parse_sess , None ) ,
2013
2014
None => true ,
0 commit comments