From 343802e20e3a8f84ab002688cea8654b61c76d59 Mon Sep 17 00:00:00 2001 From: James Miller Date: Fri, 9 Jan 2015 22:47:02 +1300 Subject: [PATCH 1/2] Remove ndebug variable --- text/0000-remove-ndebug.md | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 text/0000-remove-ndebug.md diff --git a/text/0000-remove-ndebug.md b/text/0000-remove-ndebug.md new file mode 100644 index 00000000000..10a733b006e --- /dev/null +++ b/text/0000-remove-ndebug.md @@ -0,0 +1,45 @@ +- Start Date: (fill me in with today's date, YYYY-MM-DD) +- RFC PR: (leave this empty) +- Rust Issue: (leave this empty) + +# Summary + +Remove official support for the `ndebug` config variable, replace the current usage of it with a +more appropriate 'debug_assertions` compiler-provided config variable. + +# Motivation + +The usage of 'ndebug' to indicate a release build is a strange holdover from C/C++. It is not used +much and is easy to forget about. Since it used like any other value passed to the `cfg` flag, it +does not interact with other flags such as `-g` or `-O`. + +The only current users of `ndebug` are the implementations of the `debug_assert!` macro. At the +time of this writing integer overflow checking is will also be controlled by this variable. Since +the optimisation setting does not influence `ndebug`, this means that code that the user expects to +be optimised will still contain the overflow checking logic. Similarly, `debug_assert!` invocations +are not removed, contrary to what intuition should expect. Enabling optimisations should been seen +as a request to make the user's code faster, removing `debug_assert!` and other checks seems like +a natural consequence. + +# Detailed design + +The `debug_assertions` variable, the replacement for the `ndebug` variable, will be compiler +provided based on the value of the `opt-level` codegen flag, including the implied value from `-O`. +Any value higher than 0 will disable the variable. + +Another codegen flag `debug-assertions` will override this, forcing it on or off based on the value +passed to it. + +# Drawbacks + +Technically backwards incompatible change. However the only usage of the `ndebug` variable in the +rust tree is in the implementation of `debug_assert!`, so it's unlikely that any external code is +using it. + +# Alternatives + +No real alternatives beyond different names and defaults. + +# Unresolved questions + +None. \ No newline at end of file From 6ac0f88e1a7a13eb4485aef421f925be485375e2 Mon Sep 17 00:00:00 2001 From: James Miller Date: Tue, 3 Feb 2015 12:31:10 +1300 Subject: [PATCH 2/2] Alter some wording, fix markdown --- text/0000-remove-ndebug.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/text/0000-remove-ndebug.md b/text/0000-remove-ndebug.md index 10a733b006e..5cf9f4a4fcb 100644 --- a/text/0000-remove-ndebug.md +++ b/text/0000-remove-ndebug.md @@ -5,7 +5,7 @@ # Summary Remove official support for the `ndebug` config variable, replace the current usage of it with a -more appropriate 'debug_assertions` compiler-provided config variable. +more appropriate `debug_assertions` compiler-provided config variable. # Motivation @@ -23,9 +23,9 @@ a natural consequence. # Detailed design -The `debug_assertions` variable, the replacement for the `ndebug` variable, will be compiler -provided based on the value of the `opt-level` codegen flag, including the implied value from `-O`. -Any value higher than 0 will disable the variable. +The `debug_assertions` configuration variable, the replacement for the `ndebug` variable, will be +compiler provided based on the value of the `opt-level` codegen flag, including the implied value +from `-O`. Any value higher than 0 will disable the variable. Another codegen flag `debug-assertions` will override this, forcing it on or off based on the value passed to it.