mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-25 06:32:04 +00:00
We currently have a non-additive feature, "force-soft-floats", and we will need to gain another "no-f16-f128". This makes `cfg` usage in code somewhat confusing and redundant. Use `build.rs` to figure out if "unstable-intrinsics" is enabled while "force-soft-floats" is not enabled and if so, emit a cfg `intrinsics_enabled`. This is cleaner to use and should make adding more features easier to reason about. Also use this as an opportunity to eliminate the build.rs from the compiler-builtins test crate, replaced with the `[lints]` table in Cargo.toml.
31 lines
925 B
Rust
31 lines
925 B
Rust
use std::env;
|
|
|
|
fn main() {
|
|
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" {
|
|
println!("cargo:rustc-cfg=assert_no_panic");
|
|
}
|
|
}
|
|
|
|
configure_intrinsics();
|
|
}
|
|
|
|
/// Simplify the feature logic for enabling intrinsics so code only needs to use
|
|
/// `cfg(intrinsics_enabled)`.
|
|
fn configure_intrinsics() {
|
|
println!("cargo:rustc-check-cfg=cfg(intrinsics_enabled)");
|
|
|
|
// Disabled by default; `unstable-intrinsics` enables again; `force-soft-floats` overrides
|
|
// to disable.
|
|
if cfg!(feature = "unstable-intrinsics") && !cfg!(feature = "force-soft-floats") {
|
|
println!("cargo:rustc-cfg=intrinsics_enabled");
|
|
}
|
|
}
|