Skip to content

Commit 4359549

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

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

build.rs

Lines changed: 44 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,48 @@ 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-check-cfg=cfg(intrinsics_enabled)");
109+
println!("cargo:rustc-check-cfg=cfg(arch_enabled)");
110+
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
111+
println!("cargo:rustc-check-cfg=cfg(feature, values(\"unstable-public-internals\"))");
112+
113+
// Always use intrinsics
114+
println!("cargo:rustc-cfg=intrinsics_enabled");
115+
116+
// The arch module may contain assembly.
117+
if cfg!(feature = "no-asm") {
118+
println!("cargo:rustc-cfg=feature=\"force-soft-floats\"");
119+
} else {
120+
println!("cargo:rustc-cfg=arch_enabled");
121+
}
122+
123+
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
124+
if target.opt_level >= 2 {
125+
println!("cargo:rustc-cfg=optimizations_enabled");
126+
}
127+
128+
// Config shorthands
129+
println!("cargo:rustc-check-cfg=cfg(x86_no_sse)");
130+
if target.arch == "x86" && !target.features.iter().any(|f| f == "sse") {
131+
// Shorthand to detect i586 targets
132+
println!("cargo:rustc-cfg=x86_no_sse");
133+
}
134+
135+
println!(
136+
"cargo:rustc-env=CFG_CARGO_FEATURES={:?}",
137+
target.cargo_features
138+
);
139+
println!("cargo:rustc-env=CFG_OPT_LEVEL={}", target.opt_level);
140+
println!("cargo:rustc-env=CFG_TARGET_FEATURES={:?}", target.features);
141+
142+
// Activate libm's unstable features to make full use of Nightly.
143+
println!("cargo:rustc-cfg=feature=\"unstable-intrinsics\"");
144+
}
145+
107146
fn aarch64_symbol(ordering: Ordering) -> &'static str {
108147
match ordering {
109148
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)