From ad261507454428a9825700290ef2cf596bb5040f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 7 Jan 2025 18:11:40 -0500 Subject: [PATCH 1/2] Update the `libm` submodule This includes [1], which fixes a bug parsing non-numeric optimization levels. [1]: https://github.com/rust-lang/libm/pull/417 --- libm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libm b/libm index 44770b96..8e82616f 160000 --- a/libm +++ b/libm @@ -1 +1 @@ -Subproject commit 44770b96920557baf38990d2ee4142e166be579d +Subproject commit 8e82616f154b06cf4ee9cdb82a4f56474a403d04 From 4e3cc6d13e0331c4a3851828a851933a7ba130b4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 7 Jan 2025 18:12:19 -0500 Subject: [PATCH 2/2] Account for optimization levels other than numbers The build script currently panics with `opt-level=z` or `opt-level=s`. Account for this here. This is the `compiler-builtins` version of [1]. Fixes: https://github.com/rust-lang/compiler-builtins/issues/742 [1]: https://github.com/rust-lang/libm/pull/417 --- build.rs | 2 +- configure.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 2bb8651d..f512fc2e 100644 --- a/build.rs +++ b/build.rs @@ -121,7 +121,7 @@ fn configure_libm(target: &Target) { } println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)"); - if target.opt_level >= 2 { + if !matches!(target.opt_level.as_str(), "0" | "1") { println!("cargo:rustc-cfg=optimizations_enabled"); } diff --git a/configure.rs b/configure.rs index 6cfbe11c..87bc7a0e 100644 --- a/configure.rs +++ b/configure.rs @@ -6,7 +6,7 @@ use std::env; #[allow(dead_code)] pub struct Target { pub triple: String, - pub opt_level: u8, + pub opt_level: String, pub cargo_features: Vec, pub os: String, pub arch: String, @@ -32,7 +32,7 @@ impl Target { Self { triple: env::var("TARGET").unwrap(), os: env::var("CARGO_CFG_TARGET_OS").unwrap(), - opt_level: env::var("OPT_LEVEL").unwrap().parse().unwrap(), + opt_level: env::var("OPT_LEVEL").unwrap(), cargo_features, arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(), vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),