Skip to content

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).

@stillinbeta
Copy link

stillinbeta commented Mar 8, 2025

(disregard previous message, I can't read error messages)

I can confirm this has solved the rust-lld issue for me!

@SandWoodJones
Copy link

Can also confirm this

@eureka-cpu eureka-cpu added the bug Something isn't working label Sep 27, 2025
@eureka-cpu
Copy link
Contributor

eureka-cpu commented Sep 27, 2025

I wonder if this is at all related to #206, both having to do with CC linker issues. Will need to do a bit of testing here. Thanks @marienz.

EDIT: Also please target staging.

@marienz marienz changed the base branch from main to staging September 28, 2025 13:27
@marienz
Copy link
Author

marienz commented Sep 28, 2025

Rebased to staging (sorry, must've missed that at the bottom of README before), but although the change is likely still correct I can't conveniently test it anymore (I've migrated off fenix in the >1y since I sent this). So please confirm this still fixes things before merging...

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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants