Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ fn main() {
configure_check_cfg();
configure_f16_f128(&target);

println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display());
configure_libm(&target);

// Activate libm's unstable features to make full use of Nightly.
println!("cargo::rustc-check-cfg=cfg(feature, values(\"unstable\", \"force-soft-floats\"))");
println!("cargo:rustc-cfg=feature=\"unstable\"");
println!("cargo:rustc-cfg=feature=\"force-soft-floats\"");
println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display());

// Emscripten's runtime includes all the builtins
if target.os == "emscripten" {
Expand Down Expand Up @@ -104,6 +101,48 @@ fn main() {
}
}

/// Run configuration for `libm` since it is included directly.
///
/// Much of this is copied from `libm/configure.rs`.
fn configure_libm(target: &Target) {
println!("cargo:rustc-check-cfg=cfg(intrinsics_enabled)");
println!("cargo:rustc-check-cfg=cfg(arch_enabled)");
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
println!("cargo:rustc-check-cfg=cfg(feature, values(\"unstable-public-internals\"))");

// Always use intrinsics
println!("cargo:rustc-cfg=intrinsics_enabled");

// The arch module may contain assembly.
if cfg!(feature = "no-asm") {
println!("cargo:rustc-cfg=feature=\"force-soft-floats\"");
} else {
println!("cargo:rustc-cfg=arch_enabled");
}

println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
if target.opt_level >= 2 {
println!("cargo:rustc-cfg=optimizations_enabled");
}

// Config shorthands
println!("cargo:rustc-check-cfg=cfg(x86_no_sse)");
if target.arch == "x86" && !target.features.iter().any(|f| f == "sse") {
// Shorthand to detect i586 targets
println!("cargo:rustc-cfg=x86_no_sse");
}

println!(
"cargo:rustc-env=CFG_CARGO_FEATURES={:?}",
target.cargo_features
);
println!("cargo:rustc-env=CFG_OPT_LEVEL={}", target.opt_level);
println!("cargo:rustc-env=CFG_TARGET_FEATURES={:?}", target.features);

// Activate libm's unstable features to make full use of Nightly.
println!("cargo:rustc-cfg=feature=\"unstable-intrinsics\"");
}

fn aarch64_symbol(ordering: Ordering) -> &'static str {
match ordering {
Ordering::Relaxed => "relax",
Expand Down
8 changes: 8 additions & 0 deletions configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::env;
#[allow(dead_code)]
pub struct Target {
pub triple: String,
pub opt_level: u8,
pub cargo_features: Vec<String>,
pub os: String,
pub arch: String,
pub vendor: String,
Expand All @@ -22,10 +24,16 @@ impl Target {
"big" => false,
x => panic!("unknown endian {x}"),
};
let cargo_features = env::vars()
.filter_map(|(name, _value)| name.strip_prefix("CARGO_FEATURE_").map(ToOwned::to_owned))
.map(|s| s.to_lowercase().replace("_", "-"))
.collect();

Self {
triple: env::var("TARGET").unwrap(),
os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
opt_level: env::var("OPT_LEVEL").unwrap().parse().unwrap(),
cargo_features,
arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),
env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion libm
Submodule libm updated 177 files
1 change: 1 addition & 0 deletions src/math.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[rustfmt::skip]
#[allow(dead_code)]
#[allow(unused_imports)]
#[allow(clippy::all)]
Expand Down
Loading