diff --git a/Makefile.in b/Makefile.in index a1c276cd3d2..ebcd5c79603 100644 --- a/Makefile.in +++ b/Makefile.in @@ -102,9 +102,9 @@ endif ifdef CFG_ENABLE_DEBUG $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG)) - CFG_RUSTC_FLAGS += --cfg debug CFG_GCCISH_CFLAGS += -DRUST_DEBUG else + CFG_RUSTC_FLAGS += --cfg ndebug CFG_GCCISH_CFLAGS += -DRUST_NDEBUG endif diff --git a/RELEASES.txt b/RELEASES.txt index 379f64cce1a..a65c0c22142 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -10,8 +10,8 @@ Version 0.8 (October 2013) * Many trait inheritance bugs fixed. * Owned and borrowed trait objects work more reliably. * `copy` is no longer a keyword. It has been replaced by the `Clone` trait. - * rustc no longer emits code for the `debug!` macro unless it is passed - `--cfg debug` + * rustc can omit emission of code for the `debug!` macro if it is passed + `--cfg ndebug` * mod.rs is now "blessed". When loading `mod foo;`, rustc will now look for foo.rs, then foo/mod.rs, and will generate an error when both are present. diff --git a/configure b/configure index d7c4523d543..2b024057403 100755 --- a/configure +++ b/configure @@ -373,7 +373,7 @@ opt optimize-cxx 1 "build optimized C++ code" opt optimize-llvm 1 "build optimized LLVM" opt optimize-tests 1 "build tests with optimizations" opt llvm-assertions 1 "build LLVM with assertions" -opt debug 0 "build with extra debug fun" +opt debug 1 "build with extra debug fun" opt ratchet-bench 0 "ratchet benchmarks" opt fast-make 0 "use .gitmodules as timestamp for submodule deps" opt manage-submodules 1 "let the build manage the git submodules" diff --git a/doc/rust.md b/doc/rust.md index d10238c1483..e941e4f7956 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3428,8 +3428,8 @@ sign (`=`) followed by the log level, from 1 to 4, inclusive. Level 1 is the error level, 2 is warning, 3 info, and 4 debug. You can also use the symbolic constants `error`, `warn`, `info`, and `debug`. Any logs less than or equal to the specified level will be output. If not -specified then log level 4 is assumed. However, debug messages are -only available if `--cfg=debug` is passed to `rustc`. +specified then log level 4 is assumed. Debug messages can be omitted +by passing `--cfg ndebug` to `rustc`. As an example, to see all the logs generated by the compiler, you would set `RUST_LOG` to `rustc`, which is the crate name (as specified in its `link` diff --git a/mk/tests.mk b/mk/tests.mk index 28bbddc787f..14b06bf047e 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -575,7 +575,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \ # The tests select when to use debug configuration on their own; # remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898). -CTEST_RUSTC_FLAGS := $$(subst --cfg debug,,$$(CFG_RUSTC_FLAGS)) +CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS)) # The tests can not be optimized while the rest of the compiler is optimized, so # filter out the optimization (if any) from rustc and then figure out if we need diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 0bee7895420..82d452bc734 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -715,7 +715,7 @@ pub fn std_macros() -> @str { macro_rules! warn ( ($($arg:tt)*) => (log!(2u32, $($arg)*)) ) macro_rules! info ( ($($arg:tt)*) => (log!(3u32, $($arg)*)) ) macro_rules! debug( ($($arg:tt)*) => ( - if cfg!(debug) { log!(4u32, $($arg)*) } + if cfg!(not(ndebug)) { log!(4u32, $($arg)*) } )) macro_rules! log2( @@ -730,7 +730,7 @@ pub fn std_macros() -> @str { macro_rules! warn2 ( ($($arg:tt)*) => (log2!(2u32, $($arg)*)) ) macro_rules! info2 ( ($($arg:tt)*) => (log2!(3u32, $($arg)*)) ) macro_rules! debug2( ($($arg:tt)*) => ( - if cfg!(debug) { log2!(4u32, $($arg)*) } + if cfg!(not(ndebug)) { log2!(4u32, $($arg)*) } )) macro_rules! fail( diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass/conditional-debug-macro-off.rs index f40c8112e0b..1aae5ce29c0 100644 --- a/src/test/run-pass/conditional-debug-macro-off.rs +++ b/src/test/run-pass/conditional-debug-macro-off.rs @@ -9,9 +9,10 @@ // except according to those terms. // xfail-fast exec-env directive doesn't work for check-fast +// compile-flags: --cfg ndebug // exec-env:RUST_LOG=conditional-debug-macro-off=4 fn main() { // only fails if debug! evaluates its argument. debug!({ if true { fail!() } }); -} \ No newline at end of file +} diff --git a/src/test/run-pass/conditional-debug-macro-on.rs b/src/test/run-pass/conditional-debug-macro-on.rs index 65b751a5826..2fe6d179348 100644 --- a/src/test/run-pass/conditional-debug-macro-on.rs +++ b/src/test/run-pass/conditional-debug-macro-on.rs @@ -9,7 +9,6 @@ // except according to those terms. // xfail-fast compile-flags directive doesn't work for check-fast -// compile-flags: --cfg debug // exec-env:RUST_LOG=conditional-debug-macro-on=4 fn main() { @@ -18,4 +17,4 @@ fn main() { debug!({ if true { return; } }); fail!(); -} \ No newline at end of file +}