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

Use --eh-frame-hdr on linux-musl target & ld.lld linker flavour #73483

Closed
wants to merge 1 commit into from

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Jun 18, 2020

The --eh-frame-hdr is necessary for unwinding but not enabled by default
when using lld.ld linker flavour. Enable it to match existing behaviour
for gcc linker flavour.

Closes #73451.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 18, 2020
The --eh-frame-hdr is necessary for unwinding but not enabled by default
when using ld.lld linker flavour. Enable it to match existing behaviour
for gcc linker flavour.
@petrochenkov
Copy link
Contributor

I'm not sure this will work as expected because non-baremetal targets don't really support linking with a "naked" linker (as opposed to the gcc wrapper) out of the box.

What the author of #73451 wanted to do is actually -C link-arg -fuse-ld=lld.
Then lld will be used through gcc (or clang) and --eh-frame-hdr will be passed.

@tmiasko
Copy link
Contributor Author

tmiasko commented Jun 18, 2020

I know that this approach doesn't work with linux-gnu targets for reasons you
described (it needs additionally --eh-frame-hdr, -dynamic-linker, paths to
system libraries, crt, ...), but it does work with musl.

@petrochenkov
Copy link
Contributor

It works with musl, but only in self-contained mode (see #68887 (comment) for details), which should ideally be enabled only when a native musl toolchain is nowhere in sight.

I wouldn't want to make it work today just break it tomorrow by changing the self-contained mode heuristic.

@petrochenkov
Copy link
Contributor

Speaking of --eh-frame-hdr specifically, it's one of those options that we should probably pass unconditionally in link.rs rather than in target specs (to linkers that support it).

@tmiasko
Copy link
Contributor Author

tmiasko commented Jun 18, 2020

It is already possible to use -Clinker-flavor=ld.lld -Clink-arg=--eh-frame-hdr,
so any hypothetical heuristics with regards to self contained mode would be to
some degree a regression regardless.

So, what do you propose?

  1. Close this now and potentially revisit once self contained mode option / heuristic is implemented.
  2. Explore using --eh-frame-hdr more generally through link.rs.
  3. Land it as is.
  4. ...

@alecmocatta
Copy link
Contributor

What the author of #73451 wanted to do is actually -C link-arg -fuse-ld=lld.
Then lld will be used through gcc (or clang) and --eh-frame-hdr will be passed.

Just to clarify, I'd like to be able to cross-compile from Windows. -C linker=rust-lld is the way I've been recommended to do this. I'm not sure what it would take to make -C link-arg -fuse-ld=lld work but it doesn't work out of the box.

@petrochenkov
Copy link
Contributor

Let's try

  1. Explore using --eh-frame-hdr more generally through link.rs.

(Closing in favor of #73564.)

@tmiasko tmiasko deleted the musl-lld branch June 20, 2020 22:16
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 29, 2020
linker: Create GNU_EH_FRAME header by default when producing ELFs

Do it in a centralized way in `link.rs` instead of individual target specs.

The opt-out is `-Clink-arg=(-Wl,)--no-eh-frame-hdr` if necessary.

Fixes rust-lang#73451
cc rust-lang#73483
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 30, 2020
linker: Create GNU_EH_FRAME header by default when producing ELFs

Do it in a centralized way in `link.rs` instead of individual target specs.

The opt-out is `-Clink-arg=(-Wl,)--no-eh-frame-hdr` if necessary.

Fixes rust-lang#73451
cc rust-lang#73483
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 2, 2020
linker: Create GNU_EH_FRAME header by default when producing ELFs

Do it in a centralized way in `link.rs` instead of individual target specs.

The opt-out is `-Clink-arg=(-Wl,)--no-eh-frame-hdr` if necessary.

Fixes rust-lang#73451
cc rust-lang#73483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic aborts under rust-lld + musl
4 participants