Skip to content

Document that -C opt-level=0 implies -C debug-assertions more prominently #39449

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

Closed
mystor opened this issue Feb 1, 2017 · 3 comments
Closed

Comments

@mystor
Copy link
Contributor

mystor commented Feb 1, 2017

All I was able to find documenting this is an ambiguous mention in the rust reference:
https://github.com/rust-lang/rust/blob/17cae033787aca26b00a8c820c1599926a1fd94d/src/doc/reference.md#conditional-compilation

It would be nice if, for example, the documentation for std::debug_assert! was updated to mention:

Unlike assert!, debug_assert! statements are only enabled in non optimized builds by default. An optimized build will omit all debug_assert! statements unless -C debug-assertions or -C opt-level=0 is passed to the compiler. This makes debug_assert! useful for checks that are too expensive to be present in a release build but may be helpful during development.

@nagisa
Copy link
Member

nagisa commented Feb 1, 2017

“An optimized build” seems to very clearly imply that opt-level ≠ 0 to me.

@mystor
Copy link
Contributor Author

mystor commented Feb 1, 2017

That's true - I missed that on the first reading.

@mystor mystor closed this as completed Feb 1, 2017
@daxpedda
Copy link
Contributor

Was currently trying to work with the cargo api and was struggling to find the issue until I found out about this.

In the new documentation this is mentioned nowhere:
https://doc.rust-lang.org/nightly/rustc/codegen-options/index.html#opt-level

Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
Document that `-C opt-level=0` implies `-C debug-assertions`.

I couldn't find it stated anywhere else (https://doc.rust-lang.org/nightly/rustc/codegen-options/index.html#opt-level).
It was a problem before here: rust-lang#39449, it got lost in the migration to the new documentation I assume.

On a sidenote: I think that `-C opt-level=0` having a sideeffect on another flag should be changed. Having compiler flags affecting others doesn't make much sense to me, they are used to fine tune anyway.
In any case, this plays no role in this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants