Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 463e9df

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.
1 parent 6f72bab commit 463e9df

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libm/configure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::PathBuf;
77
pub struct Config {
88
pub manifest_dir: PathBuf,
99
pub out_dir: PathBuf,
10-
pub opt_level: u8,
10+
pub opt_level: String,
1111
pub cargo_features: Vec<String>,
1212
pub target_arch: String,
1313
pub target_env: String,
@@ -31,7 +31,7 @@ impl Config {
3131
Self {
3232
manifest_dir: PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()),
3333
out_dir: PathBuf::from(env::var("OUT_DIR").unwrap()),
34-
opt_level: env::var("OPT_LEVEL").unwrap().parse().unwrap(),
34+
opt_level: env::var("OPT_LEVEL").unwrap(),
3535
cargo_features,
3636
target_arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
3737
target_env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
@@ -91,7 +91,7 @@ fn emit_arch_cfg() {
9191
fn emit_optimization_cfg(cfg: &Config) {
9292
println!("cargo:rustc-check-cfg=cfg(optimizations_enabled)");
9393

94-
if cfg.opt_level >= 2 {
94+
if !matches!(cfg.opt_level.as_str(), "0" | "1") {
9595
println!("cargo:rustc-cfg=optimizations_enabled");
9696
}
9797
}

0 commit comments

Comments
 (0)