diff options
| -rw-r--r-- | Makefile.in | 3 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 6 | ||||
| -rw-r--r-- | src/libstd/rt/util.rs | 3 |
3 files changed, 9 insertions, 3 deletions
diff --git a/Makefile.in b/Makefile.in index a9a41a073d0..0575f48c4c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -96,7 +96,8 @@ ifdef CFG_DISABLE_OPTIMIZE $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) CFG_RUSTC_FLAGS += else - CFG_RUSTC_FLAGS += -O + # The rtopt cfg turns off runtime sanity checks + CFG_RUSTC_FLAGS += -O --cfg rtopt endif ifdef CFG_ENABLE_DEBUG diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 600d0bb133e..5378a2c798d 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -27,8 +27,10 @@ macro_rules! rtdebug ( macro_rules! rtassert ( ( $arg:expr ) => ( { - if !$arg { - rtabort!("assertion failed: %s", stringify!($arg)); + if ::rt::util::ENFORCE_SANITY { + if !$arg { + rtabort!("assertion failed: %s", stringify!($arg)); + } } } ) ) diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index f2ede8872c2..c3f5b11a930 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -19,6 +19,9 @@ use unstable::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; #[cfg(target_os="macos")] use unstable::running_on_valgrind; +// Indicates whether we should perform expensive sanity checks, including rtassert! +pub static ENFORCE_SANITY: bool = !cfg!(rtopt) || cfg!(rtdebug) || cfg!(rtassert); + /// Get the number of cores available pub fn num_cpus() -> uint { #[fixed_stack_segment]; #[inline(never)]; |
