@@ -50,7 +50,7 @@ use super::command::Command;
5050use super :: linker:: { self , Linker } ;
5151use super :: metadata:: { MetadataPosition , create_wrapper_file} ;
5252use 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} ;
5454use crate :: {
5555 CodegenResults , CompiledModule , CrateInfo , NativeLib , common, errors,
5656 looks_like_rust_object_file,
@@ -2974,32 +2974,9 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
29742974 return ;
29752975 } ;
29762976
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 ;
29792977 let target_os = & * sess. target . os ;
29802978 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 ) ;
30032980
30042981 if cc == Cc :: No {
30052982 // From the man page for ld64 (`man ld`):
0 commit comments