diff --git a/bril-rs/brillvm/.cargo/config b/bril-rs/brillvm/.cargo/config deleted file mode 100644 index 59c989e69..000000000 --- a/bril-rs/brillvm/.cargo/config +++ /dev/null @@ -1,11 +0,0 @@ -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] - -[target.aarch64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] \ No newline at end of file diff --git a/bril-rs/brillvm/Cargo.toml b/bril-rs/brillvm/Cargo.toml index 2767e1ba9..4211c8917 100644 --- a/bril-rs/brillvm/Cargo.toml +++ b/bril-rs/brillvm/Cargo.toml @@ -1,3 +1,4 @@ +workspace = { members = ["runtime"] } [package] name = "brillvm" version = "0.1.0" @@ -19,16 +20,11 @@ clap = { version = "4.4", features = ["derive"] } inkwell = { git = "https://github.com/TheDan64/inkwell.git", features = [ "llvm18-0", ] } -libc-print = "0.1" [dependencies.bril-rs] path = ".." features = ["float", "ssa", "memory"] -[[bin]] -name = "rt" -path = "bin/rt.rs" - # Need to set a default `main` to build `rt` bin [[bin]] name = "main" diff --git a/bril-rs/brillvm/Makefile b/bril-rs/brillvm/Makefile index ac55676a5..f10a7c6b0 100644 --- a/bril-rs/brillvm/Makefile +++ b/bril-rs/brillvm/Makefile @@ -19,16 +19,16 @@ clean: .PHONY: rt rt: - cargo rustc --bin rt --release -- --emit=llvm-bc && mv target/release/deps/rt-*.bc rt.bc + cd runtime && cargo rustc --release -- --emit=llvm-bc && mv ../target/release/deps/runtime-*.bc ../rt.bc example: # bril2json < ../../benchmarks/mem/sieve.bril | cargo run -- -i 100 bril2json < ../../benchmarks/mixed/cholesky.bril | cargo run -- -i .PHONY: test -test: build rt +test: turnt -e brillvm $(TESTS) .PHONY: benchmark -benchmark: build rt +benchmark: turnt -e brillvm $(BENCHMARKS) \ No newline at end of file diff --git a/bril-rs/brillvm/runtime/Cargo.toml b/bril-rs/brillvm/runtime/Cargo.toml new file mode 100644 index 000000000..baeb2469e --- /dev/null +++ b/bril-rs/brillvm/runtime/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "runtime" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +libc-print = "0.1" \ No newline at end of file diff --git a/bril-rs/brillvm/runtime/build.rs b/bril-rs/brillvm/runtime/build.rs new file mode 100644 index 000000000..b3b098f5c --- /dev/null +++ b/bril-rs/brillvm/runtime/build.rs @@ -0,0 +1,11 @@ +fn main() { + #[cfg(target_os = "linux")] + println!("cargo:rustc-link-arg=-nostdlib"); + #[cfg(target_os = "macos")] + println!("cargo:rustc-link-arg=-undefined"); + #[cfg(target_os = "macos")] + println!("cargo:rustc-link-arg=dynamic_lookup"); + + #[cfg(not(any(target_os = "linux", target_os = "macos")))] + assert!(false) +} diff --git a/bril-rs/brillvm/bin/rt.rs b/bril-rs/brillvm/runtime/src/main.rs similarity index 96% rename from bril-rs/brillvm/bin/rt.rs rename to bril-rs/brillvm/runtime/src/main.rs index 60836aa59..53333b0fe 100644 --- a/bril-rs/brillvm/bin/rt.rs +++ b/bril-rs/brillvm/runtime/src/main.rs @@ -72,6 +72,11 @@ pub unsafe extern "C" fn _bril_parse_float(arg: *const c_char) -> f64 { r_str.parse::().unwrap() } +#[no_mangle] +pub extern "C" fn _start() -> ! { + loop {} +} + #[cfg(not(test))] #[panic_handler] fn my_panic(_info: &core::panic::PanicInfo) -> ! {