Skip to content

Commit ff78dfb

Browse files
authored
Rollup merge of #80215 - visigoth:issue-80202-fix, r=estebank
Use -target when linking binaries for Mac Catalyst When running `rustc` with `-target x86_64-apple-ios-macabi`, the linker eventually gets run with `-arch x86_64`, because the linker back end splits the LLVM target triple and uses the first token as the target architecture. However, this does not work for the Mac Catalyst ABI, which is a separate target from Darwin. Specifying the full target triple with `-target` allows Mac Catalyst binaries to link and run. closes #80202
2 parents 6f47762 + 8553aee commit ff78dfb

File tree

1 file changed

+7
-2
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+7
-2
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,8 +2211,13 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
22112211
return;
22122212
}
22132213
};
2214-
let arch_name = llvm_target.split('-').next().expect("LLVM target must have a hyphen");
2215-
cmd.args(&["-arch", arch_name, "-isysroot", &sdk_root, "-Wl,-syslibroot", &sdk_root]);
2214+
if llvm_target.contains("macabi") {
2215+
cmd.args(&["-target", llvm_target])
2216+
} else {
2217+
let arch_name = llvm_target.split('-').next().expect("LLVM target must have a hyphen");
2218+
cmd.args(&["-arch", arch_name])
2219+
}
2220+
cmd.args(&["-isysroot", &sdk_root, "-Wl,-syslibroot", &sdk_root]);
22162221
}
22172222

22182223
fn get_apple_sdk_root(sdk_name: &str) -> Result<String, String> {

0 commit comments

Comments
 (0)