Skip to content

Invert --cfg debug to --cfg ndebug #9278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions RELEASES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-pass/conditional-debug-macro-off.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!() } });
}
}
3 changes: 1 addition & 2 deletions src/test/run-pass/conditional-debug-macro-on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -18,4 +17,4 @@ fn main() {
debug!({ if true { return; } });

fail!();
}
}