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
revive LLVM builder
Parity fork of the Matter Labs zksync LLVM builder helper utility for compiling revive compatible LLVM builds.
Installation and usage
The LLVM compiler framework for revive must be built with our tool called revive-llvm.
This is because the revive compiler has requirements not fullfilled in upstream builds:
- Special builds for compiling the frontend into statically linked ELF binaries and also Wasm executables
- The RISC-V target (the PolkaVM target)
- The compiler-rt builtins for the PolkaVM target
- We want to leave the assertions always on
- Various other specific configurations and optimization may be applied
Obtain a compatible build for your host platform from the release section of this repository (TODO). Alternatively follow below steps to get a custom build:
1. Install the system prerequisites.
-
Linux (Debian):
Install the following packages:
apt install cmake ninja-build curl git libssl-dev pkg-config clang lld -
Linux (Arch):
Install the following packages:
pacman -Syu which cmake ninja curl git pkg-config clang lld -
MacOS:
-
Install the HomeBrew package manager.
-
Install the following packages:
brew install cmake ninja coreutils -
Install your choice of a recent LLVM/Clang compiler, e.g. via Xcode, Apple’s Command Line Tools, or your preferred package manager.
-
2. Install Rust.
-
Follow the latest [official instructions](https://www.rust-lang.org/tools/install:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh . ${HOME}/.cargo/envCurrently we are not pinned to any specific version of Rust, so just install the latest stable build for your platform.
3. Install the revive LLVM framework builder.
-
Install the builder using
cargo:cargo install --git https://github.com/paritytech/revive-llvm-builder --force --lockedThe builder is not the LLVM framework itself, but a tool that clones its repository and runs a sequence of build commands. By default it is installed in
~/.cargo/bin/, which is recommended to be added to your$PATH.
4. (Optional) Create the `LLVM.lock` file.
- The
LLVM.lockdictates the LLVM source tree being used. A default./LLVM.lockpointing to the release used for development is already provided.
5. Build LLVM.
-
Clone and build the LLVM framework using the
revive-llvmtool.The clang and lld projects are required for the
resolcSolidity frontend executable; they are enabled by default. LLVM assertions are also enabled by default.revive-llvm clone revive-llvm build --llvm-projects lld --llvm-projects clangBuild artifacts end up in the
./target-llvm/gnu/target-final/directory by default. Thegnudirectory depends on the supported archticture and will either begnu,musloremscripten. You now need to export the final target directory$LLVM_SYS_181_PREFIX:export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-finalIf built with the--enable-testsoption, test tools will be in the./target-llvm/gnu/build-final/directory, along with copies of the build artifacts. For all supported build options, runrevive-llvm build --help.
Supported target architectures
The following target platforms are supported:
- Linux GNU (x86)
- Linux MUSL (x86)
- MacOS (aarch64)
- Windows GNU (x86)
- Emscripten (wasm32)
Building for MUSL
-
Via a musl build we can build revive into fully static ELF binaries. Which is desirable for reproducible Solidity contracts builds. The resulting binary is also very portable, akin to the
solcfrontend binary distribution.Clone and build the LLVM framework using the
revive-llvmtool:revive-llvm --target-env musl clone revive-llvm --target-env musl build --enable-assertions --llvm-projects clang --llvm-projects lld
Building for Emscripten
-
Via an emsdk build we can run revive in the browser and on node.js.
Clone and build the LLVM framework using the
revive-llvmtool:revive-llvm --target-env emscripten clone revive-llvm --target-env emscripten build --enable-assertions --llvm-projects clang --llvm-projects lld