Skip to content
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

Remove official ndebug variable support #563

Merged
merged 2 commits into from
Feb 18, 2015
Merged
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
45 changes: 45 additions & 0 deletions text/0000-remove-ndebug.md
Original file line number Diff line number Diff line change
@@ -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` 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.

# 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.