Trevor Gross f0b932e723 Rework the available Cargo profiles
Currently the default release profile enables LTO and single CGU builds,
which is very slow to build. Most tests are better run with
optimizations enabled since it allows testing a much larger number of
inputs, so it is inconvenient that building can sometimes take
significantly longer than the tests.

Remedy this by doing the following:

* Move the existing `release` profile to `release-opt`.
* With the above, the default `release` profile is untouched (16 CGUs
  and thin local LTO).
* `release-checked` inherits `release`, so no LTO or single CGU.

This means that the simple `cargo test --release` becomes much faster
for local development. We are able to enable the other profiles as
needed in CI.

Tests should ideally still be run with `--profile release-checked` to
ensure there are no debug assetions or unexpected wrapping math hit.

`no-panic` still needs a single CGU, so must be run with `--profile
release-opt`. Since it is not possible to detect CGU or profilel
configuration from within build scripts, the `ENSURE_NO_PANIC`
environment variable must now always be set.
2025-01-25 07:38:15 +00:00

18 lines
417 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)");
// If set, enable `no-panic`. Requires LTO (`release-opt` profile).
if env::var("ENSURE_NO_PANIC").is_ok() {
println!("cargo:rustc-cfg=assert_no_panic");
}
configure::emit_libm_config(&cfg);
}