mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-06 20:27:48 +00:00

A failing debug assertion or overflow without correctly wrapping or saturating is a bug, but the `debug` profile that has these enabled does not run enough test cases to hit edge cases that may trigger these. Add a new `release-checked` profile that enables debug assertions and overflow checks. This seems to only extend per-function test time by a few seconds (or around a minute on longer extensive tests), so enable this as the default on CI. In order to ensure `no_panic` still gets checked, add a build-only step to CI.
27 lines
786 B
Rust
27 lines
786 B
Rust
use std::env;
|
|
|
|
mod configure;
|
|
|
|
fn main() {
|
|
let cfg = configure::Config::from_env();
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rustc-check-cfg=cfg(assert_no_panic)");
|
|
|
|
println!("cargo:rustc-check-cfg=cfg(feature, values(\"checked\"))");
|
|
|
|
#[allow(unexpected_cfgs)]
|
|
if !cfg!(feature = "checked") {
|
|
let lvl = env::var("OPT_LEVEL").unwrap();
|
|
if lvl != "0" && !cfg!(debug_assertions) {
|
|
println!("cargo:rustc-cfg=assert_no_panic");
|
|
} else if env::var("ENSURE_NO_PANIC").is_ok() {
|
|
// Give us a defensive way of ensureing that no-panic is checked when we
|
|
// expect it to be.
|
|
panic!("`assert_no_panic `was not enabled");
|
|
}
|
|
}
|
|
|
|
configure::emit_libm_config(&cfg);
|
|
}
|