Skip to content

Commit 2fb8bee

Browse files
authored
Build LLVM for Windows (#248)
This PR changes the CI build scripts to also build LLVM for windows. **It doesn't build `revive` itself for windows**. This will come in a follow up. But once we have a LLVM binary release the turn around time will be much quicker for experimenting with the revive windows build. I manually uploaded the release those changes produce [here](https://github.com/paritytech/revive-alex-workflowtest/releases/tag/llvm-18.1.8-revive.22f3ceb). This enables this PR's CI to find the proper release. This is necessary because I am also making changes to the folder structure and artifact naming that the other CI jobs are depending on. Releases generated from this branch can be inspected here: https://github.com/paritytech/revive-alex-workflowtest/releases/tag/v0.1.0-dev.12 Summary of changes: - Change `llvm-builder` to use MSVC toolchain on windows - Fix `llvm-builder` to work with `.exe` files - Unify the llvm release jobs into a single one. This removed a lot of copy pasted code and also speeds up the build by giving each their own runner. - Use the LLVM target triple to name the binary releases instead of an ad-hoc naming convention - Remove the nested folder hierarchy inside the llvm release. Its just now a single folder `llvm-<target>` that contains the toolchain. - Give jobs and workflows consistent names - Replace all runners bei their `*-latest` counterpart - Only use `parity-large` to build llvm now. All other jobs use github runners
1 parent 93788e7 commit 2fb8bee

File tree

16 files changed

+329
-435
lines changed

16 files changed

+329
-435
lines changed

.github/actions/get-emsdk/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "get emsdk"
1+
name: "Get Emscripten SDK"
22
inputs:
33
version:
44
description: ""
@@ -9,12 +9,11 @@ inputs:
99
runs:
1010
using: "composite"
1111
steps:
12-
1312
- name: install emsdk
1413
shell: bash
1514
run: |
1615
git clone https://github.com/emscripten-core/emsdk.git ./emsdk/
1716
cd emsdk
1817
git checkout tags/${{ inputs.version }}
1918
./emsdk install ${{ inputs.version }}
20-
./emsdk activate ${{ inputs.version }}
19+
./emsdk activate ${{ inputs.version }}

.github/actions/get-llvm/action.yml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
11
# example:
2-
#
3-
# - name: get llvm
4-
# uses: ./.github/actions/get-llvm
2+
# - uses: ./.github/actions/get-llvm
53
# with:
6-
# releasePrefix: llvm-
7-
# artifactArch: macos-arm64
8-
# dir: target-llvm/macos
4+
# target: x86_64-unknown-linux-gnu
95

10-
name: "get llvm"
6+
name: "Download LLVM"
117
inputs:
12-
artifactArch:
8+
target:
139
required: true
14-
releasePrefix:
15-
description: "LLVM release tag prefix to search"
16-
required: false
17-
default: "llvm-"
18-
dir:
19-
description: "Archive extract path (`tar -C`)"
20-
required: false
21-
default: "./"
22-
stripComponents:
23-
description: "Strip UMBER leading components from file names on extraction (`tar --strip-components`)"
24-
required: false
25-
default: 0
26-
2710

2811
runs:
2912
using: "composite"
@@ -32,16 +15,15 @@ runs:
3215
id: find
3316
uses: actions/github-script@v7
3417
env:
35-
releasePrefix: ${{ inputs.releasePrefix }}
36-
artifactArch: ${{ inputs.artifactArch }}
18+
target: ${{ inputs.target }}
3719
with:
3820
result-encoding: string
3921
script: |
4022
let page = 1;
4123
let releases = [];
4224
43-
let releasePrefix = process.env.releasePrefix
44-
let artifactArch = process.env.artifactArch
25+
let releasePrefix = "llvm-"
26+
let target = process.env.target
4527
4628
do {
4729
const res = await github.rest.repos.listReleases({
@@ -61,10 +43,10 @@ runs:
6143
});
6244
if (llvmLatestRelease){
6345
let asset = llvmLatestRelease.assets.find(asset =>{
64-
return asset.name.includes(artifactArch);
46+
return asset.name.includes(target);
6547
});
6648
if (!asset){
67-
core.setFailed(`Artifact for '${artifactArch}' not found in release ${llvmLatestRelease.tag_name} (${llvmLatestRelease.html_url})`);
49+
core.setFailed(`Artifact for '${target}' not found in release ${llvmLatestRelease.tag_name} (${llvmLatestRelease.html_url})`);
6850
process.exit();
6951
}
7052
return asset.browser_download_url;
@@ -79,13 +61,10 @@ runs:
7961
- name: download
8062
shell: bash
8163
run: |
82-
mkdir -p ${{ inputs.dir }}
8364
curl -sSLo llvm.tar.gz ${{ steps.find.outputs.result }}
84-
ls -al
8565
8666
- name: unpack
8767
shell: bash
8868
run: |
89-
tar -xf llvm.tar.gz -C ${{ inputs.dir }} --strip-components=${{ inputs.stripComponents }}
69+
tar -xf llvm.tar.gz
9070
rm llvm.tar.gz
91-
ls -al ${{ inputs.dir }}

.github/actions/get-solc/action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Install Solidity Compiler"
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Put Solc Direcotry into PATH
7+
shell: bash
8+
run: |
9+
mkdir -p solc
10+
echo "$(pwd)/solc/" >> $GITHUB_PATH
11+
12+
- name: Figure out Solc Download URL
13+
shell: bash
14+
run: |
15+
if [[ "${{ runner.os }}" == "Linux" ]]; then
16+
echo "SOLC_NAME=solc-static-linux" >> $GITHUB_ENV
17+
elif [[ "${{ runner.os }}" == "Windows" ]]; then
18+
echo "SOLC_NAME=solc-windows.exe" >> $GITHUB_ENV
19+
else
20+
echo "SOLC_NAME=solc-macos" >> $GITHUB_ENV
21+
fi
22+
23+
- name: Download Solc
24+
shell: bash
25+
run: |
26+
curl -sSL --output solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/${SOLC_NAME}
27+
28+
- name: Make Solc Executable
29+
shell: bash
30+
run: |
31+
chmod +x solc/solc

.github/workflows/release-llvm.yml

Lines changed: 72 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Release LLVM
2-
32
on:
43
workflow_dispatch:
54
inputs:
@@ -9,15 +8,15 @@ on:
98
description: llvm version in "x.x.x" format, e.g. "18.1.8"
109

1110
concurrency:
12-
group: ${{ github.workflow }}-${{ github.ref }}
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1312
cancel-in-progress: true
1413

1514
env:
1615
CARGO_TERM_COLOR: always
1716

1817
jobs:
19-
create-release:
20-
runs-on: ubuntu-latest
18+
create-release-draft:
19+
runs-on: ubuntu-24.04
2120
permissions:
2221
contents: write
2322
outputs:
@@ -27,145 +26,107 @@ jobs:
2726
run: |
2827
echo "version=llvm-${{ inputs.llvm_version }}-revive.${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
2928
30-
- name: create release
29+
- name: Create Release
3130
uses: softprops/action-gh-release@v2
3231
with:
33-
name: "LLVM binaries release: ${{ steps.resolve-version.outputs.version }}"
34-
body: "This release includes binaries of LLVM, used to compile revive itself"
35-
make_latest: "false"
32+
name: ${{ steps.resolve-version.outputs.version }}
33+
body: "LLVM is a dependency of revive. The LLVM releases are used by our CI to build revive."
34+
draft: true
3635
tag_name: ${{ steps.resolve-version.outputs.version }}
3736

38-
build-macos:
37+
build:
3938
strategy:
4039
matrix:
41-
os: [macos-14, macos-13]
40+
target: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, wasm32-unknown-emscripten, aarch64-apple-darwin, x86_64-apple-darwin, x86_64-pc-windows-msvc]
4241
include:
43-
- os: macos-13
44-
arch: x64
45-
- os: macos-14
46-
arch: arm64
47-
needs: create-release
48-
runs-on: ${{ matrix.os }}
49-
name: "build-macos-${{ matrix.arch }}"
42+
- target: x86_64-unknown-linux-gnu
43+
builder-arg: gnu
44+
host: linux
45+
runner: parity-large
46+
- target: x86_64-unknown-linux-musl
47+
builder-arg: musl
48+
host: linux
49+
runner: parity-large
50+
- target: wasm32-unknown-emscripten
51+
builder-arg: emscripten
52+
host: linux
53+
runner: parity-large
54+
- target: aarch64-apple-darwin
55+
builder-arg: gnu
56+
host: macos
57+
runner: macos-14
58+
- target: x86_64-apple-darwin
59+
builder-arg: gnu
60+
host: macos
61+
runner: macos-13
62+
- target: x86_64-pc-windows-msvc
63+
builder-arg: gnu
64+
host: windows
65+
runner: windows-2022
66+
needs: create-release-draft
67+
runs-on: ${{ matrix.runner }}
5068
env:
5169
RUST_LOG: trace
5270
permissions:
5371
contents: write # for uploading assets to release
5472
steps:
5573
- uses: actions/checkout@v4
56-
57-
- name: install macos deps
58-
run: |
59-
brew install ninja
60-
61-
- name: versions
62-
run: |
63-
rustup show
64-
cargo --version
65-
cmake --version
66-
echo "bash:" && bash --version
67-
echo "ninja:" && ninja --version
68-
echo "clang:" && clang --version
69-
70-
- name: Build LLVM
71-
run: |
72-
make install-llvm
73-
74-
- name: clean
75-
# check removed files
76-
run: |
77-
cd target-llvm/gnu/target-final/bin/
78-
rm diagtool llvm-libtool-darwin llvm-lipo llvm-pdbutil llvm-dwarfdump llvm-nm llvm-readobj llvm-cfi-verify \
79-
sancov llvm-debuginfo-analyzer llvm-objdump llvm-profgen llvm-extract llvm-jitlink llvm-c-test llvm-gsymutil llvm-dwp \
80-
dsymutil llvm-dwarfutil llvm-exegesis lli clang-rename bugpoint clang-extdef-mapping clang-refactor c-index-test \
81-
llvm-reduce llvm-lto clang-linker-wrapper llc llvm-lto2
82-
83-
- name: package artifacts
84-
run: |
85-
tar -czf "${{ needs.create-release.outputs.version }}-macos-${{ matrix.arch }}.tar.gz" target-llvm/gnu/target-final
86-
87-
- name: upload archive to release
88-
uses: softprops/action-gh-release@v2
74+
- uses: actions-rust-lang/setup-rust-toolchain@v1
8975
with:
90-
make_latest: "false"
91-
tag_name: ${{ needs.create-release.outputs.version }}
92-
files: |
93-
${{ needs.create-release.outputs.version }}-macos-${{ matrix.arch }}.tar.gz
94-
95-
96-
build-linux-all:
97-
needs: create-release
98-
runs-on: parity-large
99-
env:
100-
RUST_LOG: trace
101-
permissions:
102-
contents: write # for uploading assets to release
103-
steps:
104-
- uses: actions/checkout@v4
76+
# without this it will override our rust flags
77+
rustflags: ""
78+
cache-key: ${{ matrix.target }}
10579

106-
- name: install linux deps
80+
- name: Install Dependencies
81+
if: ${{ matrix.host == 'linux' }}
10782
run: |
10883
sudo apt-get update && sudo apt-get install -y cmake ninja-build curl git libssl-dev pkg-config clang lld musl
10984
110-
- uses: actions-rust-lang/setup-rust-toolchain@v1
111-
with:
112-
toolchain: stable
113-
components: rust-src
114-
target: wasm32-unknown-emscripten
115-
rustflags: ""
116-
117-
- name: versions
85+
- name: Install Dependencies
86+
if: ${{ matrix.host == 'macos' }}
11887
run: |
119-
rustup show
120-
cargo --version
121-
cmake --version
122-
echo "bash:" && bash --version
123-
echo "ninja:" && ninja --version
124-
echo "clang:" && clang --version
88+
brew install ninja
12589
126-
- name: Build host LLVM
90+
- name: Install LLVM Builder
12791
run: |
128-
make install-llvm
92+
cargo install --path crates/llvm-builder
12993
130-
- name: Build gnu LLVM
94+
- name: Clone LLVM
13195
run: |
132-
revive-llvm clone
133-
revive-llvm build --llvm-projects lld --llvm-projects clang
96+
revive-llvm --target-env ${{ matrix.builder-arg }} clone
13497
135-
- name: Build musl LLVM
98+
- name: Build LLVM
99+
if: ${{ matrix.target != 'wasm32-unknown-emscripten' }}
136100
run: |
137-
revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang
101+
revive-llvm --target-env ${{ matrix.builder-arg }} build --llvm-projects lld --llvm-projects clang
138102
139-
- name: Build emscripten LLVM
103+
- name: Build LLVM
104+
if: ${{ matrix.target == 'wasm32-unknown-emscripten' }}
140105
run: |
141-
revive-llvm --target-env emscripten clone
142106
source emsdk/emsdk_env.sh
143-
revive-llvm --target-env emscripten build --llvm-projects lld
107+
revive-llvm --target-env ${{ matrix.builder-arg }} build --llvm-projects lld
144108
145-
- name: clean
146-
# check removed files
109+
- name: Remove Unnecessary Binaries
110+
shell: bash
147111
run: |
148-
for target in gnu emscripten musl; do
149-
cd target-llvm/${target}/target-final/bin/
150-
rm -rf diagtool llvm-libtool-darwin llvm-lipo llvm-pdbutil llvm-dwarfdump llvm-nm llvm-readobj llvm-cfi-verify \
151-
sancov llvm-debuginfo-analyzer llvm-objdump llvm-profgen llvm-extract llvm-jitlink llvm-c-test llvm-gsymutil llvm-dwp \
152-
dsymutil llvm-dwarfutil llvm-exegesis lli clang-rename bugpoint clang-extdef-mapping clang-refactor c-index-test \
153-
llvm-reduce llvm-lto clang-linker-wrapper llc llvm-lto2 llvm-otool llvm-readelf
154-
cd -
155-
done
156-
157-
- name: package artifacts
112+
cd target-llvm/${{ matrix.builder-arg }}/target-final/bin/
113+
rm -f diagtool* llvm-libtool-darwin* llvm-lipo* llvm-pdbutil* llvm-dwarfdump* llvm-nm* llvm-readobj* llvm-cfi-verify* \
114+
sancov* llvm-debuginfo-analyzer* llvm-objdump* llvm-profgen* llvm-extract* llvm-jitlink* llvm-c-test* llvm-gsymutil* llvm-dwp* \
115+
dsymutil* llvm-dwarfutil* llvm-exegesis* lli clang-rename* bugpoint* clang-extdef-mapping* clang-refactor* c-index-test* \
116+
llvm-reduce* llvm-lto* clang-linker-wrapper* llc* llvm-lto2* llvm-otool* llvm-readelf* \
117+
clang-repl* clang-check* clang-scan-deps*
118+
cd -
119+
120+
- name: Package Artifact
121+
shell: bash
158122
run: |
159-
tar -czf "${{ needs.create-release.outputs.version }}-x86_64-linux-gnu-linux.tar.gz" target-llvm/gnu/target-final
160-
tar -czf "${{ needs.create-release.outputs.version }}-x86_64-linux-musl.tar.gz" target-llvm/musl/target-final
161-
tar -czf "${{ needs.create-release.outputs.version }}-wasm32-unknown-emscripten.tar.gz" target-llvm/emscripten/target-final
123+
mv target-llvm/${{ matrix.builder-arg }}/target-final/ llvm-${{ matrix.target }}
124+
tar -czf "${{ needs.create-release-draft.outputs.version }}-${{ matrix.target }}.tar.gz" llvm-${{ matrix.target }}
162125
163-
- name: upload archive to release
126+
- name: Add Artifact to Release
164127
uses: softprops/action-gh-release@v2
165128
with:
166-
make_latest: "false"
167-
tag_name: ${{ needs.create-release.outputs.version }}
129+
tag_name: ${{ needs.create-release-draft.outputs.version }}
130+
draft: true
168131
files: |
169-
${{ needs.create-release.outputs.version }}-x86_64-linux-gnu-linux.tar.gz
170-
${{ needs.create-release.outputs.version }}-x86_64-linux-musl.tar.gz
171-
${{ needs.create-release.outputs.version }}-wasm32-unknown-emscripten.tar.gz
132+
${{ needs.create-release-draft.outputs.version }}-${{ matrix.target }}.tar.gz

0 commit comments

Comments
 (0)