Skip to content

Commit aef02fb

Browse files
committed
Explain tests and setting cfgs
1 parent df58fd8 commit aef02fb

File tree

3 files changed

+15
-0
lines changed
  • compiler/rustc_session/src/config
  • tests/run-make-cargo

3 files changed

+15
-0
lines changed

compiler/rustc_session/src/config/cfg.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
205205
ins_none!(sym::overflow_checks);
206206
}
207207

208+
// We insert a cfg for the name of session's panic strategy.
209+
// Since the ImmediateAbort strategy is new, it also sets cfg(panic="abort"), so that code
210+
// which is trying to detect whether unwinding is enabled by checking for cfg(panic="abort")
211+
// does not need to be updated.
208212
ins_sym!(sym::panic, sess.panic_strategy().desc_symbol());
209213
if sess.panic_strategy() == PanicStrategy::ImmediateAbort {
210214
ins_sym!(sym::panic, PanicStrategy::Abort.desc_symbol());

tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// This is a codegen test which checks that when code is compiled with panic=immediate-abort,
2+
// we get a `tail call void @llvm.trap()` in user code instead of a call into the standard
3+
// library's panic formatting code (such as panic_fmt) or one of the numerous panic outlining shims
4+
// (such as slice_index_fail).
5+
16
#![deny(warnings)]
27

38
use run_make_support::{cargo, llvm_filecheck, path, rfs, target};

tests/run-make-cargo/panic-immediate-abort-works/rmake.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// This test ensures we are able to compile and link a simple binary with panic=immediate-abort.
2+
// The test panic-immediate-abort-codegen checks that panic strategy produces the desired codegen,
3+
// but is based on compiling a library crate (which is the norm for codegen tests because it is
4+
// cleaner and more portable). So this test ensures that we didn't mix up a cfg or a compiler
5+
// implementation detail in a way that makes panic=immediate-abort encounter errors at link time.
6+
17
//@ needs-target-std
28

39
#![deny(warnings)]

0 commit comments

Comments
 (0)