From 4fbfb97b9eac73d90ff947bfb83ae1736c4e67b2 Mon Sep 17 00:00:00 2001 From: Cyrill Leutwiler Date: Wed, 15 Jan 2025 11:36:59 +0100 Subject: [PATCH] Fix the Wasm build cache (#159) Follow-ups for https://github.com/paritytech/revive/pull/154 - Fix the cache in the Wasm build - Remove a no longer needed script - The Wasm build job uses parity-large --- .github/trigger-wasm-llvm-build | 1 - .github/workflows/build-revive-wasm.yml | 40 ++++++++++++++++--------- clone-llvm.sh | 18 ----------- 3 files changed, 26 insertions(+), 33 deletions(-) delete mode 100644 .github/trigger-wasm-llvm-build delete mode 100755 clone-llvm.sh diff --git a/.github/trigger-wasm-llvm-build b/.github/trigger-wasm-llvm-build deleted file mode 100644 index 56a6051..0000000 --- a/.github/trigger-wasm-llvm-build +++ /dev/null @@ -1 +0,0 @@ -1 \ No newline at end of file diff --git a/.github/workflows/build-revive-wasm.yml b/.github/workflows/build-revive-wasm.yml index c0db734..5ad06fa 100644 --- a/.github/workflows/build-revive-wasm.yml +++ b/.github/workflows/build-revive-wasm.yml @@ -9,12 +9,11 @@ on: env: CARGO_TERM_COLOR: always REVIVE_WASM_INSTALL_DIR: ${{ github.workspace }}/target/wasm32-unknown-emscripten/release - EMSCRIPTEN_VERSION: 3.1.64 BUN_VERSION: 1.1.43 jobs: build-revive-wasm: - runs-on: ubuntu-24.04 + runs-on: parity-large defaults: run: shell: bash @@ -26,30 +25,43 @@ jobs: uses: actions/cache@v3 with: path: | - target-llvm + target-llvm/emscripten/target-final + target-llvm/gnu/target-final # Use a unique key based on LLVM version or configuration files to avoid cache invalidation - key: llvm-build-${{ runner.os }}-${{ hashFiles('LLVM.lock', '.github/trigger-wasm-llvm-build') }} + key: llvm-build-${{ runner.os }}-${{ hashFiles('LLVM.lock', 'Cargo.toml', 'Cargo.lock', 'crates/llvm-builder/**', '.github/workflows/build-revive-wasm.yml') }} - - name: Install Dependencies + - name: Install system dependencies run: | - # 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 - # 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 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rust-src + target: wasm32-unknown-emscripten + + - name: Install LLVM build dependencies + run: | make install-llvm-builder revive-llvm --target-env emscripten clone + - name: Setup revive environment variables + run: | + echo "LLVM_SYS_181_PREFIX=$(pwd)/target-llvm/gnu/target-final" >> $GITHUB_ENV + echo "REVIVE_LLVM_TARGET_PREFIX=$(pwd)/target-llvm/emscripten/target-final" >> $GITHUB_ENV + + - name: Build host LLVM + if: steps.cache-llvm.outputs.cache-hit != 'true' + run: | + revive-llvm build + - 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 diff --git a/clone-llvm.sh b/clone-llvm.sh deleted file mode 100755 index 03aefc2..0000000 --- a/clone-llvm.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -# Default directory for cloning the llvm-project repository -DEFAULT_DIR="llvm-project" - -# Check if a directory argument is provided -if [ $# -eq 1 ]; then - DIR=$1 -else - DIR=$DEFAULT_DIR -fi - -# Clone LLVM 18 (any revision after commit bd32aaa is supposed to work) -if [ ! -d "${DIR}" ]; then - git clone --depth 1 --branch release/18.x https://github.com/llvm/llvm-project.git "${DIR}" -fi