Skip to content

Commit

Permalink
Don't manually specify optimization flags for MSVC (cc-rs takes care)
Browse files Browse the repository at this point in the history
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
  • Loading branch information
andoalon authored and briansmith committed Oct 13, 2023
1 parent e7aedb2 commit 0841301
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,9 @@ fn configure_cc(c: &mut cc::Build, target: &Target, include_dir: &Path) {
let _ = c.define("NDEBUG", None);
}

if compiler.is_like_msvc() {
if std::env::var("OPT_LEVEL").unwrap() == "0" {
let _ = c.flag("/Od"); // Disable optimization for debug builds.
// run-time checking: (s)tack frame, (u)ninitialized variables
let _ = c.flag("/RTCsu");
} else {
let _ = c.flag("/Ox"); // Enable full optimization.
}
if compiler.is_like_msvc() && std::env::var("OPT_LEVEL").unwrap() == "0" {
// run-time checking: (s)tack frame, (u)ninitialized variables
let _ = c.flag("/RTCsu");
}

// Allow cross-compiling without a target sysroot for these targets.
Expand Down

0 comments on commit 0841301

Please sign in to comment.