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

Always patch the interpreter of rustlib binaries #131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marienz
Copy link

@marienz marienz commented Dec 19, 2023

When using stable.toolchain,
lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld and other binaries in the same directory are not patched, so they do not work. I'm not sure exactly when Rust uses these, but it seems to break cross-compilation to wasm32-unknown-unknown.

Fix it by generalizing the patching applied to the rustc component. Replace the glob with a find invocation to avoid errors on components that have a lib directory but no lib/rustlib/*/bin.

@marienz
Copy link
Author

marienz commented Dec 19, 2023

The diff doesn't make it obvious what I'm actually changing: I'm swapping two loops and making a small change to one of them, but the loop body is sufficiently similar the diff looks like I'm modifying two loops. The change should be:

  • The code starting at line 47 in the old version should match line 56 in the new version.
  • The code starting at line 59 in the old version moves to line 46 in the new version. The find we're looping over changes, but the patchelf invocation is unchanged.

I think you can test this by manually running lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld --version from a stable toolchain (should crash before this change, print lld is a generic driver. after). Let me know if I need to put together a proper reproducer: I have a local project that doesn't work without this and does with, but it's a bit of a mess (multiple crates and cross-compilation to multiple platforms).

When using `stable.toolchain`,
`lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld` and other binaries
in the same directory are not patched, so they do not work. I'm not sure
exactly when Rust uses these, but it seems to break cross-compilation to
`wasm32-unknown-unknown`.

Fix it by generalizing the patching applied to the `rustc` component.
Replace the glob with a `find` invocation to avoid errors on components
that have a `lib` directory but no `lib/rustlib/*/bin`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant