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 } ;
@@ -327,11 +328,11 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
327328 // metadata of the rlib we're generating somehow.
328329 for lib in codegen_results. crate_info . used_libraries . iter ( ) {
329330 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 ,
335336 }
336337 if let Some ( name) = lib. name {
337338 ab. add_native_library ( name) ;
@@ -430,7 +431,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
430431 // object files come from where and selectively skip them.
431432 let skip_object_files = native_libs
432433 . iter ( )
433- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
434+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
434435 ab. add_rlib (
435436 path,
436437 & name. as_str ( ) ,
@@ -858,26 +859,26 @@ enum RlibFlavor {
858859 StaticlibBase ,
859860}
860861
861- fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLibrary ] ) {
862+ fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLib ] ) {
862863 let lib_args: Vec < _ > = all_native_libs
863864 . iter ( )
864865 . filter ( |l| relevant_lib ( sess, l) )
865866 . filter_map ( |lib| {
866867 let name = lib. name ?;
867868 match lib. kind {
868- NativeLibraryKind :: NativeStaticNobundle | NativeLibraryKind :: NativeUnknown => {
869+ NativeLibKind :: StaticNoBundle | NativeLibKind :: Unspecified => {
869870 if sess. target . target . options . is_like_msvc {
870871 Some ( format ! ( "{}.lib" , name) )
871872 } else {
872873 Some ( format ! ( "-l{}" , name) )
873874 }
874875 }
875- NativeLibraryKind :: NativeFramework => {
876+ NativeLibKind :: Framework => {
876877 // ld-only syntax, since there are no frameworks in MSVC
877878 Some ( format ! ( "-framework {}" , name) )
878879 }
879880 // These are included, no need to print them
880- NativeLibraryKind :: NativeStatic | NativeLibraryKind :: NativeRawDylib => None ,
881+ NativeLibKind :: StaticBundle | NativeLibKind :: RawDylib => None ,
881882 }
882883 } )
883884 . collect ( ) ;
@@ -1647,11 +1648,11 @@ fn add_local_native_libraries(
16471648 None => continue ,
16481649 } ;
16491650 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 => {
16551656 // FIXME(#58713): Proper handling for raw dylibs.
16561657 bug ! ( "raw_dylib feature not yet implemented" ) ;
16571658 }
@@ -1841,7 +1842,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
18411842 let native_libs = & codegen_results. crate_info . native_libraries [ & cnum] ;
18421843 let skip_native = native_libs
18431844 . iter ( )
1844- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
1845+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
18451846
18461847 if ( !are_upstream_rust_objects_already_included ( sess)
18471848 || ignored_for_lto ( sess, & codegen_results. crate_info , cnum) )
@@ -1983,9 +1984,9 @@ fn add_upstream_native_libraries(
19831984 continue ;
19841985 }
19851986 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 => {
19891990 // Link "static-nobundle" native libs only if the crate they originate from
19901991 // is being linked statically to the current crate. If it's linked dynamically
19911992 // or is an rlib already included via some other dylib crate, the symbols from
@@ -1997,8 +1998,8 @@ fn add_upstream_native_libraries(
19971998 // ignore statically included native libraries here as we've
19981999 // already included them when we included the rust library
19992000 // previously
2000- NativeLibraryKind :: NativeStatic => { }
2001- NativeLibraryKind :: NativeRawDylib => {
2001+ NativeLibKind :: StaticBundle => { }
2002+ NativeLibKind :: RawDylib => {
20022003 // FIXME(#58713): Proper handling for raw dylibs.
20032004 bug ! ( "raw_dylib feature not yet implemented" ) ;
20042005 }
@@ -2007,7 +2008,7 @@ fn add_upstream_native_libraries(
20072008 }
20082009}
20092010
2010- fn relevant_lib ( sess : & Session , lib : & NativeLibrary ) -> bool {
2011+ fn relevant_lib ( sess : & Session , lib : & NativeLib ) -> bool {
20112012 match lib. cfg {
20122013 Some ( ref cfg) => rustc_attr:: cfg_matches ( cfg, & sess. parse_sess , None ) ,
20132014 None => true ,
0 commit comments