11use rustc_data_structures:: fx:: FxHashSet ;
22use rustc_fs_util:: fix_windows_verbatim_for_gcc;
33use rustc_hir:: def_id:: CrateNum ;
4- use rustc_middle:: middle:: cstore:: { EncodedMetadata , LibSource , NativeLibrary , NativeLibraryKind } ;
4+ use rustc_middle:: middle:: cstore:: { EncodedMetadata , LibSource , NativeLib } ;
55use rustc_middle:: middle:: dependency_format:: Linkage ;
66use rustc_session:: config:: { self , CFGuard , CrateType , DebugInfo } ;
77use rustc_session:: config:: { OutputFilenames , OutputType , PrintRequest , Sanitizer } ;
88use rustc_session:: output:: { check_file_is_writeable, invalid_output_for_target, out_filename} ;
99use rustc_session:: search_paths:: PathKind ;
10+ use rustc_session:: utils:: NativeLibKind ;
1011/// For all the linkers we support, and information they might
1112/// need out of the shared crate context before we get rid of it.
1213use rustc_session:: { filesearch, Session } ;
@@ -328,11 +329,12 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
328329 // metadata of the rlib we're generating somehow.
329330 for lib in codegen_results. crate_info . used_libraries . iter ( ) {
330331 match lib. kind {
331- NativeLibraryKind :: NativeStatic => { }
332- NativeLibraryKind :: NativeStaticNobundle
333- | NativeLibraryKind :: NativeFramework
334- | NativeLibraryKind :: NativeRawDylib
335- | NativeLibraryKind :: NativeUnknown => continue ,
332+ NativeLibKind :: StaticBundle => { }
333+ NativeLibKind :: StaticNoBundle
334+ | NativeLibKind :: Dylib
335+ | NativeLibKind :: Framework
336+ | NativeLibKind :: RawDylib
337+ | NativeLibKind :: Unspecified => continue ,
336338 }
337339 if let Some ( name) = lib. name {
338340 ab. add_native_library ( name) ;
@@ -431,7 +433,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
431433 // object files come from where and selectively skip them.
432434 let skip_object_files = native_libs
433435 . iter ( )
434- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
436+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
435437 ab. add_rlib (
436438 path,
437439 & name. as_str ( ) ,
@@ -908,26 +910,28 @@ enum RlibFlavor {
908910 StaticlibBase ,
909911}
910912
911- fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLibrary ] ) {
913+ fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLib ] ) {
912914 let lib_args: Vec < _ > = all_native_libs
913915 . iter ( )
914916 . filter ( |l| relevant_lib ( sess, l) )
915917 . filter_map ( |lib| {
916918 let name = lib. name ?;
917919 match lib. kind {
918- NativeLibraryKind :: NativeStaticNobundle | NativeLibraryKind :: NativeUnknown => {
920+ NativeLibKind :: StaticNoBundle
921+ | NativeLibKind :: Dylib
922+ | NativeLibKind :: Unspecified => {
919923 if sess. target . target . options . is_like_msvc {
920924 Some ( format ! ( "{}.lib" , name) )
921925 } else {
922926 Some ( format ! ( "-l{}" , name) )
923927 }
924928 }
925- NativeLibraryKind :: NativeFramework => {
929+ NativeLibKind :: Framework => {
926930 // ld-only syntax, since there are no frameworks in MSVC
927931 Some ( format ! ( "-framework {}" , name) )
928932 }
929933 // These are included, no need to print them
930- NativeLibraryKind :: NativeStatic | NativeLibraryKind :: NativeRawDylib => None ,
934+ NativeLibKind :: StaticBundle | NativeLibKind :: RawDylib => None ,
931935 }
932936 } )
933937 . collect ( ) ;
@@ -1697,11 +1701,11 @@ fn add_local_native_libraries(
16971701 None => continue ,
16981702 } ;
16991703 match lib. kind {
1700- NativeLibraryKind :: NativeUnknown => cmd. link_dylib ( name) ,
1701- NativeLibraryKind :: NativeFramework => cmd. link_framework ( name) ,
1702- NativeLibraryKind :: NativeStaticNobundle => cmd. link_staticlib ( name) ,
1703- NativeLibraryKind :: NativeStatic => cmd. link_whole_staticlib ( name, & search_path) ,
1704- NativeLibraryKind :: NativeRawDylib => {
1704+ NativeLibKind :: Dylib | NativeLibKind :: Unspecified => cmd. link_dylib ( name) ,
1705+ NativeLibKind :: Framework => cmd. link_framework ( name) ,
1706+ NativeLibKind :: StaticNoBundle => cmd. link_staticlib ( name) ,
1707+ NativeLibKind :: StaticBundle => cmd. link_whole_staticlib ( name, & search_path) ,
1708+ NativeLibKind :: RawDylib => {
17051709 // FIXME(#58713): Proper handling for raw dylibs.
17061710 bug ! ( "raw_dylib feature not yet implemented" ) ;
17071711 }
@@ -1891,7 +1895,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
18911895 let native_libs = & codegen_results. crate_info . native_libraries [ & cnum] ;
18921896 let skip_native = native_libs
18931897 . iter ( )
1894- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
1898+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
18951899
18961900 if ( !are_upstream_rust_objects_already_included ( sess)
18971901 || ignored_for_lto ( sess, & codegen_results. crate_info , cnum) )
@@ -2033,9 +2037,9 @@ fn add_upstream_native_libraries(
20332037 continue ;
20342038 }
20352039 match lib. kind {
2036- NativeLibraryKind :: NativeUnknown => cmd. link_dylib ( name) ,
2037- NativeLibraryKind :: NativeFramework => cmd. link_framework ( name) ,
2038- NativeLibraryKind :: NativeStaticNobundle => {
2040+ NativeLibKind :: Dylib | NativeLibKind :: Unspecified => cmd. link_dylib ( name) ,
2041+ NativeLibKind :: Framework => cmd. link_framework ( name) ,
2042+ NativeLibKind :: StaticNoBundle => {
20392043 // Link "static-nobundle" native libs only if the crate they originate from
20402044 // is being linked statically to the current crate. If it's linked dynamically
20412045 // or is an rlib already included via some other dylib crate, the symbols from
@@ -2047,8 +2051,8 @@ fn add_upstream_native_libraries(
20472051 // ignore statically included native libraries here as we've
20482052 // already included them when we included the rust library
20492053 // previously
2050- NativeLibraryKind :: NativeStatic => { }
2051- NativeLibraryKind :: NativeRawDylib => {
2054+ NativeLibKind :: StaticBundle => { }
2055+ NativeLibKind :: RawDylib => {
20522056 // FIXME(#58713): Proper handling for raw dylibs.
20532057 bug ! ( "raw_dylib feature not yet implemented" ) ;
20542058 }
@@ -2057,7 +2061,7 @@ fn add_upstream_native_libraries(
20572061 }
20582062}
20592063
2060- fn relevant_lib ( sess : & Session , lib : & NativeLibrary ) -> bool {
2064+ fn relevant_lib ( sess : & Session , lib : & NativeLib ) -> bool {
20612065 match lib. cfg {
20622066 Some ( ref cfg) => rustc_attr:: cfg_matches ( cfg, & sess. parse_sess , None ) ,
20632067 None => true ,
0 commit comments