diff options
| -rw-r--r-- | compiler/rustc_session/src/config/cfg.rs | 4 | ||||
| -rw-r--r-- | tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs | 5 | ||||
| -rw-r--r-- | tests/run-make-cargo/panic-immediate-abort-works/rmake.rs | 6 | 
3 files changed, 15 insertions, 0 deletions
| diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index fc36fe9d5d7..f3d91ce4a5d 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -205,6 +205,10 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg { ins_none!(sym::overflow_checks); } + // We insert a cfg for the name of session's panic strategy. + // Since the ImmediateAbort strategy is new, it also sets cfg(panic="abort"), so that code + // which is trying to detect whether unwinding is enabled by checking for cfg(panic="abort") + // does not need to be updated. ins_sym!(sym::panic, sess.panic_strategy().desc_symbol()); if sess.panic_strategy() == PanicStrategy::ImmediateAbort { ins_sym!(sym::panic, PanicStrategy::Abort.desc_symbol()); diff --git a/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs b/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs index e91d1db83d1..d7a7a8bfd8c 100644 --- a/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs +++ b/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs @@ -1,3 +1,8 @@ +// This is a codegen test which checks that when code is compiled with panic=immediate-abort, +// we get a `tail call void @llvm.trap()` in user code instead of a call into the standard +// library's panic formatting code (such as panic_fmt) or one of the numerous panic outlining shims +// (such as slice_index_fail). + #![deny(warnings)] use run_make_support::{cargo, llvm_filecheck, path, rfs, target}; diff --git a/tests/run-make-cargo/panic-immediate-abort-works/rmake.rs b/tests/run-make-cargo/panic-immediate-abort-works/rmake.rs index a3c5877a6a1..bb15bd41e79 100644 --- a/tests/run-make-cargo/panic-immediate-abort-works/rmake.rs +++ b/tests/run-make-cargo/panic-immediate-abort-works/rmake.rs @@ -1,3 +1,9 @@ +// This test ensures we are able to compile and link a simple binary with panic=immediate-abort. +// The test panic-immediate-abort-codegen checks that panic strategy produces the desired codegen, +// but is based on compiling a library crate (which is the norm for codegen tests because it is +// cleaner and more portable). So this test ensures that we didn't mix up a cfg or a compiler +// implementation detail in a way that makes panic=immediate-abort encounter errors at link time. + //@ needs-target-std #![deny(warnings)] | 
