-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Stabilize -C overflow-checks #1535
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
- Feature Name: (fill me in with a unique ident, my_awesome_feature) | ||
- Start Date: (fill me in with today's date, YYYY-MM-DD) | ||
- RFC PR: (leave this empty) | ||
- Rust Issue: (leave this empty) | ||
|
||
# Summary | ||
[summary]: #summary | ||
|
||
Stabilize the `-C overflow-checks` command line argument. | ||
|
||
# Motivation | ||
[motivation]: #motivation | ||
|
||
This is an easy way to turn on overflow checks in release builds | ||
without otherwise turning on debug assertions, via the `-C | ||
debug-assertions` flag. In stable Rust today you can't get one without | ||
the other. | ||
|
||
Users can use the `-C overflow-checks` flag from their Cargo | ||
config to turn on overflow checks for an entire application. | ||
|
||
This flag, which accepts values of 'yes'/'no', 'on'/'off', is being | ||
renamed from `force-overflow-checks` because the `force` doesn't add | ||
anything that the 'yes'/'no' | ||
|
||
# Detailed design | ||
[design]: #detailed-design | ||
|
||
This is a stabilization RFC. The only steps will be to move | ||
`force-overflow-checks` from `-Z` to `-C`, renaming it to | ||
`overflow-checks`, and making it stable. | ||
|
||
# Drawbacks | ||
[drawbacks]: #drawbacks | ||
|
||
It's another rather ad-hoc flag for modifying code generation. | ||
|
||
Like other such flags, this applies to the entire code unit, | ||
regardless of monomorphizations. This means that code generation for a | ||
single function can be diferent based on which code unit its | ||
instantiated in. | ||
|
||
# Alternatives | ||
[alternatives]: #alternatives | ||
|
||
The flag could instead be tied to crates such that any time code from | ||
that crate is inlined/monomorphized it turns on overflow checks. | ||
|
||
We might also want a design that provides per-function control over | ||
overflow checks. | ||
|
||
# Unresolved questions | ||
[unresolved]: #unresolved-questions | ||
|
||
Cargo might also add a profile option like | ||
|
||
```toml | ||
[profile.dev] | ||
overflow-checks = true | ||
``` | ||
|
||
This may also be accomplished by Cargo's pending support for passing | ||
arbitrary flags to rustc. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to wait for this, rather than add more ad hoc options to Cargo |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to hear people's opinions on this - it seems significant, but I don't have a good idea of how significant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd imagine that if the option was crate-specific, that would be an incentive for the crate authors to rely on specific overflow semantics, which is undesirable.