Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the libm submodule
Browse files Browse the repository at this point in the history
tgross35 committed Jan 6, 2025
1 parent 520e2a0 commit b973e6c
Showing 5 changed files with 62 additions and 6 deletions.
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -83,3 +83,12 @@ panic = 'abort'

[profile.dev]
panic = 'abort'

[lints.rust]
# Values used during testing
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("arch"))',
'cfg(feature, values("force-soft-floats"))',
'cfg(feature, values("unstable-float"))',
'cfg(feature, values("unstable-intrinsics"))',
] }
48 changes: 43 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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" {
@@ -104,6 +101,47 @@ 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-cfg=intrinsics_enabled");
println!("cargo:rustc-cfg=arch_enabled");
println!("cargo:rustc-cfg=optimizations_enabled");

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

//
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",
8 changes: 8 additions & 0 deletions configure.rs
Original file line number Diff line number Diff line change
@@ -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,
@@ -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(),
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)]

0 comments on commit b973e6c

Please sign in to comment.