From f682e9bf7aff7c2308628ef6950ad8fa0d947d41 Mon Sep 17 00:00:00 2001 From: David Mak Date: Wed, 6 Mar 2024 12:57:20 +0800 Subject: [PATCH] core: Match IRRT compile flavor with build profile --- nac3core/build.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nac3core/build.rs b/nac3core/build.rs index 6edcf0b..5ed3acf 100644 --- a/nac3core/build.rs +++ b/nac3core/build.rs @@ -14,11 +14,15 @@ fn main() { * HACK: Sadly, clang doesn't let us emit generic LLVM bitcode. * Compiling for WASM32 and filtering the output with regex is the closest we can get. */ - const FLAG: &[&str] = &[ + let flags: &[&str] = &[ "--target=wasm32", FILE, "-fno-discard-value-names", - "-O3", + match env::var("PROFILE").as_deref() { + Ok("debug") => "-O0", + Ok("release") => "-O3", + flavor => panic!("Unknown or missing build flavor {:?}", flavor), + }, "-emit-llvm", "-S", "-Wall", @@ -32,7 +36,7 @@ fn main() { let out_path = Path::new(&out_dir); let output = Command::new("clang-irrt") - .args(FLAG) + .args(flags) .output() .map(|o| { assert!(o.status.success(), "{}", std::str::from_utf8(&o.stderr).unwrap());