Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use /usr/bin/strip on macOS -> iOS cross as a temporary mitigation #138250

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Mar 9, 2025

Mitigation for #138212. This reintroduces the "hard-coded strip" workaround (but only for iOS) that was initially introduced in #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 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 place1) that shouldn't have this offset problem.

Alternative mitigations

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.

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

Footnotes

  1. https://github.com/rust-lang/rust/issues/131206

For <rust-lang#138212>.

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.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 9, 2025
@jieyouxu jieyouxu added O-macos Operating system: macOS O-ios Operating system: iOS labels Mar 9, 2025
@jieyouxu
Copy link
Member Author

jieyouxu commented Mar 9, 2025

@bors try

@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 9, 2025
@bors
Copy link
Contributor

bors commented Mar 9, 2025

⌛ Trying commit 908c5e4 with merge 06d1077d5ba6da9a0b3b6b84e6f919ec600dc1b6...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 9, 2025
[WIP] Use `/usr/bin/strip` on macOS -> iOS cross as a temporary mitigation

Mitigation for <rust-lang#138212>. 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 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.

### 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

[^linux-darwin-cross]: rust-lang#131206
@bors
Copy link
Contributor

bors commented Mar 9, 2025

☀️ Try build successful - checks-actions
Build commit: 06d1077 (06d1077d5ba6da9a0b3b6b84e6f919ec600dc1b6)

Copy link
Contributor

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with this workaround (depending on how long llvm/llvm-project#130472 takes).

@@ -1046,7 +1046,15 @@ fn link_natively(
let strip = sess.opts.cg.strip;

if sess.target.is_like_osx {
let stripcmd = "rust-objcopy";
let stripcmd = if sess.target.os == "ios" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer something like:

Suggested change
let stripcmd = if sess.target.os == "ios" {
let stripcmd = if cfg!(target_os = "macos") && sess.target.os != "macos" {

To not further break cross-compilation from Linux->iOS (which is rare, but possible), and to also fix this on tvOS, watchOS and visionOS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-ios Operating system: iOS O-macos Operating system: macOS S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants