Skip to content

Commit dbef8b1

Browse files
committed
ci(bolt): install MLIR dependencies for modular checks
1 parent 7dd9cae commit dbef8b1

5 files changed

Lines changed: 146 additions & 0 deletions

File tree

.github/workflows/rust.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ jobs:
4747
- uses: actions-rust-lang/setup-rust-toolchain@v1
4848
with:
4949
components: clippy
50+
- name: Install LLVM
51+
run: |
52+
wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh
53+
chmod +x /tmp/llvm.sh
54+
sudo /tmp/llvm.sh 22 all
55+
sudo apt-get install -y libmlir-22-dev mlir-22-tools
56+
- name: Configure LLVM
57+
run: |
58+
echo "MLIR_SYS_220_PREFIX=/usr/lib/llvm-22" >> "$GITHUB_ENV"
59+
echo "/usr/lib/llvm-22/bin" >> "$GITHUB_PATH"
5060
- name: cargo clippy --features allocative,host
5161
run: cargo clippy --all --all-targets --features allocative,host
5262
- name: cargo clippy --features allocative,host,zk
@@ -222,6 +232,18 @@ jobs:
222232
steps:
223233
- uses: actions/checkout@v6
224234
- uses: actions-rust-lang/setup-rust-toolchain@v1
235+
- name: Install LLVM
236+
run: |
237+
wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh
238+
chmod +x /tmp/llvm.sh
239+
sudo /tmp/llvm.sh 22 all
240+
sudo apt-get install -y libmlir-22-dev mlir-22-tools
241+
- name: Configure LLVM
242+
run: |
243+
echo "MLIR_SYS_220_PREFIX=/usr/lib/llvm-22" >> "$GITHUB_ENV"
244+
echo "/usr/lib/llvm-22/bin" >> "$GITHUB_PATH"
245+
- name: Build and install jolt CLI
246+
run: cargo install --path . --locked --force
225247
- name: Install nextest
226248
uses: taiki-e/install-action@nextest
227249
- name: Discover modular crates

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
*.txt
1212
.DS_Store
13+
.bolt-dev-env
1314

1415
pprof/
1516
# pprof files

CLAUDE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ cargo build -p jolt-core -q
4242
cargo install --path . --locked
4343
```
4444

45+
### Local Bolt/MLIR Environment
46+
47+
Before running Bolt MLIR/codegen checks locally, generate and source the Bolt
48+
dev environment:
49+
50+
```bash
51+
scripts/setup-bolt-dev.sh
52+
source .bolt-dev-env
53+
```
54+
55+
Agents should source `.bolt-dev-env` before any Bolt, generated-role, or
56+
Jolt-on-Bolt equivalence command so `llvm-config`, `MLIR_SYS_220_PREFIX`, and
57+
the local `jolt` CLI all resolve consistently.
58+
4559
### Profiling
4660

4761
```bash

crates/bolt/TESTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ gate suite while semantic construction lives in Bolt, generated crates,
88

99
## Fast Local Gates
1010

11+
Set up and source the Bolt dev environment first:
12+
13+
```bash
14+
scripts/setup-bolt-dev.sh
15+
source .bolt-dev-env
16+
```
17+
1118
Run:
1219

1320
```bash

scripts/setup-bolt-dev.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
env_file="${repo_root}/.bolt-dev-env"
6+
7+
usage() {
8+
cat <<'USAGE'
9+
Usage: scripts/setup-bolt-dev.sh
10+
11+
Installs/configures the local dependencies needed by Bolt MLIR/codegen checks
12+
on macOS:
13+
14+
- Homebrew llvm
15+
- rustup components: rust-src, rustfmt, clippy
16+
- cargo-nextest
17+
- jolt CLI installed from this checkout
18+
- .bolt-dev-env with MLIR_SYS_220_PREFIX, PATH, SDKROOT, and bindgen flags
19+
20+
After it finishes, run:
21+
22+
source .bolt-dev-env
23+
USAGE
24+
}
25+
26+
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
27+
usage
28+
exit 0
29+
fi
30+
31+
if [[ "$(uname -s)" != "Darwin" ]]; then
32+
cat >&2 <<'EOF'
33+
scripts/setup-bolt-dev.sh currently supports macOS/Homebrew.
34+
35+
Bolt's MLIR path needs LLVM/MLIR 22 visible through llvm-config. On non-macOS
36+
hosts, install an LLVM 22 toolchain and export:
37+
38+
MLIR_SYS_220_PREFIX=<llvm-prefix>
39+
PATH=<llvm-prefix>/bin:$PATH
40+
41+
EOF
42+
exit 1
43+
fi
44+
45+
if ! command -v brew >/dev/null 2>&1; then
46+
cat >&2 <<'EOF'
47+
Homebrew is required to install the LLVM toolchain for this helper.
48+
Install Homebrew first: https://brew.sh
49+
EOF
50+
exit 1
51+
fi
52+
53+
if ! command -v xcrun >/dev/null 2>&1; then
54+
cat >&2 <<'EOF'
55+
xcrun is missing. Install the Xcode command line tools first:
56+
57+
xcode-select --install
58+
EOF
59+
exit 1
60+
fi
61+
62+
if ! brew list llvm >/dev/null 2>&1; then
63+
brew install llvm
64+
fi
65+
66+
if command -v rustup >/dev/null 2>&1; then
67+
rustup component add rust-src rustfmt clippy
68+
else
69+
cat >&2 <<'EOF'
70+
rustup is not installed. Install Rust from https://rustup.rs, then rerun this
71+
script so it can add rust-src, rustfmt, and clippy.
72+
EOF
73+
exit 1
74+
fi
75+
76+
if ! cargo nextest --version >/dev/null 2>&1; then
77+
cargo install cargo-nextest --locked
78+
fi
79+
80+
cargo install --path "${repo_root}" --locked --force
81+
82+
llvm_prefix="$(brew --prefix llvm)"
83+
sdkroot="$(xcrun --show-sdk-path)"
84+
85+
cat >"${env_file}" <<EOF
86+
# Generated by scripts/setup-bolt-dev.sh. Source this before Bolt MLIR checks.
87+
export MLIR_SYS_220_PREFIX="${llvm_prefix}"
88+
export PATH="${llvm_prefix}/bin:\${PATH}"
89+
export SDKROOT="${sdkroot}"
90+
export BINDGEN_EXTRA_CLANG_ARGS="-isysroot${sdkroot}"
91+
EOF
92+
93+
"${llvm_prefix}/bin/llvm-config" --version >/dev/null
94+
95+
cat <<EOF
96+
Wrote ${env_file}
97+
98+
Run:
99+
source .bolt-dev-env
100+
101+
Then Bolt checks can find llvm-config and MLIR_SYS_220_PREFIX.
102+
EOF

0 commit comments

Comments
 (0)