Skip to content

Commit 2fd3c07

Browse files
committed
auto merge of #9278 : alexcrichton/rust/ndebug, r=brson
Many people will be very confused that their debug! statements aren't working when they first use rust only to learn that they should have been building with `--cfg debug` the entire time. This inverts the meaning of the flag to instead of enabling debug statements, now it disables debug statements. This way the default behavior is a bit more reasonable, and requires less end-user configuration. Furthermore, this turns on debug by default when building the rustc compiler.
2 parents ff0aaaf + 833a64d commit 2fd3c07

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ endif
102102

103103
ifdef CFG_ENABLE_DEBUG
104104
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
105-
CFG_RUSTC_FLAGS += --cfg debug
106105
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
107106
else
107+
CFG_RUSTC_FLAGS += --cfg ndebug
108108
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
109109
endif
110110

RELEASES.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Version 0.8 (October 2013)
1010
* Many trait inheritance bugs fixed.
1111
* Owned and borrowed trait objects work more reliably.
1212
* `copy` is no longer a keyword. It has been replaced by the `Clone` trait.
13-
* rustc no longer emits code for the `debug!` macro unless it is passed
14-
`--cfg debug`
13+
* rustc can omit emission of code for the `debug!` macro if it is passed
14+
`--cfg ndebug`
1515
* mod.rs is now "blessed". When loading `mod foo;`, rustc will now look
1616
for foo.rs, then foo/mod.rs, and will generate an error when both are
1717
present.

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ opt optimize-cxx 1 "build optimized C++ code"
373373
opt optimize-llvm 1 "build optimized LLVM"
374374
opt optimize-tests 1 "build tests with optimizations"
375375
opt llvm-assertions 1 "build LLVM with assertions"
376-
opt debug 0 "build with extra debug fun"
376+
opt debug 1 "build with extra debug fun"
377377
opt ratchet-bench 0 "ratchet benchmarks"
378378
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
379379
opt manage-submodules 1 "let the build manage the git submodules"

doc/rust.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3428,8 +3428,8 @@ sign (`=`) followed by the log level, from 1 to 4, inclusive. Level 1
34283428
is the error level, 2 is warning, 3 info, and 4 debug. You can also
34293429
use the symbolic constants `error`, `warn`, `info`, and `debug`. Any
34303430
logs less than or equal to the specified level will be output. If not
3431-
specified then log level 4 is assumed. However, debug messages are
3432-
only available if `--cfg=debug` is passed to `rustc`.
3431+
specified then log level 4 is assumed. Debug messages can be omitted
3432+
by passing `--cfg ndebug` to `rustc`.
34333433

34343434
As an example, to see all the logs generated by the compiler, you would set
34353435
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `link`

mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
575575

576576
# The tests select when to use debug configuration on their own;
577577
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
578-
CTEST_RUSTC_FLAGS := $$(subst --cfg debug,,$$(CFG_RUSTC_FLAGS))
578+
CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
579579

580580
# The tests can not be optimized while the rest of the compiler is optimized, so
581581
# filter out the optimization (if any) from rustc and then figure out if we need

src/libsyntax/ext/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ pub fn std_macros() -> @str {
715715
macro_rules! warn ( ($($arg:tt)*) => (log!(2u32, $($arg)*)) )
716716
macro_rules! info ( ($($arg:tt)*) => (log!(3u32, $($arg)*)) )
717717
macro_rules! debug( ($($arg:tt)*) => (
718-
if cfg!(debug) { log!(4u32, $($arg)*) }
718+
if cfg!(not(ndebug)) { log!(4u32, $($arg)*) }
719719
))
720720

721721
macro_rules! log2(
@@ -730,7 +730,7 @@ pub fn std_macros() -> @str {
730730
macro_rules! warn2 ( ($($arg:tt)*) => (log2!(2u32, $($arg)*)) )
731731
macro_rules! info2 ( ($($arg:tt)*) => (log2!(3u32, $($arg)*)) )
732732
macro_rules! debug2( ($($arg:tt)*) => (
733-
if cfg!(debug) { log2!(4u32, $($arg)*) }
733+
if cfg!(not(ndebug)) { log2!(4u32, $($arg)*) }
734734
))
735735

736736
macro_rules! fail(

src/test/run-pass/conditional-debug-macro-off.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
// except according to those terms.
1010

1111
// xfail-fast exec-env directive doesn't work for check-fast
12+
// compile-flags: --cfg ndebug
1213
// exec-env:RUST_LOG=conditional-debug-macro-off=4
1314

1415
fn main() {
1516
// only fails if debug! evaluates its argument.
1617
debug!({ if true { fail!() } });
17-
}
18+
}

src/test/run-pass/conditional-debug-macro-on.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
// xfail-fast compile-flags directive doesn't work for check-fast
12-
// compile-flags: --cfg debug
1312
// exec-env:RUST_LOG=conditional-debug-macro-on=4
1413

1514
fn main() {
@@ -18,4 +17,4 @@ fn main() {
1817
debug!({ if true { return; } });
1918

2019
fail!();
21-
}
20+
}

0 commit comments

Comments
 (0)