From d88636f432e2aac5ad5705b5cb38dcbe7c37afcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:55:38 +0800 Subject: [PATCH] Use `/usr/bin/strip` on macOS -> iOS cross as a temporary workaround For . Looks like LLVM 20's initial `llvm-objcopy` version that we ship as `rust-objcopy` may be producing stripped iOS binaries with invalid offsets that fail iOS platform consistency checks. For the time being, use macOS system strip at `/usr/bin/strip` which should be available (unlike Linux -> macOS cross where this is not guaranteed to be available, partially why we are shipping `llvm-objcopy` in the first place) that shouldn't have this offset problem. --- compiler/rustc_codegen_ssa/src/back/link.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 3407117a06e3b..b2152769d7789 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1046,7 +1046,18 @@ fn link_natively( let strip = sess.opts.cg.strip; if sess.target.is_like_osx { - let stripcmd = "rust-objcopy"; + let stripcmd = if sess.host.os == "macos" && sess.target.os != "macos" { + // FIXME(#138212): properly fix `llvm-objcopy` upstream when stripping iOS binaries + // (seemingly producing stripped binaries with incorrect offsets that fail platform + // consistency checks). This can only be used on macOS -> iOS cross because other linux + // hosts may not have a (good) system strip in this location. + // + // See upstream bug report . + "/usr/bin/strip" + } else { + "rust-objcopy" + }; + match (strip, crate_type) { (Strip::Debuginfo, _) => { strip_with_external_utility(sess, stripcmd, out_filename, &["--strip-debug"])