Skip to content

Commit

Permalink
Merge pull request #319 from Pat-Lafon/llvm-18
Browse files Browse the repository at this point in the history
Update Brillvm to Llvm 18
  • Loading branch information
sampsyo authored May 27, 2024
2 parents 45edbd3 + ca6ff3e commit a9925d5
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 165 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,42 @@ on:

name: Workflow checks for rust code

env:
LLVM_VERSION: 18.0

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
test-code:
- "cd bril-rs && make test TURNTARGS=-v"
- "cd bril-rs && make features"
- "cd brilirs && make test TURNTARGS=-v"
- "cd brilirs && make benchmark TURNTARGS=-v"
- "cd brilift && cargo build --release && make rt.o && make test TURNTARGS=-v"
- "cd brilift && cargo build --release && make rt.o && make benchmark TURNTARGS=-v"
# Code requiring additional dependencies are separated out
include:
- test-code: "cd bril-rs && make features"
needs_cargo_hack: true
- test-code: "cd bril-rs/brillvm && make build"
needs_llvm: true
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable

- name: Install LLVM and Clang
if: matrix.needs_llvm
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ env.LLVM_VERSION }} all
- name: Install cargo-hack for feature-flag checking
run: cargo install cargo-hack
if: matrix.needs_cargo_hack

- uses: actions/setup-python@v4
with:
Expand All @@ -65,7 +81,8 @@ jobs:
repository: cucapra/turnt
path: './turnt'
- name: Install Turnt part 2
run: cd turnt ; flit install --symlink
run: flit install --symlink
working-directory: ./turnt

- name: Problem matcher
run: echo '::add-matcher::.github/tap-matcher.json'
Expand All @@ -88,10 +105,11 @@ jobs:
toolchain: stable

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
if: matrix.path == 'bril-rs/brillvm/Cargo.toml'
with:
version: "16.0"
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ env.LLVM_VERSION }} all
- name: cargo check
run: cargo check --manifest-path ${{ matrix.path }} --all-targets
Expand Down
1 change: 0 additions & 1 deletion bril-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"
description = "A rust representation of the Bril language"
readme = "README.md"
repository = "https://github.com/sampsyo/bril"
# license = "MIT"
license-file = "../LICENSE"
categories = ["command-line-utilities", "compilers", "data-structures", "parser-implementations"]
keywords = ["compiler", "bril", "parser", "data-structures", "language"]
Expand Down
11 changes: 0 additions & 11 deletions bril-rs/brillvm/.cargo/config

This file was deleted.

23 changes: 3 additions & 20 deletions bril-rs/brillvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,15 @@ default-run = "main"

[dependencies]
clap = { version = "4.4", features = ["derive"] }
inkwell = { version = "0.2", features = ["llvm16-0"] }
libc-print = "0.1"

# For overriding parking_lot_core to latest version from 0.9.7
# To pull in the removal of `window-sys` which was causing duplicate dependencies
[patch.crates-io]
parking_lot_core = { git = "https://github.com/Amanieu/parking_lot" }
inkwell = { git = "https://github.com/TheDan64/inkwell.git", features = [
"llvm18-0",
] }

[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"
path = "src/main.rs"

# To properly set up the rt library for linking with LLVM
[profile.dev]
panic = "abort"
lto = true

[profile.release]
panic = "abort"
lto = true
8 changes: 6 additions & 2 deletions bril-rs/brillvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ BENCHMARKS := ../../benchmarks/core/*.bril \
../../benchmarks/mem/*.bril \
../../benchmarks/mixed/*.bril

build:
cargo build

clean:
cargo clean
rm rt.bc
rm tmp.ll

.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
# bril2json < ../../benchmarks/mixed/cholesky.bril | cargo run -- -i
bril2json < ../../test/interp/ssa/ssa-two-phi.bril | cargo run -- -i true

.PHONY: test
test:
Expand Down
12 changes: 12 additions & 0 deletions bril-rs/brillvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ This tool relies on the `llvm-sys` crate to find the correct version of LLVM to
```shell
LLVM_SYS_150_PREFIX="/opt/homebrew/Cellar/llvm/15.0.7_1/"
```

### zstd not found

```shell
ld: Library 'zstd' not found
```

Mac specific: Assuming you have zstd installed via `brew install zstd`, googling
around has found that you might need
`export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix zstd)/lib/`. Apparently this
also hit the ruby community at some point so, they have many issues with similar
resolutions to this problem.
18 changes: 18 additions & 0 deletions bril-rs/brillvm/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[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"

# To properly set up the rt library for linking with LLVM
[profile.dev]
panic = "abort"
lto = true

[profile.release]
panic = "abort"
lto = true
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)
}
File renamed without changes.
Loading

0 comments on commit a9925d5

Please sign in to comment.