From ab34373da2305f8862948496d745ff3e3bee78cb Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Mon, 3 Feb 2025 14:26:45 -0500 Subject: [PATCH] Correctly choose profile to use. If, e.g., a user sets `CARGO_PROFILE_RELEASE_DEBUG=1`, the `DEBUG` environment variable will be set accordingly, and so the debug build will be used. Instead, we should use the PROFILE env variable (see https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts) to determine which profile to use. This isn't 100% correct, because it won't pass through any other flags (in this case, we won't have debug information for the cubeb backend), but it is more correct to ensure the matching profile. --- cubeb-sys/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubeb-sys/build.rs b/cubeb-sys/build.rs index 7723d69..ec4fb6f 100644 --- a/cubeb-sys/build.rs +++ b/cubeb-sys/build.rs @@ -113,7 +113,7 @@ fn main() { .env("CARGO_BUILD_TARGET", &target) .build(); - let debug = env::var("DEBUG").unwrap().parse::().unwrap(); + let debug = env::var("PROFILE").unwrap() == "debug"; println!("cargo:rustc-link-lib=static=cubeb"); if windows {