Skip to content

Commit

Permalink
revive llvm builder utility (#154)
Browse files Browse the repository at this point in the history
Pre-eliminary support for LLVM releases and resolc binary releases by streamlining the build process for all supported hosts platforms.

- Introduce the revive-llvm-builder crate with the revive-llvm builder utilty.
- Do not rely on the LLVM dependency in $PATH to decouple the system LLVM installation from the LLVM host dependency.
- Fix the emscripten build by decoupling the host and native LLVM dependencies. Thus allowing a single LLVM emscripten release that can be used on any host platform.
- An example Dockerfile building an alpine container with a fully statically linked resolc ELF binary.
- Remove the Debian builder utilities and workflow.
  • Loading branch information
xermicus authored Jan 13, 2025
1 parent fde9eda commit 7f81f37
Show file tree
Hide file tree
Showing 65 changed files with 4,844 additions and 554 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
emsdk
llvm*/
target-llvm/
target/
node_modules/
utils/
build/
1 change: 1 addition & 0 deletions .github/trigger-wasm-llvm-build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
38 changes: 0 additions & 38 deletions .github/workflows/build-revive-debian.yml

This file was deleted.

48 changes: 23 additions & 25 deletions .github/workflows/build-revive-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:

jobs:
build-revive-wasm:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
Expand All @@ -26,24 +26,30 @@ jobs:
uses: actions/cache@v3
with:
path: |
llvm18.0-emscripten
target-llvm
# Use a unique key based on LLVM version or configuration files to avoid cache invalidation
key: llvm-build-${{ runner.os }}-${{ hashFiles('clone-llvm.sh', 'emscripten-build-llvm.sh') }}
key: llvm-build-${{ runner.os }}-${{ hashFiles('LLVM.lock', '.github/trigger-wasm-llvm-build') }}

- name: Install Dependencies
run: |
sudo apt-get update && sudo apt-get install -y cmake ninja-build libncurses5
# system dependencies
sudo apt-get update && sudo apt-get install -y cmake ninja-build curl git libssl-dev pkg-config clang lld
rustup target add wasm32-unknown-emscripten
# Install LLVM required for the compiler runtime, runtime-api and stdlib
curl -sSL --output llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.4/clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar Jxf llvm.tar.xz
mv clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04 llvm18/
echo "$(pwd)/llvm18/bin" >> $GITHUB_PATH
# Install Emscripten
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${{ env.EMSCRIPTEN_VERSION }}
./emsdk activate ${{ env.EMSCRIPTEN_VERSION }}
# host LLVM
curl -sSL --output llvm.tar.xz https://github.com/paritytech/revive/releases/download/v0.1.0-dev.7/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-24.04.tar.xz
mkdir llvm18
tar Jxf llvm.tar.xz -C llvm18/
echo "LLVM_SYS_181_PREFIX=$(pwd)/llvm18" >> $GITHUB_ENV
# Clone LLVM and install the Emscripten SDK
make install-llvm-builder
revive-llvm --target-env emscripten clone
- name: Build target LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
source emsdk/emsdk_env.sh
revive-llvm --target-env emscripten build
echo "REVIVE_LLVM_TARGET_PREFIX=${PWD}/target-llvm/emscripten/target-final" >> $GITHUB_ENV
- run: |
rustup show
Expand All @@ -52,13 +58,6 @@ jobs:
cargo +nightly --version
cmake --version
bash --version
llvm-config --version
- name: Build LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
export EMSDK_ROOT=${PWD}/emsdk
./emscripten-build-llvm.sh
- name: Use Cached LLVM
if: steps.cache-llvm.outputs.cache-hit == 'true'
Expand All @@ -67,8 +66,7 @@ jobs:
- name: Build revive
run: |
export LLVM_LINK_PREFIX=${PWD}/llvm18.0-emscripten
source ./emsdk/emsdk_env.sh
source emsdk/emsdk_env.sh
make install-wasm
- uses: actions/upload-artifact@v4
Expand All @@ -83,7 +81,7 @@ jobs:
needs: build-revive-wasm
strategy:
matrix:
os: ['ubuntu-24.04', 'macos-14', 'windows-2022']
os: ["ubuntu-24.04", "macos-14", "windows-2022"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -100,7 +98,7 @@ jobs:
- name: Set Up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
node-version: "20"

- name: Install Bun on Windows
if: runner.os == 'Windows'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
build-ubuntu-x86:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
Expand All @@ -25,16 +25,16 @@ jobs:
- name: Install LLVM
run: |
curl -sSL --output llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.4/clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar Jxf llvm.tar.xz
mv clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04 llvm18/
echo "$(pwd)/llvm18/bin" >> $GITHUB_PATH
curl -sSL --output llvm.tar.xz https://github.com/paritytech/revive/releases/download/v0.1.0-dev.7/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-24.04.tar.xz
mkdir llvm18
tar Jxf llvm.tar.xz -C llvm18/
echo "LLVM_SYS_181_PREFIX=$(pwd)/llvm18" >> $GITHUB_ENV
- name: Install apt dependencies
run: |
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt update
sudo apt install -y libtinfo5 ethereum
sudo apt install -y ethereum
- name: Format
run: make format
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/target
target-llvm
*.dot
.vscode/
.DS_Store
/*.sol
/*.yul
/*.ll
/*.s
/llvm-project
/llvm18.0
/llvm18.0-emscripten
/llvm*
node_modules
artifacts
tmp
package-lock.json
/*.html
/build
soljson.js
emsdk
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## Unreleased

This is a development pre-release.

### Added
- The `revive-llvm-builder` crate with the `revive-llvm` helper utility for streamlined management of the LLVM framework dependency.

### Changed
- The minimum supported Rust version is `1.81.0`.

### Fixed
- Decouple the LLVM target dependency from the LLVM host dependency.

## v0.1.0-dev.7

This is a development pre-release.
Expand Down
Loading

0 comments on commit 7f81f37

Please sign in to comment.