Skip to content

Commit

Permalink
Merge pull request #743 from tgross35/fix-opt-level
Browse files Browse the repository at this point in the history
Account for optimization levels other than numbers
  • Loading branch information
tgross35 authored Jan 7, 2025
2 parents 280c7b1 + 4e3cc6d commit 288a33f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
4 changes: 2 additions & 2 deletions configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub os: String,
pub arch: String,
Expand All @@ -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(),
Expand Down

0 comments on commit 288a33f

Please sign in to comment.