diff --git a/flake.nix b/flake.nix index 5a51737b..1701e0c7 100644 --- a/flake.nix +++ b/flake.nix @@ -177,7 +177,7 @@ name = "nac3-dev-shell"; buildInputs = with pkgs; [ packages.x86_64-linux.llvm-nac3 - clang_13 + llvmPackages_13.clang-unwrapped # for IRRT lld_13 cargo cargo-insta diff --git a/nac3core/build.rs b/nac3core/build.rs index c4dcfc8e..c3bff8eb 100644 --- a/nac3core/build.rs +++ b/nac3core/build.rs @@ -6,10 +6,16 @@ use std::{ }; fn main() { - let out_dir = env::var("OUT_DIR").unwrap(); const FILE: &str = "src/codegen/irrt/irrt.c"; println!("cargo:rerun-if-changed={}", FILE); + + /* + * 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] = &[ + "--target=wasm32", FILE, "-O3", "-emit-llvm", @@ -46,7 +52,7 @@ fn main() { let mut llvm_as = Command::new("llvm-as") .stdin(Stdio::piped()) .arg("-o") - .arg(&format!("{}/irrt.bc", out_dir)) + .arg(&format!("{}/irrt.bc", env::var("OUT_DIR").unwrap())) .spawn() .unwrap(); llvm_as.stdin.as_mut().unwrap().write_all(filtered_output.as_bytes()).unwrap();