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
This commit is contained in:
Alexander Theißen
2025-02-28 15:06:03 +01:00
committed by GitHub
parent 93788e72e9
commit 2fb8beee62
16 changed files with 340 additions and 446 deletions
+71 -110
View File
@@ -1,5 +1,4 @@
name: Release LLVM
on:
workflow_dispatch:
inputs:
@@ -9,15 +8,15 @@ on:
description: llvm version in "x.x.x" format, e.g. "18.1.8"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
create-release-draft:
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
@@ -27,145 +26,107 @@ jobs:
run: |
echo "version=llvm-${{ inputs.llvm_version }}-revive.${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: create release
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: "LLVM binaries release: ${{ steps.resolve-version.outputs.version }}"
body: "This release includes binaries of LLVM, used to compile revive itself"
make_latest: "false"
name: ${{ steps.resolve-version.outputs.version }}
body: "LLVM is a dependency of revive. The LLVM releases are used by our CI to build revive."
draft: true
tag_name: ${{ steps.resolve-version.outputs.version }}
build-macos:
build:
strategy:
matrix:
os: [macos-14, macos-13]
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]
include:
- os: macos-13
arch: x64
- os: macos-14
arch: arm64
needs: create-release
runs-on: ${{ matrix.os }}
name: "build-macos-${{ matrix.arch }}"
- target: x86_64-unknown-linux-gnu
builder-arg: gnu
host: linux
runner: parity-large
- target: x86_64-unknown-linux-musl
builder-arg: musl
host: linux
runner: parity-large
- target: wasm32-unknown-emscripten
builder-arg: emscripten
host: linux
runner: parity-large
- target: aarch64-apple-darwin
builder-arg: gnu
host: macos
runner: macos-14
- target: x86_64-apple-darwin
builder-arg: gnu
host: macos
runner: macos-13
- target: x86_64-pc-windows-msvc
builder-arg: gnu
host: windows
runner: windows-2022
needs: create-release-draft
runs-on: ${{ matrix.runner }}
env:
RUST_LOG: trace
permissions:
contents: write # for uploading assets to release
steps:
- uses: actions/checkout@v4
- name: install macos deps
run: |
brew install ninja
- name: versions
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: Build LLVM
run: |
make install-llvm
- name: clean
# check removed files
run: |
cd target-llvm/gnu/target-final/bin/
rm diagtool llvm-libtool-darwin llvm-lipo llvm-pdbutil llvm-dwarfdump llvm-nm llvm-readobj llvm-cfi-verify \
sancov llvm-debuginfo-analyzer llvm-objdump llvm-profgen llvm-extract llvm-jitlink llvm-c-test llvm-gsymutil llvm-dwp \
dsymutil llvm-dwarfutil llvm-exegesis lli clang-rename bugpoint clang-extdef-mapping clang-refactor c-index-test \
llvm-reduce llvm-lto clang-linker-wrapper llc llvm-lto2
- name: package artifacts
run: |
tar -czf "${{ needs.create-release.outputs.version }}-macos-${{ matrix.arch }}.tar.gz" target-llvm/gnu/target-final
- name: upload archive to release
uses: softprops/action-gh-release@v2
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
make_latest: "false"
tag_name: ${{ needs.create-release.outputs.version }}
files: |
${{ needs.create-release.outputs.version }}-macos-${{ matrix.arch }}.tar.gz
# without this it will override our rust flags
rustflags: ""
cache-key: ${{ matrix.target }}
build-linux-all:
needs: create-release
runs-on: parity-large
env:
RUST_LOG: trace
permissions:
contents: write # for uploading assets to release
steps:
- uses: actions/checkout@v4
- name: install linux deps
- name: Install Dependencies
if: ${{ matrix.host == 'linux' }}
run: |
sudo apt-get update && sudo apt-get install -y cmake ninja-build curl git libssl-dev pkg-config clang lld musl
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rust-src
target: wasm32-unknown-emscripten
rustflags: ""
- name: versions
- name: Install Dependencies
if: ${{ matrix.host == 'macos' }}
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
echo "ninja:" && ninja --version
echo "clang:" && clang --version
brew install ninja
- name: Build host LLVM
- name: Install LLVM Builder
run: |
make install-llvm
cargo install --path crates/llvm-builder
- name: Build gnu LLVM
- name: Clone LLVM
run: |
revive-llvm clone
revive-llvm build --llvm-projects lld --llvm-projects clang
revive-llvm --target-env ${{ matrix.builder-arg }} clone
- name: Build musl LLVM
- name: Build LLVM
if: ${{ matrix.target != 'wasm32-unknown-emscripten' }}
run: |
revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang
revive-llvm --target-env ${{ matrix.builder-arg }} build --llvm-projects lld --llvm-projects clang
- name: Build emscripten LLVM
- name: Build LLVM
if: ${{ matrix.target == 'wasm32-unknown-emscripten' }}
run: |
revive-llvm --target-env emscripten clone
source emsdk/emsdk_env.sh
revive-llvm --target-env emscripten build --llvm-projects lld
revive-llvm --target-env ${{ matrix.builder-arg }} build --llvm-projects lld
- name: clean
# check removed files
- name: Remove Unnecessary Binaries
shell: bash
run: |
for target in gnu emscripten musl; do
cd target-llvm/${target}/target-final/bin/
rm -rf diagtool llvm-libtool-darwin llvm-lipo llvm-pdbutil llvm-dwarfdump llvm-nm llvm-readobj llvm-cfi-verify \
sancov llvm-debuginfo-analyzer llvm-objdump llvm-profgen llvm-extract llvm-jitlink llvm-c-test llvm-gsymutil llvm-dwp \
dsymutil llvm-dwarfutil llvm-exegesis lli clang-rename bugpoint clang-extdef-mapping clang-refactor c-index-test \
llvm-reduce llvm-lto clang-linker-wrapper llc llvm-lto2 llvm-otool llvm-readelf
cd -
done
cd target-llvm/${{ matrix.builder-arg }}/target-final/bin/
rm -f diagtool* llvm-libtool-darwin* llvm-lipo* llvm-pdbutil* llvm-dwarfdump* llvm-nm* llvm-readobj* llvm-cfi-verify* \
sancov* llvm-debuginfo-analyzer* llvm-objdump* llvm-profgen* llvm-extract* llvm-jitlink* llvm-c-test* llvm-gsymutil* llvm-dwp* \
dsymutil* llvm-dwarfutil* llvm-exegesis* lli clang-rename* bugpoint* clang-extdef-mapping* clang-refactor* c-index-test* \
llvm-reduce* llvm-lto* clang-linker-wrapper* llc* llvm-lto2* llvm-otool* llvm-readelf* \
clang-repl* clang-check* clang-scan-deps*
cd -
- name: package artifacts
- name: Package Artifact
shell: bash
run: |
tar -czf "${{ needs.create-release.outputs.version }}-x86_64-linux-gnu-linux.tar.gz" target-llvm/gnu/target-final
tar -czf "${{ needs.create-release.outputs.version }}-x86_64-linux-musl.tar.gz" target-llvm/musl/target-final
tar -czf "${{ needs.create-release.outputs.version }}-wasm32-unknown-emscripten.tar.gz" target-llvm/emscripten/target-final
mv target-llvm/${{ matrix.builder-arg }}/target-final/ llvm-${{ matrix.target }}
tar -czf "${{ needs.create-release-draft.outputs.version }}-${{ matrix.target }}.tar.gz" llvm-${{ matrix.target }}
- name: upload archive to release
- name: Add Artifact to Release
uses: softprops/action-gh-release@v2
with:
make_latest: "false"
tag_name: ${{ needs.create-release.outputs.version }}
tag_name: ${{ needs.create-release-draft.outputs.version }}
draft: true
files: |
${{ needs.create-release.outputs.version }}-x86_64-linux-gnu-linux.tar.gz
${{ needs.create-release.outputs.version }}-x86_64-linux-musl.tar.gz
${{ needs.create-release.outputs.version }}-wasm32-unknown-emscripten.tar.gz
${{ needs.create-release-draft.outputs.version }}-${{ matrix.target }}.tar.gz