Skip to content

Commit ea10048

Browse files
cptarturksew1
andauthored
Cairo native (#3665)
<!-- 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` --------- Co-authored-by: ksew1 <[email protected]>
1 parent 126ca50 commit ea10048

File tree

57 files changed

+2704
-199
lines changed

Some content is hidden

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

57 files changed

+2704
-199
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Setup Tools
2+
description: Installs Rust and optionally Scarb, Universal Sierra Compiler and LLVM 19 toolchain
3+
4+
inputs:
5+
install-llvm:
6+
description: 'Whether to install the LLVM 19 toolchain'
7+
required: false
8+
default: 'false'
9+
setup-scarb:
10+
description: 'Whether to setup scarb'
11+
required: false
12+
default: 'true'
13+
setup-usc:
14+
description: 'Whether to setup universal-sierra-compiler'
15+
required: false
16+
default: 'true'
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: dtolnay/rust-toolchain@stable
22+
23+
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
24+
25+
- uses: software-mansion/setup-scarb@v1
26+
if: ${{ inputs.setup-scarb == 'true' }}
27+
28+
- uses: software-mansion/setup-universal-sierra-compiler@v1
29+
if: ${{ inputs.setup-usc == 'true' }}
30+
31+
- name: Add LLVM APT repository
32+
uses: myci-actions/add-deb-repo@11
33+
if: ${{ inputs.install-llvm == 'true' }}
34+
with:
35+
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main
36+
repo-name: llvm-repo
37+
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
38+
39+
- name: Install LLVM
40+
shell: bash
41+
if: ${{ inputs.install-llvm == 'true' }}
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y \
45+
llvm-19 llvm-19-dev llvm-19-runtime \
46+
clang-19 clang-tools-19 \
47+
lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools
48+
49+
- name: Set environment variables
50+
if: ${{ inputs.install-llvm == 'true' }}
51+
shell: bash
52+
run: |
53+
echo "MLIR_SYS_190_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
54+
echo "LLVM_SYS_191_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
55+
echo "TABLEGEN_190_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# TODO(#3790) this is currently unused, integrate into nightly release flow
2+
name: Build Native binaries
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
# Specify the version in MAJOR.MINOR.PATCH format, without a leading 'v'
8+
version:
9+
required: true
10+
type: string
11+
ref:
12+
required: false
13+
type: string
14+
15+
jobs:
16+
build-binaries:
17+
name: Build ${{ matrix.target }}
18+
runs-on: ${{ matrix.os }}
19+
20+
env:
21+
# Cross-compiled targets will override this to `cross`.
22+
CARGO: cargo
23+
24+
strategy:
25+
matrix:
26+
# Currently we have only managed to build successfuly on x86 gnu Linux
27+
# - On MacOS, LLVM is installed with brew and the built binary requires having LLVM installed through it,
28+
# even though it is supossed to be bundled.
29+
# - MUSL Linux was not investigated
30+
# - Aarch64 Linux requires LLVM to be build for Aarch64, but proc macros run against host OS, which is x86_64
31+
# when building through cross. With current setup, we install LLVM for only one of these arches.
32+
# We need to investigate cross compiling LLVM for multiple architectures.
33+
include:
34+
- target: x86_64-unknown-linux-gnu
35+
os: ubuntu-latest
36+
system: linux
37+
38+
# - target: x86_64-unknown-linux-musl
39+
# os: ubuntu-latest
40+
# system: linux
41+
#
42+
# - target: aarch64-unknown-linux-gnu
43+
# os: ubuntu-latest
44+
# system: linux
45+
#
46+
# - target: aarch64-unknown-linux-musl
47+
# os: ubuntu-latest
48+
# system: linux
49+
#
50+
# - target: x86_64-apple-darwin
51+
# os: macos-14-large
52+
# system: macos
53+
#
54+
# - target: aarch64-apple-darwin
55+
# os: macos-latest
56+
# system: macos
57+
58+
steps:
59+
- name: Checkout with ref
60+
if: inputs.ref != ''
61+
uses: actions/checkout@v5
62+
with:
63+
ref: ${{ inputs.ref }}
64+
65+
- name: Checkout default
66+
if: inputs.ref == ''
67+
uses: actions/checkout@v5
68+
69+
- name: Setup rust
70+
run: |
71+
rustup target add ${{ matrix.target }}
72+
73+
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
74+
75+
- name: Setup LLVM on MacOS
76+
if: matrix.system == 'macos'
77+
run: |
78+
brew install llvm@19
79+
brew reinstall zstd
80+
echo "MLIR_SYS_190_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
81+
echo "LLVM_SYS_191_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
82+
echo "TABLEGEN_190_PREFIX=$(brew --prefix llvm@19)" >> $GITHUB_ENV
83+
echo "LIBRARY_PATH=/opt/homebrew/lib" >> $GITHUB_ENV
84+
85+
- name: Install cross
86+
if: matrix.system == 'linux'
87+
run: |
88+
cargo install cross --git https://github.com/cross-rs/cross
89+
90+
- name: Build MacOS
91+
if: matrix.system == 'macos'
92+
run: |
93+
export MLIR_SYS_190_PREFIX=${{ env.MLIR_SYS_190_PREFIX }}
94+
export LLVM_SYS_191_PREFIX=${{ env.LLVM_SYS_191_PREFIX }}
95+
export TABLEGEN_190_PREFIX=${{ env.TABLEGEN_190_PREFIX }}
96+
export LIBRARY_PATH=${{ env.LIBRARY_PATH }}
97+
cargo build --release --locked --target ${{ matrix.target }}
98+
99+
- name: Build Linux
100+
if: matrix.system == 'linux'
101+
run: |
102+
# Use cross to link oldest GLIBC possible.
103+
cross build --release --locked --target ${{ matrix.target }}
104+
105+
- name: Package
106+
shell: bash
107+
run: |
108+
set -euxo pipefail
109+
PKG_FULL_NAME="starknet-foundry-v${{ inputs.version }}-${{ matrix.target }}"
110+
echo "PKG_FULL_NAME=$PKG_FULL_NAME" >> $GITHUB_ENV
111+
112+
./scripts/package.sh "${{ matrix.target }}" "$PKG_FULL_NAME"
113+
114+
- name: Upload artifact
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: build-${{ matrix.target }}
118+
path: ${{ env.PKG_FULL_NAME }}.*

.github/workflows/_test-binaries.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ jobs:
2424
- target: x86_64-unknown-linux-gnu
2525
os: ubuntu-latest
2626

27-
- target: x86_64-apple-darwin
27+
- target: aarch64-apple-darwin
2828
os: macos-latest
2929

30+
- target: x86_64-apple-darwin
31+
# Target macos-latest uses Mac with ARM, macos-14-large is still on Intel
32+
os: macos-14-large
33+
3034
steps:
3135
- uses: actions/checkout@v5
3236
- uses: software-mansion/setup-scarb@v1

0 commit comments

Comments
 (0)