Skip to content

Commit e171452

Browse files
committed
Update the libm submodule
1 parent 520e2a0 commit e171452

File tree

5 files changed

+61
-6
lines changed

5 files changed

+61
-6
lines changed

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,12 @@ panic = 'abort'
8383

8484
[profile.dev]
8585
panic = 'abort'
86+
87+
[lints.rust]
88+
# Values used during testing
89+
unexpected_cfgs = { level = "warn", check-cfg = [
90+
'cfg(feature, values("arch"))',
91+
'cfg(feature, values("force-soft-floats"))',
92+
'cfg(feature, values("unstable-float"))',
93+
'cfg(feature, values("unstable-intrinsics"))',
94+
] }

build.rs

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ fn main() {
1414
configure_check_cfg();
1515
configure_f16_f128(&target);
1616

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

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

2421
// Emscripten's runtime includes all the builtins
2522
if target.os == "emscripten" {
@@ -104,6 +101,46 @@ fn main() {
104101
}
105102
}
106103

104+
/// Run configuration for `libm` since it is included directly.
105+
///
106+
/// Much of this is copied from `libm/configure.rs`.
107+
fn configure_libm(target: &Target) {
108+
println!("cargo:rustc-cfg=intrinsics_enabled");
109+
println!("cargo:rustc-cfg=arch_enabled");
110+
println!("cargo:rustc-cfg=optimizations_enabled");
111+
112+
// Always use intrinsics
113+
println!("cargo:rustc-cfg=intrinsics_enabled");
114+
115+
if cfg!(feature = "no-asm") {
116+
println!("cargo:rustc-cfg=feature=\"force-soft-floats\"");
117+
} else {
118+
println!("cargo:rustc-cfg=arch_enabled");
119+
}
120+
121+
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
122+
if target.opt_level >= 2 {
123+
println!("cargo:rustc-cfg=optimizations_enabled");
124+
}
125+
126+
// Config shorthands
127+
println!("cargo:rustc-check-cfg=cfg(x86_no_sse)");
128+
if target.arch == "x86" && !target.features.iter().any(|f| f == "sse") {
129+
// Shorthand to detect i586 targets
130+
println!("cargo:rustc-cfg=x86_no_sse");
131+
}
132+
133+
println!(
134+
"cargo:rustc-env=CFG_CARGO_FEATURES={:?}",
135+
target.cargo_features
136+
);
137+
println!("cargo:rustc-env=CFG_OPT_LEVEL={}", target.opt_level);
138+
println!("cargo:rustc-env=CFG_TARGET_FEATURES={:?}", target.features);
139+
140+
// Activate libm's unstable features to make full use of Nightly.
141+
println!("cargo:rustc-cfg=feature=\"unstable-intrinsics\"");
142+
}
143+
107144
fn aarch64_symbol(ordering: Ordering) -> &'static str {
108145
match ordering {
109146
Ordering::Relaxed => "relax",

configure.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::env;
66
#[allow(dead_code)]
77
pub struct Target {
88
pub triple: String,
9+
pub opt_level: u8,
10+
pub cargo_features: Vec<String>,
911
pub os: String,
1012
pub arch: String,
1113
pub vendor: String,
@@ -22,10 +24,16 @@ impl Target {
2224
"big" => false,
2325
x => panic!("unknown endian {x}"),
2426
};
27+
let cargo_features = env::vars()
28+
.filter_map(|(name, _value)| name.strip_prefix("CARGO_FEATURE_").map(ToOwned::to_owned))
29+
.map(|s| s.to_lowercase().replace("_", "-"))
30+
.collect();
2531

2632
Self {
2733
triple: env::var("TARGET").unwrap(),
2834
os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
35+
opt_level: env::var("OPT_LEVEL").unwrap().parse().unwrap(),
36+
cargo_features,
2937
arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
3038
vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),
3139
env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),

libm

Submodule libm updated 177 files

src/math.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[rustfmt::skip]
12
#[allow(dead_code)]
23
#[allow(unused_imports)]
34
#[allow(clippy::all)]

0 commit comments

Comments
 (0)