Skip to content

Commit b78073f

Browse files
chore: use llvm as submodule (#306)
1 parent c3041ce commit b78073f

11 files changed

Lines changed: 116 additions & 11 deletions

File tree

.github/workflows/ccache-regen.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ jobs:
6161
steps:
6262
- name: Checkout source
6363
uses: actions/checkout@v4
64+
with:
65+
submodules: 'recursive'
66+
67+
# This step is required to checkout submodules
68+
# that are disabled in .gitmodules config
69+
- name: Checkout submodules
70+
run: |
71+
git config --global --add safe.directory '*'
72+
git submodule update --force --depth=1 --recursive --checkout
73+
74+
- name: Checkout host LLVM for musl build
75+
uses: actions/checkout@v4
76+
if: contains(matrix.target, 'musl')
77+
with:
78+
repository: 'llvm/llvm-project'
79+
path: 'llvm-host'
80+
ref: 'llvmorg-17.0.6'
81+
fetch-depth: '1'
6482

6583
- name: Prepare Windows env
6684
if: runner.os == 'Windows'
@@ -69,6 +87,7 @@ jobs:
6987
- name: Build LLVM for tests
7088
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
7189
with:
90+
clone-llvm: 'false'
7291
target-env: ${{ contains(matrix.target, 'musl') && 'musl' || 'gnu' }}
7392
enable-assertions: 'true'
7493
build-type: RelWithDebInfo

.github/workflows/check-tooling.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@ jobs:
3333
- name: Checkout source
3434
uses: actions/checkout@v4
3535
with:
36+
submodules: 'recursive'
3637
ref: ${{ inputs.zksolc-version || '' }}
3738

39+
# This step is required to checkout submodules
40+
# that are disabled in .gitmodules config
41+
- name: Checkout submodules
42+
run: |
43+
git config --global --add safe.directory '*'
44+
git submodule update --force --depth=1 --recursive --checkout
45+
3846
- name: Build LLVM
3947
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
4048
with:
49+
clone-llvm: 'false'
4150
target-env: 'gnu'
4251
enable-assertions: 'false'
4352
build-type: Release

.github/workflows/dependencies.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ jobs:
3030
with:
3131
ref: ${{ inputs.ref }}
3232
repository: matter-labs/era-compiler-solidity
33+
submodules: 'recursive'
34+
35+
# This step is required to checkout submodules
36+
# that are disabled in .gitmodules config
37+
- name: Checkout submodules
38+
run: |
39+
git config --global --add safe.directory '*'
40+
git submodule update --force --depth=1 --recursive --checkout
3341
3442
- name: Patch dependencies
3543
shell: bash -ex {0}
@@ -54,6 +62,7 @@ jobs:
5462
- name: Build LLVM
5563
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
5664
with:
65+
clone-llvm: 'false'
5766
enable-assertions: 'true'
5867
build-type: RelWithDebInfo
5968
ccache-key: ${{ format('llvm-{0}-{1}-gnu', runner.os, runner.arch) }}

.github/workflows/release.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ jobs:
6262
- name: Checkout source
6363
uses: actions/checkout@v4
6464
with:
65+
submodules: 'recursive'
6566
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || '' }}
6667

6768
- name: Check LLVM version
6869
if: github.ref_type == 'tag'
6970
shell: 'bash -ex {0}'
7071
run: |
71-
LLVM_BRANCH=$(grep "^branch" LLVM.lock | awk -F ' = ' '{print $2}' | tr -d '"')
72+
# Extracts submodule branch from the submodule status output. Works in case of shallow clone.
73+
LLVM_BRANCH=$(git submodule status llvm | awk -F '[()/]' '{print $3}')
7274
[[ "${LLVM_BRANCH}" =~ ^v[0-9]+(\.[0-9]+)+(\.[0-9]+).*$ ]] || \
7375
{ echo "LLVM branch is not semver: '${LLVM_BRANCH}'. Please, update LLVM.lock file."; exit 1; }
7476
@@ -109,15 +111,33 @@ jobs:
109111
- name: Checkout source
110112
uses: actions/checkout@v4
111113
with:
114+
submodules: 'recursive'
112115
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || '' }}
113116

117+
# This step is required to checkout submodules
118+
# that are disabled in .gitmodules config
119+
- name: Checkout submodules
120+
run: |
121+
git config --global --add safe.directory '*'
122+
git submodule update --force --depth=1 --recursive --checkout
123+
124+
- name: Checkout host LLVM for musl build
125+
uses: actions/checkout@v4
126+
if: contains(matrix.target, 'musl')
127+
with:
128+
repository: 'llvm/llvm-project'
129+
path: 'llvm-host'
130+
ref: 'llvmorg-17.0.6'
131+
fetch-depth: '1'
132+
114133
- name: Prepare Windows env
115134
if: runner.os == 'Windows'
116135
uses: matter-labs/era-compiler-ci/.github/actions/prepare-msys@v1
117136

118137
- name: Build LLVM
119138
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
120139
with:
140+
clone-llvm: 'false'
121141
target-env: ${{ contains(matrix.target, 'musl') && 'musl' || 'gnu' }}
122142
enable-assertions: 'false'
123143
build-type: Release

.github/workflows/sanitizers.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,20 @@ jobs:
3232

3333
- name: Checkout
3434
uses: actions/checkout@v4
35+
with:
36+
submodules: 'recursive'
37+
38+
# This step is required to checkout submodules
39+
# that are disabled in .gitmodules config
40+
- name: Checkout submodules
41+
run: |
42+
git config --global --add safe.directory '*'
43+
git submodule update --force --depth=1 --recursive --checkout
3544
3645
- name: Build LLVM
3746
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
3847
with:
48+
clone-llvm: 'false'
3949
target-env: 'gnu'
4050
enable-assertions: 'true'
4151
build-type: RelWithDebInfo

.github/workflows/test.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,20 @@ jobs:
2323
steps:
2424
- name: Checkout source
2525
uses: actions/checkout@v4
26+
with:
27+
submodules: 'recursive'
28+
29+
# This step is required to checkout submodules
30+
# that are disabled in .gitmodules config
31+
- name: Checkout submodules
32+
run: |
33+
git config --global --add safe.directory '*'
34+
git submodule update --force --depth=1 --recursive --checkout
2635
2736
- name: Build LLVM
2837
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
2938
with:
30-
target-env: 'gnu'
39+
clone-llvm: 'false'
3140
build-type: 'Release'
3241
enable-assertions: 'false'
3342
ccache-key: ${{ format('llvm-{0}-{1}-gnu', runner.os, runner.arch) }}
@@ -75,6 +84,24 @@ jobs:
7584
steps:
7685
- name: Checkout source
7786
uses: actions/checkout@v4
87+
with:
88+
submodules: 'recursive'
89+
90+
# This step is required to checkout submodules
91+
# that are disabled in .gitmodules config
92+
- name: Checkout submodules
93+
run: |
94+
git config --global --add safe.directory '*'
95+
git submodule update --force --depth=1 --recursive --checkout
96+
97+
- name: Checkout host LLVM for musl build
98+
uses: actions/checkout@v4
99+
if: contains(matrix.target, 'musl')
100+
with:
101+
repository: 'llvm/llvm-project'
102+
path: 'llvm-host'
103+
ref: 'llvmorg-17.0.6'
104+
fetch-depth: '1'
78105

79106
- name: Prepare Windows env
80107
if: runner.os == 'Windows'
@@ -83,6 +110,7 @@ jobs:
83110
- name: Build LLVM
84111
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
85112
with:
113+
clone-llvm: 'false'
86114
target-env: ${{ contains(matrix.target, 'musl') && 'musl' || 'gnu' }}
87115
enable-assertions: 'true'
88116
build-type: RelWithDebInfo

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
# These are backup files generated by rustfmt
66
**/*.rs.bk
77

8-
# The LLVM framework source and build
9-
/llvm/
8+
# The LLVM framework build
109
/target-llvm*/
1110

1211
# IDE project data

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[submodule "llvm"]
2+
path = llvm
3+
url = https://github.com/matter-labs/era-compiler-llvm
4+
branch = v1.5.9
5+
update = none

LLVM.lock

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/src/01-installation.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ If any of your projects are still using the old locations, please change their d
165165
3. Clone and checkout this repository.
166166

167167
```shell
168-
git clone https://github.com/matter-labs/era-compiler-solidity
168+
git clone https://github.com/matter-labs/era-compiler-solidity --recursive
169+
```
170+
171+
By default, submodules checkout is disabled to prevent cloning large repositories via `cargo`.
172+
If you're building locally, ensure all submodules are checked out with:
173+
```shell
174+
git submodule update --recursive --checkout
169175
```
170176
171177
4. Install the ZKsync LLVM framework builder. This tool clones the [repository of ZKsync LLVM Framework](https://github.com/matter-labs/era-compiler-llvm) and runs a sequence of build commands tuned for the needs of ZKsync compiler toolchain.
@@ -186,8 +192,6 @@ If any of your projects are still using the old locations, please change their d
186192
```shell
187193
# Navigate to the root of your local copy of this repository.
188194
cd era-compiler-solidity
189-
# Clone the ZKsync LLVM framework. The branch is specified in the file `LLVM.lock`.
190-
zksync-llvm clone
191195
# Build the ZKsync LLVM framework.
192196
zksync-llvm build
193197
```
@@ -197,8 +201,11 @@ If any of your projects are still using the old locations, please change their d
197201
You can also clone and build LLVM framework outside of the repository root.
198202
In this case, do the following:
199203
200-
1. Provide an `LLVM.lock` file in the directory where you run `zksync-llvm`.
201-
See the [default LLVM.lock for an example](../LLVM.lock).
204+
1. Provide an `LLVM.lock` file in the directory where you run `zksync-llvm`:
205+
```text
206+
url = "https://github.com/matter-labs/era-compiler-llvm"
207+
branch = "main"
208+
```
202209
2. Ensure that `LLVM.lock` selects the correct branch of the [ZKsync LLVM Framework repository](https://github.com/matter-labs/era-compiler-llvm).
203210
3. Before proceeding to the next step, set the environment variable `LLVM_SYS_170_PREFIX` to the path of the directory with the LLVM build artifacts.
204211
Typically, it ends with `target-llvm/build-final`, which is the default LLVM target directory of the LLVM builder. For example:

0 commit comments

Comments
 (0)