core: Match IRRT compile flavor with build profile

This commit is contained in:
David Mak 2024-03-06 12:57:20 +08:00
parent b26cb2b360
commit f682e9bf7a
1 changed files with 7 additions and 3 deletions

View File

@ -14,11 +14,15 @@ fn main() {
* HACK: Sadly, clang doesn't let us emit generic LLVM bitcode. * 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. * Compiling for WASM32 and filtering the output with regex is the closest we can get.
*/ */
const FLAG: &[&str] = &[ let flags: &[&str] = &[
"--target=wasm32", "--target=wasm32",
FILE, FILE,
"-fno-discard-value-names", "-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", "-emit-llvm",
"-S", "-S",
"-Wall", "-Wall",
@ -32,7 +36,7 @@ fn main() {
let out_path = Path::new(&out_dir); let out_path = Path::new(&out_dir);
let output = Command::new("clang-irrt") let output = Command::new("clang-irrt")
.args(FLAG) .args(flags)
.output() .output()
.map(|o| { .map(|o| {
assert!(o.status.success(), "{}", std::str::from_utf8(&o.stderr).unwrap()); assert!(o.status.success(), "{}", std::str::from_utf8(&o.stderr).unwrap());