Skip to content

Commit eb4a768

Browse files
authored
Bundle LLVM (#3698)
<!-- Reference any GitHub issues resolved by this PR --> Closes # ## Introduced changes <!-- A brief description of the changes --> - ## Checklist <!-- Make sure all of these are complete --> - [ ] Linked relevant issue - [ ] Updated relevant documentation - [ ] Added relevant tests - [ ] Performed self-review of the code - [ ] Added changes to `CHANGELOG.md`
1 parent 6e99355 commit eb4a768

File tree

3 files changed

+82
-26
lines changed

3 files changed

+82
-26
lines changed

.github/workflows/_build-binaries.yml

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,27 @@ jobs:
2525
include:
2626
- target: x86_64-unknown-linux-gnu
2727
os: ubuntu-latest
28-
# Use cross to link oldest GLIBC possible.
29-
cross: true
30-
31-
- target: x86_64-unknown-linux-musl
32-
os: ubuntu-latest
33-
cross: true
34-
35-
- target: aarch64-unknown-linux-gnu
36-
os: ubuntu-latest
37-
cross: true
38-
39-
- target: aarch64-unknown-linux-musl
40-
os: ubuntu-latest
41-
cross: true
28+
system: linux
29+
#
30+
# - target: x86_64-unknown-linux-musl
31+
# os: ubuntu-latest
32+
# system: linux
33+
#
34+
# - target: aarch64-unknown-linux-gnu
35+
# os: ubuntu-latest
36+
# system: linux
37+
#
38+
# - target: aarch64-unknown-linux-musl
39+
# os: ubuntu-latest
40+
# system: linux
4241

4342
- target: x86_64-apple-darwin
44-
os: macos-latest
43+
os: macos-14-large
44+
system: macos
4545

4646
- target: aarch64-apple-darwin
4747
os: macos-latest
48+
system: macos
4849

4950
steps:
5051
- name: Checkout with ref
@@ -62,21 +63,36 @@ jobs:
6263
rustup target add ${{ matrix.target }}
6364
6465
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
65-
with:
66-
workspaces: starknet-foundry
6766

68-
- name: Install cross
69-
if: matrix.cross
70-
uses: taiki-e/install-action@cross
67+
- name: Setup LLVM on MacOS
68+
if: matrix.system == 'macos'
69+
run: |
70+
brew install llvm@19
71+
brew reinstall zstd
72+
echo "MLIR_SYS_190_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
73+
echo "LLVM_SYS_191_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
74+
echo "TABLEGEN_190_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
75+
echo "LIBRARY_PATH=/opt/homebrew/lib" >> $GITHUB_ENV
7176
72-
- name: Enable cross-compilation
73-
if: matrix.cross
74-
shell: bash
77+
- name: Install cross
78+
if: matrix.system == 'linux'
7579
run: |
76-
echo "CARGO=cross" >> $GITHUB_ENV
80+
cargo install cross --git https://github.com/cross-rs/cross
7781
78-
- name: Build
79-
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
82+
- name: Build MacOS
83+
if: matrix.system == 'macos'
84+
run: |
85+
export MLIR_SYS_190_PREFIX=${{ env.MLIR_SYS_190_PREFIX }}
86+
export LLVM_SYS_191_PREFIX=${{ env.LLVM_SYS_191_PREFIX }}
87+
export TABLEGEN_190_PREFIX=${{ env.TABLEGEN_190_PREFIX }}
88+
export LIBRARY_PATH=${{ env.LIBRARY_PATH }}
89+
cargo build --release --locked --target ${{ matrix.target }}
90+
91+
- name: Build Linux
92+
if: matrix.system == 'linux'
93+
run: |
94+
# Use cross to link oldest GLIBC possible.
95+
cross build --release --locked --target ${{ matrix.target }}
8096
8197
- name: Package
8298
shell: bash

Cross.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[build]
2+
pre-build = [
3+
"dpkg --add-architecture $CROSS_DEB_ARCH",
4+
"apt-get update",
5+
"apt-get install -y --no-install-recommends ca-certificates gnupg wget software-properties-common lsb-release",
6+
"apt-get install -y --no-install-recommends zlib1g-dev libzstd-dev zlib1g-dev:$CROSS_DEB_ARCH libzstd-dev:$CROSS_DEB_ARCH",
7+
"echo \"deb http://apt.llvm.org/focal/ llvm-toolchain-focal-19 main\" > /etc/apt/sources.list.d/llvm-toolchain-focal.list",
8+
"echo \"deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-19 main\" >> /etc/apt/sources.list.d/llvm-toolchain-focal.list",
9+
"wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -",
10+
"apt-get update",
11+
"apt-get install -y --no-install-recommends llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools",
12+
]
13+
14+
[target.x86_64-unknown-linux-gnu.env]
15+
passthrough = [
16+
"MLIR_SYS_190_PREFIX=/usr/lib/llvm-19",
17+
"LLVM_SYS_191_PREFIX=/usr/lib/llvm-19",
18+
"TABLEGEN_190_PREFIX=/usr/lib/llvm-19",
19+
]

NATIVE_INSTALLATION.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Installing Starknet Foundry With Cairo Native Support
2+
3+
Cairo Native introduces additional dependencies outside of the Rust ecosystem.
4+
5+
## LLVM
6+
7+
LLVM is linked into Starknet Foundry binary, so it doesn't have to be installed separately at the cost an incrased
8+
binary size.
9+
10+
## `ld`
11+
12+
Cairo Native crate makes direct calls to `ld`, which must in turn be installed on the system.
13+
14+
### Linux
15+
16+
The package `binutils` contains `ld`, install it with package manager relevant to your distribution or build it
17+
from source.
18+
19+
### MacOS
20+
21+
`ld` is part of the Xcode command line tools. Install it with `xcode-select --install`.

0 commit comments

Comments
 (0)