Skip to content

Commit

Permalink
move runtime to own crate, add _start, and use build script for config
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat-Lafon committed May 5, 2024
1 parent 9fc993a commit b2f56ae
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
11 changes: 0 additions & 11 deletions bril-rs/brillvm/.cargo/config

This file was deleted.

6 changes: 1 addition & 5 deletions bril-rs/brillvm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
workspace = { members = ["runtime"] }
[package]
name = "brillvm"
version = "0.1.0"
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions bril-rs/brillvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 9 additions & 0 deletions bril-rs/brillvm/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 11 additions & 0 deletions bril-rs/brillvm/runtime/build.rs
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ pub unsafe extern "C" fn _bril_parse_float(arg: *const c_char) -> f64 {
r_str.parse::<f64>().unwrap()
}

#[no_mangle]
pub extern "C" fn _start() -> ! {
loop {}
}

#[cfg(not(test))]
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
Expand Down

0 comments on commit b2f56ae

Please sign in to comment.