Skip to content

Commit 929e632

Browse files
committed
Pass -Cpanic=abort for the panic_abort crate
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).
1 parent 2fcf177 commit 929e632

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

library/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
cargo-features = ["profile-rustflags"]
2+
13
[workspace]
24
resolver = "1"
35
members = [
@@ -44,6 +46,12 @@ object.debug = 0
4446
rustc-demangle.debug = 0
4547
rustc-demangle.opt-level = "s"
4648

49+
[profile.dev.package.panic_abort]
50+
rustflags = ["-Cpanic=abort"]
51+
52+
[profile.release.package.panic_abort]
53+
rustflags = ["-Cpanic=abort"]
54+
4755
[patch.crates-io]
4856
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
4957
# here

src/bootstrap/src/bin/rustc.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@ fn main() {
151151
cmd.arg("--sysroot").arg(&sysroot);
152152
}
153153

154-
// If we're compiling specifically the `panic_abort` crate then we pass
155-
// the `-C panic=abort` option. Note that we do not do this for any
156-
// other crate intentionally as this is the only crate for now that we
157-
// ship with panic=abort.
158-
//
159-
// This... is a bit of a hack how we detect this. Ideally this
160-
// information should be encoded in the crate I guess? Would likely
161-
// require an RFC amendment to RFC 1513, however.
162-
if crate_name == Some("panic_abort") {
163-
cmd.arg("-C").arg("panic=abort");
164-
}
165-
166154
let crate_type = parse_value_from_args(&orig_args, "--crate-type");
167155
// `-Ztls-model=initial-exec` must not be applied to proc-macros, see
168156
// issue https://github.com/rust-lang/rust/issues/100530

0 commit comments

Comments
 (0)