about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2021-01-29 09:17:29 +0900
committerGitHub <noreply@github.com>2021-01-29 09:17:29 +0900
commita3c060c7f5b76f5c371f40349ac868d7271fa817 (patch)
tree7694e5ea03a2d720de9a87dfd663ac0d597cdb3b
parent3eac643d044ad9e3841128ab122827e161c65dbd (diff)
parent8553aeeb66afa1369548f9e7d88409459f5ff815 (diff)
downloadrust-a3c060c7f5b76f5c371f40349ac868d7271fa817.tar.gz
rust-a3c060c7f5b76f5c371f40349ac868d7271fa817.zip
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
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index 0738b2df71e..8bc4e644223 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2203,8 +2203,13 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
             return;
         }
     };
-    let arch_name = llvm_target.split('-').next().expect("LLVM target must have a hyphen");
-    cmd.args(&["-arch", arch_name, "-isysroot", &sdk_root, "-Wl,-syslibroot", &sdk_root]);
+    if llvm_target.contains("macabi") {
+        cmd.args(&["-target", llvm_target])
+    } else {
+        let arch_name = llvm_target.split('-').next().expect("LLVM target must have a hyphen");
+        cmd.args(&["-arch", arch_name])
+    }
+    cmd.args(&["-isysroot", &sdk_root, "-Wl,-syslibroot", &sdk_root]);
 }
 
 fn get_apple_sdk_root(sdk_name: &str) -> Result<String, String> {