-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Can no longer set custom section flags in LLVM IR #50551
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
Comments
82d0749 is innocent. The Rust code is incorrect. With the inline asm .section directive, The Rust abused the previous LLVM behavior when an inline asm .section directive can override the section attributes of To support such usage properly, we need an LLVM IR construct to encode the section attributes. |
I don't think that modifying object files after the fact is an acceptable outcome for us. Prior to your change, LLVM provided a way to set section flags on the llvmbc section, even if it was roundabout -- and after your change there is no longer any IR-level way to achieve that, if I understood correctly. As such, I believe this change should be reverted for the LLVM 13 release, and be reapplied once there is an IR-level mechanism to specify the flags. |
After further testing, it looks like reverting https://reviews.llvm.org/D86374 just fixes the assertion failure, but still results in undesirable behavior: We'll get two .llvmbc sections, one with the EXCLUDE flag, and one (containing the actual bitcode) with the ALLOC flag. This breaks bitcode extraction entirely. The actual problem here is https://reviews.llvm.org/D100944. Reverting that change (and just that change) restores the previous behavior. Actually, it looks like this problem was brought up in post-commit review for D100944, but didn't reach a satisfactory conclusion. |
Revert posted at https://reviews.llvm.org/D107216. |
We have now finished the LLVM 13 upgrade with D100944 reverted in our fork. |
In further discussion on D107216, we agreed to apply the revert on 13.x only, leaving the change on main, so Rust will have time to find a new way for 14. Fangrui suggested different wording for the commit message though. |
Merged: 1c198b3 |
mentioned in issue #50580 |
@tstellar Move to 13.0.1? |
This issue has been addressed on the rust side (see rust-lang/rust#90326), so closing this. Adding proper support for section flags in LLVM would still be nice, but it's no longer relevant as far as the release is concerned. |
Extended Description
After 82d0749 this IR
module asm ".section .llvmbc,\22e\22"
@rustc.embedded.module = private constant [3 x i8] c"ABC", section ".llvmbc"
when run through llc results in an "Unknown section kind" assertion failure.
rustc emits this IR here, which has a comment explaining why it does so: https://github.com/rust-lang/rust/blob/bddb59cf07efcf6e606f16b87f85e3ecd2c1ca69/compiler/rustc_codegen_llvm/src/back/write.rs#L970-L1017
I'm not sure where the bug is here -- what rustc is doing certainly looks fishy, but I'm not sure what it is supposed to be doing instead. Any advice?
The text was updated successfully, but these errors were encountered: