diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-06-22 08:49:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-22 08:49:03 +0200 |
| commit | aef8a76ce0a7f779e9b89c6fd46335280878a079 (patch) | |
| tree | 09dcd4ba7f1aa8d9c80a7175aa9fa485def9ac22 | |
| parent | 8051f012658fde822bfc661b52e90950b411e5c9 (diff) | |
| parent | a0badba6eeb4b24dd9748f5e99cec285b473c43b (diff) | |
| download | rust-aef8a76ce0a7f779e9b89c6fd46335280878a079.tar.gz rust-aef8a76ce0a7f779e9b89c6fd46335280878a079.zip | |
Rollup merge of #140254 - bjorn3:rustc_panic_abort_abort, r=petrochenkov
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). Required for https://github.com/rust-lang/rustc_codegen_cranelift/issues/1567
| -rw-r--r-- | library/Cargo.toml | 10 | ||||
| -rw-r--r-- | src/bootstrap/src/bin/rustc.rs | 12 |
2 files changed, 10 insertions, 12 deletions
diff --git a/library/Cargo.toml b/library/Cargo.toml index 35480b9319d..c66f621ffde 100644 --- a/library/Cargo.toml +++ b/library/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["profile-rustflags"] + [workspace] resolver = "1" members = [ @@ -44,6 +46,14 @@ object.debug = 0 rustc-demangle.debug = 0 rustc-demangle.opt-level = "s" +# panic_abort must always be compiled with panic=abort, even when the rest of the +# sysroot is panic=unwind. +[profile.dev.package.panic_abort] +rustflags = ["-Cpanic=abort"] + +[profile.release.package.panic_abort] +rustflags = ["-Cpanic=abort"] + [patch.crates-io] # See comments in `library/rustc-std-workspace-core/README.md` for what's going on # here diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index 0671a8467e8..0364c664ba5 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -151,18 +151,6 @@ fn main() { cmd.arg("--sysroot").arg(&sysroot); } - // If we're compiling specifically the `panic_abort` crate then we pass - // the `-C panic=abort` option. Note that we do not do this for any - // other crate intentionally as this is the only crate for now that we - // ship with panic=abort. - // - // This... is a bit of a hack how we detect this. Ideally this - // information should be encoded in the crate I guess? Would likely - // require an RFC amendment to RFC 1513, however. - if crate_name == Some("panic_abort") { - cmd.arg("-C").arg("panic=abort"); - } - let crate_type = parse_value_from_args(&orig_args, "--crate-type"); // `-Ztls-model=initial-exec` must not be applied to proc-macros, see // issue https://github.com/rust-lang/rust/issues/100530 |
