Skip to content

add overflow-checks field to profiles #3908

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
Apr 18, 2017
Merged

Conversation

froydnj
Copy link
Contributor

@froydnj froydnj commented Apr 7, 2017

...and pass -C overflow-checks to the compiler when necessary.

Fixes #2262.

@rust-highfive
Copy link

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@froydnj
Copy link
Contributor Author

froydnj commented Apr 7, 2017

I am not super-happy about the logic in cargo_rustc/mod.rs; that seems like the sort of thing will have to be duplicated by anybody who wants to consume Cargo's output. I understand that they already have to do that with debug-assertions, but adding several extra cases might be taking it too far. I'm not really sure what a good alternative would be.

@alexcrichton
Copy link
Member

Thanks!

The logic here was mostly just to make -v pretty, I think we can always resort to just unconditionally passing these flags perhaps.

Could you also add a test to ensure this is plumbed through and enabled?

@froydnj
Copy link
Contributor Author

froydnj commented Apr 11, 2017

I think we can always resort to just unconditionally passing these flags perhaps.

I assume this means using the same logic that debug-assertions already uses.

Could you also add a test to ensure this is plumbed through and enabled?

@alexcrichton Do you mean something different than the tests in tests/build.rs? Or do you mean testing a Cargo.toml with explicit declarations of `overflow-checks?

@alexcrichton
Copy link
Member

Oh not precisely, we try to make the command line "pretty" by not passing -Cdebug-assertions=on when compiling in debug mode. That is, Cargo assumes that -C opt-level=0 is the default (doesn't need to be passed) and implies that debug assertions on. Cargo then treats opt-level 0 and debug assertions on as "pass no flags to rustc". That makes the logic here a little odd (with all the various implications), so I'm fine either way (whichever you prefer)

Yeah let's add a test to something like tests/build.rs or tests/test.rs (or anywhere really). Mostly just build a program in release mode with an overflow and make sure it panics.

@froydnj
Copy link
Contributor Author

froydnj commented Apr 11, 2017

OK, updated patch pushed with a release-mode, overflow-checks test. I left the logic that adds -C overflow-checks as-is, because a tidy -v command line is better than a cluttered one.

@alexcrichton
Copy link
Member

Looks great to me! I think though the test needs to be gated on nightly only?

@froydnj
Copy link
Contributor Author

froydnj commented Apr 12, 2017

Looks great to me! I think though the test needs to be gated on nightly only?

Ah, good point! How does that work when -C overflow-checks makes it into stable, though...it won't get tested there, then?

@alexcrichton
Copy link
Member

@froydnj oh we just delete the "if not nightly skip test" checks at that point (eventually ...)

...and pass `-C overflow-checks` to the compiler when necessary.

Fixes rust-lang#2262.
@froydnj
Copy link
Contributor Author

froydnj commented Apr 14, 2017

oh we just delete the "if not nightly skip test" checks at that point (eventually ...)

Hey, OK!

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Apr 18, 2017

📌 Commit 803d748 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Apr 18, 2017

⌛ Testing commit 803d748 with merge b94fbda...

@bors
Copy link
Contributor

bors commented Apr 18, 2017

💔 Test failed - status-travis

@alexcrichton
Copy link
Member

That seems... odd!

Let's see if it's spurious...

@bors: retry

@bors
Copy link
Contributor

bors commented Apr 18, 2017

⌛ Testing commit 803d748 with merge 434e7a8...

bors added a commit that referenced this pull request Apr 18, 2017
add `overflow-checks` field to profiles

...and pass `-C overflow-checks` to the compiler when necessary.

Fixes #2262.
@bors
Copy link
Contributor

bors commented Apr 18, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 434e7a8 to master...

@bors bors merged commit 803d748 into rust-lang:master Apr 18, 2017
@ehuss ehuss added this to the 1.18.0 milestone Feb 6, 2022
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

Successfully merging this pull request may close these issues.

Add a flag to build profiles to enable overflow checking
6 participants