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 } ;
@@ -183,6 +184,7 @@ fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> Command {
183
184
"x86_64" => Some ( "x64" . to_string ( ) ) ,
184
185
"x86" => Some ( "x86" . to_string ( ) ) ,
185
186
"aarch64" => Some ( "arm64" . to_string ( ) ) ,
187
+ "arm" => Some ( "arm" . to_string ( ) ) ,
186
188
_ => None ,
187
189
} ;
188
190
if let Some ( ref a) = arch {
@@ -327,11 +329,12 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
327
329
// metadata of the rlib we're generating somehow.
328
330
for lib in codegen_results. crate_info . used_libraries . iter ( ) {
329
331
match lib. kind {
330
- NativeLibraryKind :: NativeStatic => { }
331
- NativeLibraryKind :: NativeStaticNobundle
332
- | NativeLibraryKind :: NativeFramework
333
- | NativeLibraryKind :: NativeRawDylib
334
- | NativeLibraryKind :: NativeUnknown => continue ,
332
+ NativeLibKind :: StaticBundle => { }
333
+ NativeLibKind :: StaticNoBundle
334
+ | NativeLibKind :: Dylib
335
+ | NativeLibKind :: Framework
336
+ | NativeLibKind :: RawDylib
337
+ | NativeLibKind :: Unspecified => continue ,
335
338
}
336
339
if let Some ( name) = lib. name {
337
340
ab. add_native_library ( name) ;
@@ -430,7 +433,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
430
433
// object files come from where and selectively skip them.
431
434
let skip_object_files = native_libs
432
435
. iter ( )
433
- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
436
+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
434
437
ab. add_rlib (
435
438
path,
436
439
& name. as_str ( ) ,
@@ -907,26 +910,28 @@ enum RlibFlavor {
907
910
StaticlibBase ,
908
911
}
909
912
910
- fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLibrary ] ) {
913
+ fn print_native_static_libs ( sess : & Session , all_native_libs : & [ NativeLib ] ) {
911
914
let lib_args: Vec < _ > = all_native_libs
912
915
. iter ( )
913
916
. filter ( |l| relevant_lib ( sess, l) )
914
917
. filter_map ( |lib| {
915
918
let name = lib. name ?;
916
919
match lib. kind {
917
- NativeLibraryKind :: NativeStaticNobundle | NativeLibraryKind :: NativeUnknown => {
920
+ NativeLibKind :: StaticNoBundle
921
+ | NativeLibKind :: Dylib
922
+ | NativeLibKind :: Unspecified => {
918
923
if sess. target . target . options . is_like_msvc {
919
924
Some ( format ! ( "{}.lib" , name) )
920
925
} else {
921
926
Some ( format ! ( "-l{}" , name) )
922
927
}
923
928
}
924
- NativeLibraryKind :: NativeFramework => {
929
+ NativeLibKind :: Framework => {
925
930
// ld-only syntax, since there are no frameworks in MSVC
926
931
Some ( format ! ( "-framework {}" , name) )
927
932
}
928
933
// These are included, no need to print them
929
- NativeLibraryKind :: NativeStatic | NativeLibraryKind :: NativeRawDylib => None ,
934
+ NativeLibKind :: StaticBundle | NativeLibKind :: RawDylib => None ,
930
935
}
931
936
} )
932
937
. collect ( ) ;
@@ -1696,11 +1701,11 @@ fn add_local_native_libraries(
1696
1701
None => continue ,
1697
1702
} ;
1698
1703
match lib. kind {
1699
- NativeLibraryKind :: NativeUnknown => cmd. link_dylib ( name) ,
1700
- NativeLibraryKind :: NativeFramework => cmd. link_framework ( name) ,
1701
- NativeLibraryKind :: NativeStaticNobundle => cmd. link_staticlib ( name) ,
1702
- NativeLibraryKind :: NativeStatic => cmd. link_whole_staticlib ( name, & search_path) ,
1703
- 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 => {
1704
1709
// FIXME(#58713): Proper handling for raw dylibs.
1705
1710
bug ! ( "raw_dylib feature not yet implemented" ) ;
1706
1711
}
@@ -1890,7 +1895,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
1890
1895
let native_libs = & codegen_results. crate_info . native_libraries [ & cnum] ;
1891
1896
let skip_native = native_libs
1892
1897
. iter ( )
1893
- . any ( |lib| lib. kind == NativeLibraryKind :: NativeStatic && !relevant_lib ( sess, lib) ) ;
1898
+ . any ( |lib| lib. kind == NativeLibKind :: StaticBundle && !relevant_lib ( sess, lib) ) ;
1894
1899
1895
1900
if ( !are_upstream_rust_objects_already_included ( sess)
1896
1901
|| ignored_for_lto ( sess, & codegen_results. crate_info , cnum) )
@@ -2032,9 +2037,9 @@ fn add_upstream_native_libraries(
2032
2037
continue ;
2033
2038
}
2034
2039
match lib. kind {
2035
- NativeLibraryKind :: NativeUnknown => cmd. link_dylib ( name) ,
2036
- NativeLibraryKind :: NativeFramework => cmd. link_framework ( name) ,
2037
- NativeLibraryKind :: NativeStaticNobundle => {
2040
+ NativeLibKind :: Dylib | NativeLibKind :: Unspecified => cmd. link_dylib ( name) ,
2041
+ NativeLibKind :: Framework => cmd. link_framework ( name) ,
2042
+ NativeLibKind :: StaticNoBundle => {
2038
2043
// Link "static-nobundle" native libs only if the crate they originate from
2039
2044
// is being linked statically to the current crate. If it's linked dynamically
2040
2045
// or is an rlib already included via some other dylib crate, the symbols from
@@ -2046,8 +2051,8 @@ fn add_upstream_native_libraries(
2046
2051
// ignore statically included native libraries here as we've
2047
2052
// already included them when we included the rust library
2048
2053
// previously
2049
- NativeLibraryKind :: NativeStatic => { }
2050
- NativeLibraryKind :: NativeRawDylib => {
2054
+ NativeLibKind :: StaticBundle => { }
2055
+ NativeLibKind :: RawDylib => {
2051
2056
// FIXME(#58713): Proper handling for raw dylibs.
2052
2057
bug ! ( "raw_dylib feature not yet implemented" ) ;
2053
2058
}
@@ -2056,7 +2061,7 @@ fn add_upstream_native_libraries(
2056
2061
}
2057
2062
}
2058
2063
2059
- fn relevant_lib ( sess : & Session , lib : & NativeLibrary ) -> bool {
2064
+ fn relevant_lib ( sess : & Session , lib : & NativeLib ) -> bool {
2060
2065
match lib. cfg {
2061
2066
Some ( ref cfg) => rustc_attr:: cfg_matches ( cfg, & sess. parse_sess , None ) ,
2062
2067
None => true ,
0 commit comments