Skip to content

Commit 4e3cc6d

Browse files
committed
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: #742 [1]: rust-lang/libm#417
1 parent ad26150 commit 4e3cc6d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn configure_libm(target: &Target) {
121121
}
122122

123123
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
124-
if target.opt_level >= 2 {
124+
if !matches!(target.opt_level.as_str(), "0" | "1") {
125125
println!("cargo:rustc-cfg=optimizations_enabled");
126126
}
127127

configure.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::env;
66
#[allow(dead_code)]
77
pub struct Target {
88
pub triple: String,
9-
pub opt_level: u8,
9+
pub opt_level: String,
1010
pub cargo_features: Vec<String>,
1111
pub os: String,
1212
pub arch: String,
@@ -32,7 +32,7 @@ impl Target {
3232
Self {
3333
triple: env::var("TARGET").unwrap(),
3434
os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
35-
opt_level: env::var("OPT_LEVEL").unwrap().parse().unwrap(),
35+
opt_level: env::var("OPT_LEVEL").unwrap(),
3636
cargo_features,
3737
arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
3838
vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),

0 commit comments

Comments
 (0)