Skip to content

Commit

Permalink
Use the abort strategy when tracing.
Browse files Browse the repository at this point in the history
  • Loading branch information
vext01 committed Mar 12, 2020
1 parent 5657c94 commit c8c964a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{early_error, early_warn, Session};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::impl_stable_hash_via_hash;

use rustc_target::spec::{Target, TargetTriple};
use rustc_target::spec::{PanicStrategy, Target, TargetTriple};

use crate::parse::CrateConfig;
use rustc_feature::UnstableFeatures;
Expand Down Expand Up @@ -1754,6 +1754,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
early_error(error_format, &format!("optimisation cannot be enabled with a tracer"));
}

// If a tracer is enabled, we use only the abort panic strategy.
if cg.tracer != TracerMode::Off {
cg.panic = Some(PanicStrategy::Abort);
debugging_opts.panic_abort_tests = true;
}

let cg = cg;

// The `-g` and `-C debuginfo` flags specify the same setting, so we want to be able
Expand Down
7 changes: 7 additions & 0 deletions src/test/run-make/yk-abort-strategy-std/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-include ../../run-make-fulldeps/tools.mk

PROG=yk-abort-strategy-std

all:
$(RUSTC) --emit mir ${PROG}.rs && grep 'resume;' ${TMPDIR}/${PROG}.mir
$(RUSTC) --emit mir -C tracer=hw ${PROG}.rs && grep 'resume;' ${TMPDIR}/${PROG}.mir; [ $$? -eq 1 ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main() {
println!("{}", f(None));
}

#[inline(never)]
fn f(a: Option<usize>) -> String {
let s = String::from("hello");
format!("{}{}", s, a.unwrap())
}
7 changes: 7 additions & 0 deletions src/test/run-make/yk-abort-strategy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-include ../../run-make-fulldeps/tools.mk

PROG=yk-abort-strategy

all:
$(RUSTC) --emit mir ${PROG}.rs && grep 'resume;' ${TMPDIR}/${PROG}.mir
$(RUSTC) --emit mir -C tracer=hw ${PROG}.rs && grep 'resume;' ${TMPDIR}/${PROG}.mir; [ $$? -eq 1 ]
9 changes: 9 additions & 0 deletions src/test/run-make/yk-abort-strategy/yk-abort-strategy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main() {
let s = String::from("hello");
println!("{} {}", s, f(1));
}

#[inline(never)]
fn f(_a: usize) -> usize {
panic!();
}

0 comments on commit c8c964a

Please sign in to comment.