forked from M-Labs/nac3
1
0
Fork 0

switch to clang-unwrapped, build IRRT with wasm32

This commit is contained in:
Sebastien Bourdeauducq 2022-01-09 10:53:58 +08:00
parent 096193f7ab
commit b88f17ed42
2 changed files with 9 additions and 3 deletions

View File

@ -177,7 +177,7 @@
name = "nac3-dev-shell"; name = "nac3-dev-shell";
buildInputs = with pkgs; [ buildInputs = with pkgs; [
packages.x86_64-linux.llvm-nac3 packages.x86_64-linux.llvm-nac3
clang_13 llvmPackages_13.clang-unwrapped # for IRRT
lld_13 lld_13
cargo cargo
cargo-insta cargo-insta

View File

@ -6,10 +6,16 @@ use std::{
}; };
fn main() { fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
const FILE: &str = "src/codegen/irrt/irrt.c"; const FILE: &str = "src/codegen/irrt/irrt.c";
println!("cargo:rerun-if-changed={}", FILE); 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] = &[ const FLAG: &[&str] = &[
"--target=wasm32",
FILE, FILE,
"-O3", "-O3",
"-emit-llvm", "-emit-llvm",
@ -46,7 +52,7 @@ fn main() {
let mut llvm_as = Command::new("llvm-as") let mut llvm_as = Command::new("llvm-as")
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.arg("-o") .arg("-o")
.arg(&format!("{}/irrt.bc", out_dir)) .arg(&format!("{}/irrt.bc", env::var("OUT_DIR").unwrap()))
.spawn() .spawn()
.unwrap(); .unwrap();
llvm_as.stdin.as_mut().unwrap().write_all(filtered_output.as_bytes()).unwrap(); llvm_as.stdin.as_mut().unwrap().write_all(filtered_output.as_bytes()).unwrap();