@@ -50,7 +50,7 @@ use super::command::Command;
50
50
use super :: linker:: { self , Linker } ;
51
51
use super :: metadata:: { MetadataPosition , create_wrapper_file} ;
52
52
use super :: rpath:: { self , RPathConfig } ;
53
- use crate :: apple:: { deployment_target, find_sdk_root, versioned_llvm_target} ;
53
+ use crate :: apple:: { deployment_target, find_sdk_root, ld64_arch , versioned_llvm_target} ;
54
54
use crate :: {
55
55
CodegenResults , CompiledModule , CrateInfo , NativeLib , common, errors,
56
56
looks_like_rust_object_file,
@@ -2974,32 +2974,9 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
2974
2974
return ;
2975
2975
} ;
2976
2976
2977
- // `sess.target.arch` (`target_arch`) is not detailed enough.
2978
- let llvm_arch = sess. target . llvm_target . split_once ( '-' ) . expect ( "LLVM target must have arch" ) . 0 ;
2979
2977
let target_os = & * sess. target . os ;
2980
2978
let target_abi = & * sess. target . abi ;
2981
-
2982
- // The architecture name to forward to the linker.
2983
- //
2984
- // Supported architecture names can be found in the source:
2985
- // https://github.com/apple-oss-distributions/ld64/blob/ld64-951.9/src/abstraction/MachOFileAbstraction.hpp#L578-L648
2986
- //
2987
- // Intentially verbose to ensure that the list always matches correctly
2988
- // with the list in the source above.
2989
- let ld64_arch = match llvm_arch {
2990
- "armv7k" => "armv7k" ,
2991
- "armv7s" => "armv7s" ,
2992
- "arm64" => "arm64" ,
2993
- "arm64e" => "arm64e" ,
2994
- "arm64_32" => "arm64_32" ,
2995
- // ld64 doesn't understand i686, so fall back to i386 instead.
2996
- //
2997
- // Same story when linking with cc, since that ends up invoking ld64.
2998
- "i386" | "i686" => "i386" ,
2999
- "x86_64" => "x86_64" ,
3000
- "x86_64h" => "x86_64h" ,
3001
- _ => bug ! ( "unsupported architecture in Apple target: {}" , sess. target. llvm_target) ,
3002
- } ;
2979
+ let ld64_arch = ld64_arch ( & sess. target ) ;
3003
2980
3004
2981
if cc == Cc :: No {
3005
2982
// From the man page for ld64 (`man ld`):
0 commit comments