Skip to content

Commit d1f7fb3

Browse files
committed
Auto merge of rust-lang#138250 - jieyouxu:ios-mitigation, r=<try>
Use `/usr/bin/strip` on macOS -> iOS cross as a temporary workaround Crude workaround for <rust-lang#138212> to unblock nightly macOS-to-iOS cross builds. This reintroduces the "hard-coded strip" workaround (but only for iOS) that was initially introduced in rust-lang#130781. 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 when cross-compiling from macOS -> iOS 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[^linux-darwin-cross]) that shouldn't have this offset problem. ### Alternatives - We *could* also try to use a `strip` from PATH. *However*, that can regress iOS users if they have broken homebrew binutils strip in their PATH that take precedence over a "good" strip. - We could also wait for upstream `llvm-objcopy` fixes. ### Review and testing advice I don't have access to either macOS or iOS platforms, and I can't really write a test for this. This will need to be tested manually. r? `@davidtwco` (or reroll) cc *-apple-ios target maintainers `@badboy` `@deg4uss3r` `@madsmtm` try-job: dist-apple-various try-job: dist-x86_64-apple try-job: dist-aarch64-apple [^linux-darwin-cross]: rust-lang#131206
2 parents ed897d5 + d88636f commit d1f7fb3

File tree

1 file changed

+12
-1
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+12
-1
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,18 @@ fn link_natively(
10461046
let strip = sess.opts.cg.strip;
10471047

10481048
if sess.target.is_like_osx {
1049-
let stripcmd = "rust-objcopy";
1049+
let stripcmd = if sess.host.os == "macos" && sess.target.os != "macos" {
1050+
// FIXME(#138212): properly fix `llvm-objcopy` upstream when stripping iOS binaries
1051+
// (seemingly producing stripped binaries with incorrect offsets that fail platform
1052+
// consistency checks). This can only be used on macOS -> iOS cross because other linux
1053+
// hosts may not have a (good) system strip in this location.
1054+
//
1055+
// See upstream bug report <https://github.com/llvm/llvm-project/issues/130472>.
1056+
"/usr/bin/strip"
1057+
} else {
1058+
"rust-objcopy"
1059+
};
1060+
10501061
match (strip, crate_type) {
10511062
(Strip::Debuginfo, _) => {
10521063
strip_with_external_utility(sess, stripcmd, out_filename, &["--strip-debug"])

0 commit comments

Comments
 (0)