Skip to content

Commit a3c060c

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 3eac643 + 8553aee commit a3c060c

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -2203,8 +2203,13 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
22032203
return;
22042204
}
22052205
};
2206-
let arch_name = llvm_target.split('-').next().expect("LLVM target must have a hyphen");
2207-
cmd.args(&["-arch", arch_name, "-isysroot", &sdk_root, "-Wl,-syslibroot", &sdk_root]);
2206+
if llvm_target.contains("macabi") {
2207+
cmd.args(&["-target", llvm_target])
2208+
} else {
2209+
let arch_name = llvm_target.split('-').next().expect("LLVM target must have a hyphen");
2210+
cmd.args(&["-arch", arch_name])
2211+
}
2212+
cmd.args(&["-isysroot", &sdk_root, "-Wl,-syslibroot", &sdk_root]);
22082213
}
22092214

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

0 commit comments

Comments
 (0)