-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Make rustc implicitly use panic=abort for the panic_abort crate #140254
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @petrochenkov. Use |
It's less of a practical concern, but shouldn't I guess the proper solution would be to move |
Ah, crate loader still searches for |
If panic=abort was used while compiling the standard library, panic_unwind won't be used anyway as any panic=abort dependency will force panic=abort to be used and thus panic_unwind doesn't get linked in.
The LLVM backend needs to know if the current crate uses panic=unwind or panic=abort before any source code gets parsed:
There already is a sanity check that the found crate is a panic runtime: rust/compiler/rustc_metadata/src/creader.rs Lines 999 to 1001 in 862156d
|
88b79e8
to
7e58a46
Compare
@rustbot ready |
@bors r+ |
Should be possible with https://doc.rust-lang.org/cargo/reference/unstable.html#profile-rustflags-option ? Something like (in case if it allowed to pass package name, didn't checked that): [profile.release.package.panic_abort]
rustflags = [ "-C", "panic=abort" ] |
Didn't know that was possible already. That is a much better solution. @bors r- |
Wouldn't that break |
7e58a46
to
929e632
Compare
Off-topic: Just wondering, Rust 1.87 depends on LLVM 20, but the Jobs are named 19? 🤔
rust/src/ci/docker/scripts/build-clang.sh Lines 7 to 8 in 18491d5
rust/src/ci/scripts/install-clang.sh Lines 13 to 14 in 036b5fc
https://github.com/llvm/llvm-project/releases/tag/llvmorg-20.1.7 Why not use renovate comments instead to group those 2 scripts together? |
The panic_abort crate must be compiled with panic=abort, but cargo doesn't allow setting the panic strategy for a single crate the usual way using panic="abort", but luckily per-package rustflags do allow this. Bootstrap previously handled this in its rustc wrapper, but for example the build systems of cg_clif and cg_gcc don't use the rustc wrapper, so they would either need to add one, patch the standard library or be unable to build a sysroot suitable for both panic=abort and panic=unwind (as is currently the case).
929e632
to
a0badba
Compare
I don't think it should break @rustbot ready |
We test rustc with the current LLVM (20) and one version before (19). The scripts that you link in different environments (inside/outside) Docker, and on different OSes, and they are not always fully synchronized. |
Thanks for explaining, I created a PR to merge those versions if you're interested: #142786 |
The panic_abort crate must be compiled with panic=abort, but cargo doesn't allow setting the panic strategy for a single crate. Bootstrap handles this in its rustc wrapper, but for example the build systems of cg_clif and cg_gcc don't use a rustc wrapper, so they would either need to add one or be unable to build a sysroot suitable for both panic=abort and panic=unwind (as is currently the case).
There is a crate called panic_abort on crates.io that would also be affected by this change. This crate uses unstable features and has last been updated in 2019 however and seems to be meant to be used when you want panic=abort behavior anyway.
Required for rust-lang/rustc_codegen_cranelift#1567