Skip to content

Commit d38631d

Browse files
authored
Merge pull request #66 from upstat-io/dev
build: make LLVM hard requirement, simplify build tooling
2 parents 1f2c2e7 + 83e806c commit d38631d

197 files changed

Lines changed: 11112 additions & 9893 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,19 @@
55
LLVM_SYS_170_PREFIX = "/usr/lib/llvm-17"
66

77
[alias]
8-
# Run Ori language tests (all tests in tests/ directory)
8+
# Ori language tests
99
st = "run -p oric --bin ori -- test tests/"
10-
11-
# Run Ori tests with verbose output
1210
stv = "run -p oric --bin ori -- test --verbose"
13-
14-
# Run Ori tests with filter (usage: cargo stf map)
1511
stf = "run -p oric --bin ori -- test --filter"
1612

17-
# Run all Rust unit tests across the workspace (excludes ori_llvm — needs LLVM 17)
18-
t = "test --workspace --exclude ori_llvm"
19-
20-
# Run Rust tests with output shown
21-
tv = "test --workspace --exclude ori_llvm -- --nocapture"
22-
23-
# Run tests for a specific crate (usage: cargo tc ori_parse)
13+
# Rust unit tests (all crates including ori_llvm)
14+
t = "test --workspace"
15+
tv = "test --workspace -- --nocapture"
2416
tc = "test -p"
2517

26-
# Check all crates (excludes ori_llvm — needs LLVM 17)
27-
c = "check --workspace --exclude ori_llvm"
28-
29-
# Build all crates (excludes ori_llvm — needs LLVM 17)
30-
b = "build --workspace --exclude ori_llvm"
31-
32-
# Clippy on all crates (excludes ori_llvm — needs LLVM 17; use `cargo cll` for LLVM)
33-
cl = "clippy --workspace --exclude ori_llvm --all-targets -- -D warnings"
34-
35-
# LLVM crates (ori_llvm, ori_rt) are excluded from workspace.
36-
# LLVM 17 path is configured via LLVM_SYS_170_PREFIX above.
37-
# `cargo b` (workspace build) does NOT include LLVM — use `bl`/`blr` for LLVM builds.
38-
# `bl`/`blr` build oric with --features llvm plus ori_rt (needed for AOT linking).
39-
40-
# Build oric + runtime with LLVM feature (local LLVM required)
41-
bl = "build -p oric -p ori_rt --features llvm"
42-
blr = "build -p oric -p ori_rt --features llvm --release"
43-
44-
# Run oric with LLVM feature
45-
rl = "run -p oric --features llvm --bin ori --"
18+
# Build / check / lint (all crates including ori_llvm)
19+
c = "check --workspace"
20+
b = "build --workspace"
21+
cl = "clippy --workspace --all-targets -- -D warnings"
4622

47-
# Clippy on LLVM crate
48-
cll = "clippy -p ori_llvm --all-targets -- -D warnings"
23+
# LLVM 17 is a default feature of oric. All commands include LLVM.

.github/workflows/ci.yml

Lines changed: 58 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,28 @@ jobs:
4343
name: Clippy
4444
if: "!startsWith(github.event.head_commit.message, 'chore: release v')"
4545
runs-on: ubuntu-latest
46-
timeout-minutes: 15
46+
timeout-minutes: 20
4747
steps:
4848
- uses: actions/checkout@v4
49+
50+
- name: Install LLVM 17
51+
run: |
52+
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
53+
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-17 main" | sudo tee /etc/apt/sources.list.d/llvm.list
54+
sudo apt-get update
55+
sudo apt-get install -y --no-install-recommends llvm-17 llvm-17-dev libpolly-17-dev clang-17 lld-17
56+
env:
57+
DEBIAN_FRONTEND: noninteractive
58+
4959
- uses: dtolnay/rust-toolchain@stable
5060
with:
5161
components: clippy
5262
- uses: Swatinem/rust-cache@v2
5363
with:
5464
key: clippy
55-
- run: cargo clippy --workspace --exclude ori_llvm --all-targets -- -D warnings
65+
- run: cargo clippy --workspace --all-targets -- -D warnings
66+
env:
67+
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
5668

5769
# Main test suite
5870
test:
@@ -62,25 +74,39 @@ jobs:
6274
timeout-minutes: 30
6375
steps:
6476
- uses: actions/checkout@v4
77+
78+
- name: Install LLVM 17
79+
run: |
80+
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
81+
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-17 main" | sudo tee /etc/apt/sources.list.d/llvm.list
82+
sudo apt-get update
83+
sudo apt-get install -y --no-install-recommends llvm-17 llvm-17-dev libpolly-17-dev clang-17 lld-17
84+
env:
85+
DEBIAN_FRONTEND: noninteractive
86+
6587
- uses: dtolnay/rust-toolchain@stable
6688
- uses: Swatinem/rust-cache@v2
6789
with:
6890
key: test
6991

7092
- name: Build
71-
run: cargo build --workspace --exclude ori_llvm
93+
run: cargo build --workspace
94+
env:
95+
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
7296

7397
- name: Rust unit tests
7498
id: rust-tests
7599
continue-on-error: true
76100
run: |
77101
set -o pipefail
78-
cargo test --workspace --exclude ori_llvm 2>&1 | tee rust-test-output.txt
102+
cargo test --workspace 2>&1 | tee rust-test-output.txt
79103
# Sum all "X passed" counts from "test result:" lines
80104
RUST_TESTS=$(grep -oE '[0-9]+ passed' rust-test-output.txt | grep -oE '^[0-9]+' | awk '{sum+=$1} END {print sum+0}')
81105
RUST_FAILED=$(grep -oE '[0-9]+ failed' rust-test-output.txt | grep -oE '^[0-9]+' | awk '{sum+=$1} END {print sum+0}')
82106
echo "RUST_TESTS=$RUST_TESTS" >> $GITHUB_ENV
83107
echo "RUST_FAILED=$RUST_FAILED" >> $GITHUB_ENV
108+
env:
109+
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
84110

85111
- name: Ori language tests
86112
id: ori-tests
@@ -93,6 +119,8 @@ jobs:
93119
ORI_FAILED=$(grep -oE '[0-9]+ failed' ori-test-output.txt | grep -oE '^[0-9]+' | tail -1 || echo "0")
94120
echo "ORI_TESTS=$ORI_TESTS" >> $GITHUB_ENV
95121
echo "ORI_FAILED=$ORI_FAILED" >> $GITHUB_ENV
122+
env:
123+
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
96124

97125
- name: Ori runtime tests
98126
id: rt-tests
@@ -163,104 +191,48 @@ jobs:
163191
name: ${{ matrix.os }}
164192
needs: [format, clippy] # Don't waste CI time if basics fail
165193
runs-on: ${{ matrix.os }}
166-
timeout-minutes: 20
194+
timeout-minutes: 7
167195
strategy:
168196
fail-fast: false
169197
matrix:
170198
os: [macos-latest, windows-latest]
171199
steps:
172200
- uses: actions/checkout@v4
173-
- uses: dtolnay/rust-toolchain@stable
174-
- uses: Swatinem/rust-cache@v2
175-
with:
176-
key: ${{ matrix.os }}
177-
178-
- name: Build
179-
run: cargo build --workspace --exclude ori_llvm
180-
181-
- name: Rust unit tests
182-
run: cargo test --workspace --exclude ori_llvm
183201

184-
- name: Ori language tests
185-
run: cargo run -p oric --bin ori -- test tests/
186-
187-
# LLVM backend - not in ci-success `needs`, so failures show red but don't block merges
188-
llvm:
189-
name: LLVM Backend
190-
if: "!startsWith(github.event.head_commit.message, 'chore: release v')"
191-
runs-on: ubuntu-latest
192-
timeout-minutes: 30
193-
steps:
194-
- uses: actions/checkout@v4
202+
- name: Install LLVM 17 (macOS)
203+
if: runner.os == 'macOS'
204+
run: |
205+
brew install llvm@17
206+
echo "LLVM_SYS_170_PREFIX=$(brew --prefix llvm@17)" >> $GITHUB_ENV
195207
196-
- name: Install LLVM 17
208+
- name: Install LLVM 17 (Windows)
209+
if: runner.os == 'Windows'
197210
run: |
198-
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
199-
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-17 main" | sudo tee /etc/apt/sources.list.d/llvm.list
200-
sudo apt-get update
201-
sudo apt-get install -y --no-install-recommends llvm-17 llvm-17-dev libpolly-17-dev clang-17 lld-17
202-
env:
203-
DEBIAN_FRONTEND: noninteractive
211+
$LLVM_URL = "https://github.com/upstat-io/llvm-package-windows/releases/download/v17.0.6/LLVM-17.0.6-win64.7z"
212+
Write-Host "Downloading LLVM from $LLVM_URL"
213+
curl.exe -fLO $LLVM_URL
214+
Write-Host "Extracting LLVM to C:\LLVM..."
215+
7z x LLVM-17.0.6-win64.7z -oC:\LLVM
216+
echo "LLVM_SYS_170_PREFIX=C:\LLVM" >> $env:GITHUB_ENV
217+
echo "C:\LLVM\bin" >> $env:GITHUB_PATH
218+
219+
- name: Set up MSVC environment (Windows)
220+
if: runner.os == 'Windows'
221+
uses: ilammy/msvc-dev-cmd@v1
204222

205223
- uses: dtolnay/rust-toolchain@stable
206-
with:
207-
components: clippy
208-
209224
- uses: Swatinem/rust-cache@v2
210225
with:
211-
key: llvm
212-
213-
- name: LLVM clippy
214-
run: cargo clippy -p ori_llvm --all-targets -- -D warnings
215-
env:
216-
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
217-
218-
- name: LLVM tests
219-
id: llvm-tests
220-
continue-on-error: true
221-
run: |
222-
set -o pipefail
223-
cargo build -p oric -p ori_rt --features llvm -q
224-
cargo test -p ori_rt 2>&1 | tee rt-llvm-output.txt
225-
cargo test -p ori_llvm 2>&1 | tee llvm-test-output.txt
226-
# Sum all "X passed" counts from test output
227-
LLVM_TESTS=$(cat rt-llvm-output.txt llvm-test-output.txt | grep -oE '[0-9]+ passed' | grep -oE '^[0-9]+' | awk '{sum+=$1} END {print sum+0}')
228-
LLVM_FAILED=$(cat rt-llvm-output.txt llvm-test-output.txt | grep -oE '[0-9]+ failed' | grep -oE '^[0-9]+' | awk '{sum+=$1} END {print sum+0}')
229-
echo "LLVM_TESTS=$LLVM_TESTS" >> $GITHUB_ENV
230-
echo "LLVM_FAILED=$LLVM_FAILED" >> $GITHUB_ENV
231-
env:
232-
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17
226+
key: ${{ matrix.os }}
233227

234-
- name: Save LLVM test results
235-
if: always()
236-
run: |
237-
LLVM_P=${LLVM_TESTS:-0}
238-
LLVM_F=${LLVM_FAILED:-0}
239-
OVERALL="passed"
240-
if [ "$LLVM_F" -gt 0 ]; then OVERALL="failed"; fi
241-
cat > llvm-test-results.json << EOF
242-
{
243-
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
244-
"overall": "$OVERALL",
245-
"suites": [
246-
{ "name": "Rust unit tests (ori_llvm)", "passed": $LLVM_P, "failed": $LLVM_F, "skipped": 0, "lcfail": null }
247-
],
248-
"totals": { "passed": $LLVM_P, "failed": $LLVM_F, "skipped": 0, "lcfail": 0 }
249-
}
250-
EOF
251-
cat llvm-test-results.json
228+
- name: Build (all crates incl. LLVM)
229+
run: cargo build --workspace
252230

253-
- name: Upload LLVM test results
254-
if: always()
255-
uses: actions/upload-artifact@v4
256-
with:
257-
name: llvm-test-results
258-
path: llvm-test-results.json
259-
retention-days: 90
231+
- name: Rust unit tests (excl. LLVM AOT — tested on Linux)
232+
run: cargo test --workspace --exclude ori_llvm
260233

261-
- name: Fail if LLVM tests failed
262-
if: steps.llvm-tests.outcome == 'failure'
263-
run: exit 1
234+
- name: Ori language tests
235+
run: cargo run -p oric --bin ori -- test tests/
264236

265237
# Single status check for branch protection
266238
ci-success:

.github/workflows/deploy-website.yml

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,45 +48,12 @@ jobs:
4848
if_no_artifact_found: warn
4949
continue-on-error: true
5050

51-
- name: Fetch LLVM test results from CI
52-
uses: dawidd6/action-download-artifact@v6
53-
with:
54-
workflow: ci.yml
55-
branch: master
56-
name: llvm-test-results
57-
path: website/public
58-
run_id: ${{ github.event.workflow_run.id }}
59-
if_no_artifact_found: warn
60-
continue-on-error: true
61-
62-
- name: Merge test results
51+
- name: Validate test results
6352
run: |
6453
cd website/public
65-
# Create default if missing
6654
if [ ! -f test-results.json ]; then
6755
echo '{"timestamp":"","overall":"unknown","suites":[],"totals":{"passed":0,"failed":0,"skipped":0,"lcfail":0}}' > test-results.json
6856
fi
69-
# Merge LLVM suites into main results if artifact was downloaded
70-
if [ -f llvm-test-results.json ]; then
71-
# Concatenate suites arrays and recompute totals + overall
72-
jq -s '
73-
{
74-
timestamp: (if .[1].timestamp > .[0].timestamp then .[1].timestamp else .[0].timestamp end),
75-
overall: (if ([.[].suites[].failed // 0] | add) > 0 then "failed" else "passed" end),
76-
suites: ([.[].suites] | add),
77-
totals: {
78-
passed: ([.[].suites[] | .passed // 0] | add),
79-
failed: ([.[].suites[] | .failed // 0] | add),
80-
skipped: ([.[].suites[] | .skipped // 0] | add),
81-
lcfail: ([.[].suites[] | .lcfail // 0] | add)
82-
}
83-
}
84-
' test-results.json llvm-test-results.json > combined-test-results.json
85-
mv combined-test-results.json test-results.json
86-
rm -f llvm-test-results.json
87-
else
88-
echo "LLVM test results artifact not found, preserving existing data"
89-
fi
9057
echo "Test results:"
9158
cat test-results.json
9259

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
- name: Build with LLVM
9292
run: |
9393
docker run --rm -v ${{ github.workspace }}:/workspace ori-llvm:latest \
94-
sh -c "cargo build --release --features llvm -p oric && strip /workspace/target/release/ori"
94+
sh -c "cargo build --release -p oric && strip /workspace/target/release/ori"
9595
9696
- name: Package
9797
run: |
@@ -157,7 +157,7 @@ jobs:
157157
targets: ${{ matrix.target }}
158158

159159
- name: Build with LLVM
160-
run: cargo build --release --features llvm -p oric --target ${{ matrix.target }}
160+
run: cargo build --release -p oric --target ${{ matrix.target }}
161161

162162
- name: Package
163163
run: |
@@ -228,7 +228,7 @@ jobs:
228228
targets: x86_64-pc-windows-msvc
229229

230230
- name: Build with LLVM
231-
run: cargo build --release --features llvm -p oric --target x86_64-pc-windows-msvc
231+
run: cargo build --release -p oric --target x86_64-pc-windows-msvc
232232

233233
- name: Package
234234
run: |

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ members = [
1818
"compiler/ori_llvm",
1919
"compiler/ori_rt",
2020
]
21-
# Default members exclude LLVM crates (require LLVM 17 system libraries).
22-
# Bare `cargo check`/`cargo test` skip them; use `-p ori_llvm` or `cargo bl` explicitly.
21+
# All crates including ori_llvm are in default-members; LLVM 17 is required for oric builds.
2322
default-members = [
2423
"compiler/ori_ir",
2524
"compiler/ori_diagnostic",
@@ -35,6 +34,7 @@ default-members = [
3534
"compiler/ori_compiler",
3635
"compiler/ori_stack",
3736
"compiler/oric",
37+
"compiler/ori_llvm",
3838
"compiler/ori_rt",
3939
]
4040
# Excluded crates (not part of workspace at all):

build-all.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
#!/bin/bash
2-
# Build ALL Rust code: workspace and LLVM crate
2+
# Build ALL Rust code: workspace including LLVM crate
33
# Usage: ./build-all
4-
54
set -e
65

76
echo "=== Building workspace ==="
8-
cargo b
9-
10-
echo ""
11-
echo "=== Building LLVM crate ==="
12-
./llvm-build.sh
7+
cargo build --workspace
138

149
echo ""
1510
echo "=== All builds complete ==="

0 commit comments

Comments
 (0)