Implement the `panic` profile option #2687

Merged
merged 1 commit into from May 21, 2016

Conversation

Projects
None yet
8 participants
@alexcrichton
Member

alexcrichton commented May 13, 2016

This is the Cargo half of the implementation of RFC 1513 which adds a new
profile.*.panic option to customize the -C panic argument to the compiler.
This is not passed by default and can otherwise be specified as abort or
unwind on the nightly compiler.

The profile.*.panic option is only used from the top-level crate, not each
crate individually. This means that applications should customize this value as
they see fit, and libraries will only use their own value when they're being
tested.

Cargo also has specific knowledge that when testing a crate it can't pass
-C panic=abort for now as the default test harness requires panic=unwind.
This essentially just means that cargo test will continue to work for crates
that specify panic=abort in Cargo.toml.

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
Member

alexcrichton commented May 13, 2016

r? @brson

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive May 13, 2016

r? @wycats

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

r? @wycats

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

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik May 15, 2016

Member

Any chance we can get this merged sometime soon? Eagerly awaiting 😄

Member

steveklabnik commented May 15, 2016

Any chance we can get this merged sometime soon? Eagerly awaiting 😄

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors May 17, 2016

Contributor

☔️ The latest upstream changes (presumably #2685) made this pull request unmergeable. Please resolve the merge conflicts.

Contributor

bors commented May 17, 2016

☔️ The latest upstream changes (presumably #2685) made this pull request unmergeable. Please resolve the merge conflicts.

@wycats

This comment has been minimized.

Show comment
Hide comment
@wycats

wycats May 20, 2016

Contributor

@bors r+

Contributor

wycats commented May 20, 2016

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors May 20, 2016

Contributor

📌 Commit b6e0fe9 has been approved by wycats

Contributor

bors commented May 20, 2016

📌 Commit b6e0fe9 has been approved by wycats

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors May 20, 2016

Contributor

⌛️ Testing commit b6e0fe9 with merge aaea05d...

Contributor

bors commented May 20, 2016

⌛️ Testing commit b6e0fe9 with merge aaea05d...

bors added a commit that referenced this pull request May 20, 2016

Auto merge of #2687 - alexcrichton:panic-abort, r=wycats
Implement the `panic` profile option

This is the Cargo half of the implementation of [RFC 1513] which adds a new
`profile.*.panic` option to customize the `-C panic` argument to the compiler.
This is not passed by default and can otherwise be specified as `abort` or
`unwind` on the nightly compiler.

[RFC 1513]: rust-lang/rfcs#1513

The `profile.*.panic` option is *only* used from the top-level crate, not each
crate individually. This means that applications should customize this value as
they see fit, and libraries will only use their own value when they're being
tested.

Cargo also has specific knowledge that when *testing* a crate it can't pass
`-C panic=abort` for now as the default test harness requires `panic=unwind`.
This essentially just means that `cargo test` will continue to work for crates
that specify `panic=abort` in Cargo.toml.
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors May 20, 2016

Contributor

💔 Test failed - cargo-linux-64

Contributor

bors commented May 20, 2016

💔 Test failed - cargo-linux-64

Implement the `panic` profile option
This is the Cargo half of the implementation of [RFC 1513] which adds a new
`profile.*.panic` option to customize the `-C panic` argument to the compiler.
This is not passed by default and can otherwise be specified as `abort` or
`unwind` on the nightly compiler.

[RFC 1513]: rust-lang/rfcs#1513

The `profile.*.panic` option is *only* used from the top-level crate, not each
crate individually. This means that applications should customize this value as
they see fit, and libraries will only use their own value when they're being
tested.

Cargo also has specific knowledge that when *testing* a crate it can't pass
`-C panic=abort` for now as the default test harness requires `panic=unwind`.
This essentially just means that `cargo test` will continue to work for crates
that specify `panic=abort` in Cargo.toml.
@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton May 20, 2016

Member

@bors: r=wycats

Member

alexcrichton commented May 20, 2016

@bors: r=wycats

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors May 20, 2016

Contributor

📌 Commit 75848a2 has been approved by wycats

Contributor

bors commented May 20, 2016

📌 Commit 75848a2 has been approved by wycats

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors May 21, 2016

Contributor

⌛️ Testing commit 75848a2 with merge 259324c...

Contributor

bors commented May 21, 2016

⌛️ Testing commit 75848a2 with merge 259324c...

bors added a commit that referenced this pull request May 21, 2016

Auto merge of #2687 - alexcrichton:panic-abort, r=wycats
Implement the `panic` profile option

This is the Cargo half of the implementation of [RFC 1513] which adds a new
`profile.*.panic` option to customize the `-C panic` argument to the compiler.
This is not passed by default and can otherwise be specified as `abort` or
`unwind` on the nightly compiler.

[RFC 1513]: rust-lang/rfcs#1513

The `profile.*.panic` option is *only* used from the top-level crate, not each
crate individually. This means that applications should customize this value as
they see fit, and libraries will only use their own value when they're being
tested.

Cargo also has specific knowledge that when *testing* a crate it can't pass
`-C panic=abort` for now as the default test harness requires `panic=unwind`.
This essentially just means that `cargo test` will continue to work for crates
that specify `panic=abort` in Cargo.toml.

@bors bors merged commit 75848a2 into rust-lang:master May 21, 2016

2 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@alexbool

This comment has been minimized.

Show comment
Hide comment
@alexbool

alexbool May 22, 2016

Seems like there's a bug in your implementation.
When I build my crate with

[profile.dev]
panic = "abort"

I get an error if my crate depends on any crate that builds using a build.rs.
The failure looks as following:

$ cargo build --release --verbose
...
   Compiling kernel32-sys v0.2.2
     Running `rustc /Users/alexbool/.cargo/registry/src/github.com-1ecc6299db9ec823/kernel32-sys-0.2.2/build.rs --crate-name build_script_build --crate-type bin -g --out-dir /Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/build/kernel32-sys-d6afa5bd3d7cfaef --emit=dep-info,link -L dependency=/Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/deps -L dependency=/Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/deps --extern build=/Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/deps/libbuild-493a7b0628804707.rlib --cap-lints allow`
error: the crate `build` is compiled with the panic strategy `abort` which is incompatible with this crate's strategy of `unwind`
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
error: Could not compile `kernel32-sys`.

Seems like there's a bug in your implementation.
When I build my crate with

[profile.dev]
panic = "abort"

I get an error if my crate depends on any crate that builds using a build.rs.
The failure looks as following:

$ cargo build --release --verbose
...
   Compiling kernel32-sys v0.2.2
     Running `rustc /Users/alexbool/.cargo/registry/src/github.com-1ecc6299db9ec823/kernel32-sys-0.2.2/build.rs --crate-name build_script_build --crate-type bin -g --out-dir /Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/build/kernel32-sys-d6afa5bd3d7cfaef --emit=dep-info,link -L dependency=/Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/deps -L dependency=/Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/deps --extern build=/Users/alexbool/Documents/IdeaProjects/rust/mycrate/target/release/deps/libbuild-493a7b0628804707.rlib --cap-lints allow`
error: the crate `build` is compiled with the panic strategy `abort` which is incompatible with this crate's strategy of `unwind`
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
error: Could not compile `kernel32-sys`.

@alexcrichton alexcrichton deleted the alexcrichton:panic-abort branch May 22, 2016

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton May 22, 2016

Member

Thanks for the report @alexbool! I unfortunately can't seem to reproduce easily, could you open an issue with some instructions about how to reproduce as well?

Member

alexcrichton commented May 22, 2016

Thanks for the report @alexbool! I unfortunately can't seem to reproduce easily, could you open an issue with some instructions about how to reproduce as well?

@tomaka

This comment has been minimized.

Show comment
Hide comment
@tomaka

tomaka May 22, 2016

Contributor

@alexcrichton I didn't test a lot, but I think the issue appears when you have a different value for panic for the dev and release profiles.

Contributor

tomaka commented May 22, 2016

@alexcrichton I didn't test a lot, but I think the issue appears when you have a different value for panic for the dev and release profiles.

@alexbool

This comment has been minimized.

Show comment
Hide comment

@alexcrichton the issue is #2726 :)

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton May 23, 2016

Member

Thanks!

Member

alexcrichton commented May 23, 2016

Thanks!

@ozkriff ozkriff referenced this pull request in ozkriff/nergal May 30, 2016

Open

Check panic="abort" #18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment