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

Emit nounwind LLVM attribute with -C panic=abort #44992

Closed
alexcrichton opened this issue Oct 3, 2017 · 4 comments
Closed

Emit nounwind LLVM attribute with -C panic=abort #44992

alexcrichton opened this issue Oct 3, 2017 · 4 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@alexcrichton
Copy link
Member

Currently whenever you compile with -C panic=abort we will omit invoke instructions and the uwtable LLVM function attribute, but we should also set the nounwind attribute. It looks like on ARM this forces the object file to not reference functions that otherwise a function missing the nounwind attribute will not have.

This should help out remove some weird hacks for embedded work!

cc @japaric

@TimNN TimNN added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Oct 3, 2017
@hanna-kruppe
Copy link
Contributor

Just for the record: in #45029 @sunfishcode brought up the possibility of other languages unwinding through Rust code. IIUC this could theoretically work if the Rust code contains no landing pads, though I believe that it is and should be UB instead. Still, I find it interesting that if we wanted to support that, the change proposed here would break that (b/c any unwinding would now be UB, rather than passing through the landing-pad-free code harmlessly).

@alexcrichton
Copy link
Member Author

@rkruppe that seems like support for that would be opt-in, if ever?

@hanna-kruppe
Copy link
Contributor

Mayyyyybe? I don't think this is likely to happen regardless of the details. I mostly wanted to record the thought somewhere.

@retep998
Copy link
Member

retep998 commented Oct 4, 2017

There are currently platforms where Rust and C++ can unwind through each other and landing pads will function correctly (such as windows msvc). I don't understand why anyone would want to support unwinding between Rust and other languages when -C panic=abort is specified, considering the whole point of -C panic=abort is that no unwinding occurs.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 11, 2017
This informs LLVM that functions can't unwind, which while it should typically
have already been inferred when necessary or otherwise not impact codegen is
apparently needed on targets like ARM to avoid references to unnecessary
symbols.

Closes rust-lang#44992
bors added a commit that referenced this issue Oct 13, 2017
rustc: Add LLVM `nounwind` with `-C panic=abort`

This informs LLVM that functions can't unwind, which while it should typically
have already been inferred when necessary or otherwise not impact codegen is
apparently needed on targets like ARM to avoid references to unnecessary
symbols.

Closes #44992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants