Compare commits

...

8 Commits

Author SHA1 Message Date
xermicus 75a83af4da ci: clippy (#227)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-21 16:43:09 +01:00
xermicus 9c330ef8fc llvm-builder: only run expensive tests on linux (#226)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-21 16:38:44 +01:00
Yuri Volkov 687cec31ef Using released LLVM in revive build (#220) 2025-02-21 16:30:26 +01:00
Yuri Volkov 48a019e0ad Fix: add llvm- prefix to llvm version tag (#225)
Needed both for differentiating them from regular releases and for
filtering the tags in automation
2025-02-21 12:05:40 +01:00
xermicus 17a2d2f9f2 update README.md (#223)
Signed-off-by: xermicus <cyrill@parity.io>
2025-02-21 10:51:40 +01:00
Yuri Volkov 6ad7908c5e Using workflow_dispatch for LLVM releases (#222) 2025-02-20 20:00:33 +01:00
Yuri Volkov 840a736fc5 LLVM release workflows (#207)
Co-authored-by: xermicus <cyrill@parity.io>
2025-02-20 12:30:52 +01:00
xermicus 89cdfefab4 remove some dead code leftovers (#218)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-19 10:41:32 +01:00
8 changed files with 624 additions and 383 deletions
+36
View File
@@ -0,0 +1,36 @@
module.exports = async ({
octokit,
context,
releasePrefix,
artifactSuffix,
}) => {
let page = 1;
while (true) {
const res = await octokit.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
page,
});
if (res.data.length === 0) {
throw new Error(
`No LLVM releases with '${artifactSuffix}' atifacts found! Please release LLVM before running this workflow.`,
);
}
for (let release of res.data) {
if (release.tag_name.startsWith(releasePrefix)) {
for (let asset of release.assets) {
if (asset.name.includes(artifactSuffix)) {
return asset.browser_download_url;
}
}
console.warn(
`LLVM release ${release.tag_name} doesn't have a '${artifactSuffix}' artifact; searching for older releases...`,
);
}
}
page++;
}
};
+167
View File
@@ -0,0 +1,167 @@
name: Release LLVM
on:
workflow_dispatch:
inputs:
llvm_version:
type: string
required: true
description: llvm version in "x.x.x" format, e.g. "18.1.8"
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.resolve-version.outputs.version }}
steps:
- id: resolve-version
run: |
echo "version=llvm-${{ inputs.llvm_version }}-revive.${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- 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"
tag_name: ${{ steps.resolve-version.outputs.version }}
build-macos:
strategy:
matrix:
os: [macos-14, macos-13]
include:
- os: macos-13
arch: x64
- os: macos-14
arch: arm64
needs: create-release
runs-on: ${{ matrix.os }}
name: "build-macos-${{ matrix.arch }}"
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
with:
make_latest: "false"
tag_name: ${{ needs.create-release.outputs.version }}
files: |
${{ needs.create-release.outputs.version }}-macos-${{ matrix.arch }}.tar.gz
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
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
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: Build host LLVM
run: |
make install-llvm
- name: Build gnu LLVM
run: |
revive-llvm clone
revive-llvm build --llvm-projects lld --llvm-projects clang
- name: Build musl LLVM
run: |
revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang
- name: Build emscripten LLVM
run: |
revive-llvm --target-env emscripten clone
source emsdk/emsdk_env.sh
revive-llvm --target-env emscripten build --llvm-projects lld
- name: clean
# check removed files
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
- name: package artifacts
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
- name: upload archive to release
uses: softprops/action-gh-release@v2
with:
make_latest: "false"
tag_name: ${{ needs.create-release.outputs.version }}
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
+366 -347
View File
@@ -1,347 +1,366 @@
name: Release name: Release
run-name: Release ${{ github.ref_name }} run-name: Release ${{ github.ref_name }}
on: on:
push: push:
branches: branches:
- 'main' - "main"
concurrency: concurrency:
group: ${{ github.ref }}-${{ github.workflow }} group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true cancel-in-progress: true
env: env:
#rust-musl-cross:x86_64-musl #rust-musl-cross:x86_64-musl
RUST_MUSL_CROSS_IMAGE: messense/rust-musl-cross@sha256:68b86bc7cb2867259e6b233415a665ff4469c28b57763e78c3bfea1c68091561 RUST_MUSL_CROSS_IMAGE: messense/rust-musl-cross@sha256:68b86bc7cb2867259e6b233415a665ff4469c28b57763e78c3bfea1c68091561
RUST_LOG: trace
jobs:
jobs:
# tag:
# runs-on: ubuntu-24.04
# permissions:
tag: contents: write
runs-on: ubuntu-24.04 outputs:
permissions: TAG: ${{ steps.versions.outputs.TAG }}
contents: write PKG_VER: ${{ steps.versions.outputs.PKG_VER }}
outputs: RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }}
TAG: ${{ steps.versions.outputs.TAG }} steps:
PKG_VER: ${{ steps.versions.outputs.PKG_VER }} - name: Checkout
steps: uses: actions/checkout@v4
- name: Checkout with:
uses: actions/checkout@v4 fetch-tags: "true"
with: fetch-depth: 0
fetch-tags: 'true'
fetch-depth: 0 - name: Versions
id: versions
- name: Versions run: |
id: versions export CURRENT_TAG=$(git describe --tags --abbrev=0 --exclude "llvm-*")
run: | export PKG_VER=v$(cat Cargo.toml | grep -A 5 package] | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d " ")
export CURRENT_TAG=$(git describe --tags --abbrev=0 --exclude "llvm-*") echo "Current tag $CURRENT_TAG"
export PKG_VER=v$(cat Cargo.toml | grep -A 5 package] | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d " ") echo "Package version $PKG_VER"
echo "Current tag $CURRENT_TAG" #
echo "Package version $PKG_VER" echo "PKG_VER=$PKG_VER" >> $GITHUB_OUTPUT
# if [[ $CURRENT_TAG == $PKG_VER ]];
echo "PKG_VER=$PKG_VER" >> $GITHUB_OUTPUT then
if [ $CURRENT_TAG == $PKG_VER ]; echo "Tag is up to date. Nothing to do.";
then export TAG=old;
echo "Tag is up to date. Nothing to do."; else
export TAG=old; echo "Tag was updated.";
else export TAG=new;
echo "Tag was updated."; fi
export TAG=new; echo "TAG=$TAG" >> $GITHUB_OUTPUT
fi
echo "TAG=$TAG" >> $GITHUB_OUTPUT # Generating release notes early, in order to avoid checkout at the last step
export RELEASE_NOTES="$(sed '/^## '${PKG_VER}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
#
# echo "Release notes:"
# echo "$RELEASE_NOTES"
build-linux-all:
if: ${{ needs.tag.outputs.TAG == 'new' }} echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
runs-on: parity-large echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
needs: [tag] echo 'EOF' >> $GITHUB_OUTPUT
steps:
- uses: actions/checkout@v4 build-macos:
strategy:
- name: install linux deps matrix:
run: | os: [macos-14, macos-13]
sudo apt-get update && sudo apt-get install -y cmake ninja-build \ include:
curl git libssl-dev pkg-config clang lld musl - os: macos-13
arch: x64
- name: Install Rust stable toolchain - os: macos-14
uses: actions-rs/toolchain@v1 arch: arm64
with: if: ${{ needs.tag.outputs.TAG == 'new' }}
profile: minimal runs-on: ${{ matrix.os }}
toolchain: stable name: "build-macos-${{ matrix.arch }}"
components: rust-src needs: [tag]
target: wasm32-unknown-emscripten steps:
- uses: actions/checkout@v4
- name: versions
run: | - name: Get latest macos ${{ matrix.arch }} LLVM release artifact
rustup show id: get-llvm-artifact
cargo --version uses: actions/github-script@v7
cmake --version with:
echo "bash:" && bash --version result-encoding: string
echo "ninja:" && ninja --version script: |
echo "clang:" && clang --version const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js");
return await getReleaseArtifact({
- name: build revive-llvm octokit: github,
run: make install-llvm-builder context,
releasePrefix: "llvm-",
# musl LLVM artifactSuffix: "-macos-${{ matrix.arch }}"
});
- name: llvm-musl-cache restore
id: llvm-musl-cache - uses: actions-rust-lang/setup-rust-toolchain@v1
uses: actions/cache/restore@v4 with:
with: toolchain: stable
path: target-llvm/musl/target-final components: rust-src
key: llvm-linux-musl-${{ hashFiles('crates/solidity/**') }} target: wasm32-unknown-emscripten
rustflags: ""
- name: Build musl LLVM
if: steps.llvm-musl-cache.outputs.cache-hit != 'true' - name: install macos deps
run: | run: |
revive-llvm --target-env musl clone brew install ninja
revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang
- name: versions
- name: llvm-musl-cache save run: |
if: steps.llvm-musl-cache.outputs.cache-hit != 'true' rustup show
uses: actions/cache/save@v4 cargo --version
with: cmake --version
path: target-llvm/musl/target-final echo "bash:" && bash --version
key: llvm-linux-musl-${{ hashFiles('crates/solidity/**') }} echo "ninja:" && ninja --version
echo "clang:" && clang --version
# emscripten LLVM
- name: download llvm
- name: llvm-emscripten-cache restore run: |
id: llvm-emscripten-cache curl -L -o llvm.tar.gz "${{ steps.get-llvm-artifact.outputs.result }}"
uses: actions/cache/restore@v4 tar -xvf llvm.tar.gz
with:
path: | - name: build revive
target-llvm/emscripten/target-final run: |
emsdk export LLVM_SYS_181_PREFIX=$PWD/target-llvm/gnu/target-final
key: llvm-linux-emscripten-${{ hashFiles('crates/solidity/**') }} make install-bin
cp ./target/release/resolc ./target/release/resolc-${{ matrix.arch }}
- name: Build emscripten LLVM
if: steps.llvm-emscripten-cache.outputs.cache-hit != 'true' - name: check revive
run: | run: |
revive-llvm --target-env emscripten clone mkdir solc
source emsdk/emsdk_env.sh curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-macos
revive-llvm --target-env emscripten build --llvm-projects lld chmod +x solc/solc
PATH=$PWD/solc:$PATH
- name: llvm-emscripten-cache save result=$(./target/release/resolc-${{ matrix.arch }} --bin crates/integration/contracts/flipper.sol)
if: steps.llvm-emscripten-cache.outputs.cache-hit != 'true' echo $result
uses: actions/cache/save@v4 if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi
with:
path: | - uses: actions/upload-artifact@v4
target-llvm/emscripten/target-final with:
emsdk name: "revive-macos-${{ matrix.arch }}"
key: llvm-linux-emscripten-${{ hashFiles('crates/solidity/**') }} path: |
./target/release/resolc-${{ matrix.arch }}
# Build revive retention-days: 1
- name: build musl macos-universal-binary:
run: | runs-on: macos-14
mkdir resolc-out needs: [build-macos]
docker run -v $PWD:/opt/revive $RUST_MUSL_CROSS_IMAGE /bin/bash -c " steps:
cd /opt/revive - uses: actions/download-artifact@v4
apt update && apt upgrade -y && apt install -y pkg-config with:
export LLVM_SYS_181_PREFIX=/opt/revive/target-llvm/musl/target-final pattern: revive-macos-*
make install-bin path: revive-macos
cp /root/.cargo/bin/resolc /opt/revive/resolc-out/resolc
" - name: run lipo
run: |
- name: check musl lipo revive-macos/revive-macos-arm64/resolc-arm64 revive-macos/revive-macos-x64/resolc-x64 -create -output resolc-macos
run: |
mkdir solc - name: compress macos artifact
curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-static-linux run: |
chmod +x solc/solc tar -czf resolc-macos.tar.gz ./resolc-macos
PATH=$PWD/solc:$PATH
result=$(./resolc-out/resolc --bin crates/integration/contracts/flipper.sol) - uses: actions/upload-artifact@v4
echo $result with:
if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi name: revive-macos
path: |
- name: Set Up Node.js resolc-macos.tar.gz
uses: actions/setup-node@v3 retention-days: 1
with:
node-version: "20" build-linux-all:
if: ${{ needs.tag.outputs.TAG == 'new' }}
- name: build wasm runs-on: parity-large
run: | needs: [tag]
export LLVM_SYS_181_PREFIX=$PWD/target-llvm/musl/target-final steps:
export REVIVE_LLVM_TARGET_PREFIX=$PWD/target-llvm/emscripten/target-final - uses: actions/checkout@v4
source emsdk/emsdk_env.sh
rustup target add wasm32-unknown-emscripten - name: Get latest linux LLVM release artifact
make install-wasm id: get-llvm-musl-artifact
uses: actions/github-script@v7
- name: check wasm with:
run: | result-encoding: string
curl -sSLo solc/soljson.js https://github.com/ethereum/solidity/releases/download/v0.8.28/soljson.js script: |
node -e " const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js")
const soljson = require('solc/soljson'); return await getReleaseArtifact({
const createRevive = require('./target/wasm32-unknown-emscripten/release/resolc.js'); octokit: github,
context,
const compiler = createRevive(); releasePrefix: "llvm-",
compiler.soljson = soljson; artifactSuffix: "-x86_64-linux-musl"
})
const standardJsonInput =
{ - name: install linux deps
language: 'Solidity', run: |
sources: { sudo apt-get update && sudo apt-get install -y cmake ninja-build \
'MyContract.sol': { curl git libssl-dev pkg-config clang lld musl
content: 'pragma solidity ^0.8.0; contract MyContract { function greet() public pure returns (string memory) { return \'Hello\'; } }',
}, - uses: actions-rust-lang/setup-rust-toolchain@v1
}, with:
settings: { optimizer: { enabled: false } } toolchain: stable
}; components: rust-src
target: wasm32-unknown-emscripten
compiler.writeToStdin(JSON.stringify(standardJsonInput)); rustflags: ""
compiler.callMain(['--standard-json']);
- name: versions
// Collect output run: |
const stdout = compiler.readFromStdout(); rustup show
const stderr = compiler.readFromStderr(); cargo --version
cmake --version
if (stderr) { console.error(stderr); process.exit(1); } echo "bash:" && bash --version
echo "ninja:" && ninja --version
let out = JSON.parse(stdout); echo "clang:" && clang --version
let bytecode = out.contracts['MyContract.sol']['MyContract'].evm.bytecode.object
console.log(bytecode); - name: download llvm
run: |
if(!bytecode.startsWith('50564d')) { process.exit(1); } curl -L -o llvm.tar.gz "${{ steps.get-llvm-musl-artifact.outputs.result }}"
" tar -xvf llvm.tar.gz
- uses: actions/upload-artifact@v4 # Build revive
with:
name: revive-wasm - name: build musl
path: | run: |
./target/wasm32-unknown-emscripten/release/resolc.js mkdir resolc-out
./target/wasm32-unknown-emscripten/release/resolc.wasm docker run -v $PWD:/opt/revive $RUST_MUSL_CROSS_IMAGE /bin/bash -c "
./target/wasm32-unknown-emscripten/release/resolc_web.js cd /opt/revive
retention-days: 1 apt update && apt upgrade -y && apt install -y pkg-config
export LLVM_SYS_181_PREFIX=/opt/revive/target-llvm/musl/target-final
- uses: actions/upload-artifact@v4 make install-bin
with: cp /root/.cargo/bin/resolc /opt/revive/resolc-out/resolc-static-linux
name: revive-linux "
path: |
./resolc-out/resolc - name: check musl
retention-days: 1 run: |
mkdir solc
# curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-static-linux
# chmod +x solc/solc
# PATH=$PWD/solc:$PATH
create-release: result=$(./resolc-out/resolc-static-linux --bin crates/integration/contracts/flipper.sol)
needs: [tag, build-linux-all] echo $result
runs-on: ubuntu-24.04 if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi
permissions:
contents: write - name: compress musl artifact
outputs: run: |
upload_url: ${{ steps.create_release.outputs.result }} tar --strip-components 1 -czf resolc-static-linux.tar.gz ./resolc-out/resolc-static-linux
steps:
- uses: actions/checkout@v4 - uses: actions/upload-artifact@v4
with:
- name: Create/update tag name: revive-linux
id: tag path: |
uses: actions/github-script@v7 ./resolc-static-linux.tar.gz
with: retention-days: 1
result-encoding: string
script: | - name: Set Up Node.js
await github.rest.git.createRef({ uses: actions/setup-node@v3
owner: context.repo.owner, with:
repo: context.repo.repo, node-version: "20"
ref: 'refs/tags/${{ needs.tag.outputs.PKG_VER }}',
sha: context.sha - name: Get latest emscripten LLVM release artifact
}) id: get-llvm-emscripten-artifact
uses: actions/github-script@v7
- name: get relese notes with:
id: get-notes result-encoding: string
run: | script: |
{ const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js")
echo 'releaseNotes<<EOF' return await getReleaseArtifact({
sed '/^## ${{ needs.tag.outputs.PKG_VER }}/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d' octokit: github,
echo EOF context,
} >> "$GITHUB_OUTPUT" releasePrefix: "llvm-",
artifactSuffix: "-wasm32-unknown-emscripten"
})
- name: Create release
id: create_release - name: download llvm
env: run: |
releaseNotes: ${{ steps.get-notes.outputs.releaseNotes }} curl -L -o llvm.tar.gz "${{ steps.get-llvm-emscripten-artifact.outputs.result }}"
version: ${{ needs.tag.outputs.PKG_VER }} tar -xvf llvm.tar.gz
uses: actions/github-script@v7
with: - name: build wasm
result-encoding: string run: |
script: | make install-llvm-builder
let response = await github.rest.repos.createRelease({ revive-llvm --target-env emscripten clone
owner: context.repo.owner, export LLVM_SYS_181_PREFIX=$PWD/target-llvm/musl/target-final
repo: context.repo.repo, export REVIVE_LLVM_TARGET_PREFIX=$PWD/target-llvm/emscripten/target-final
tag_name: process.env.version, source emsdk/emsdk_env.sh
name: process.env.version, rustup target add wasm32-unknown-emscripten
body: process.env.releaseNotes, make install-wasm
draft: true,
prerelease: true - name: check wasm
}); run: |
console.log(response); curl -sSLo solc/soljson.js https://github.com/ethereum/solidity/releases/download/v0.8.28/soljson.js
return response.data.upload_url; node -e "
const soljson = require('solc/soljson');
- name: Log const createRevive = require('./target/wasm32-unknown-emscripten/release/resolc.js');
run: |
echo "tag result: ${{ needs.tag.outputs.TAG }}" const compiler = createRevive();
echo "pkg version: ${{ needs.tag.outputs.PKG_VER }}" compiler.soljson = soljson;
# const standardJsonInput =
# {
# language: 'Solidity',
upload-assets: sources: {
runs-on: ubuntu-24.04 'MyContract.sol': {
needs: [create-release] content: 'pragma solidity ^0.8.0; contract MyContract { function greet() public pure returns (string memory) { return \'Hello\'; } }',
steps: },
},
- name: Download Artifact settings: { optimizer: { enabled: false } }
uses: actions/download-artifact@v4 };
with:
name: revive-wasm compiler.writeToStdin(JSON.stringify(standardJsonInput));
path: resolc/ compiler.callMain(['--standard-json']);
- name: Download Artifact // Collect output
uses: actions/download-artifact@v4 const stdout = compiler.readFromStdout();
with: const stderr = compiler.readFromStderr();
name: revive-linux
path: resolc/ if (stderr) { console.error(stderr); process.exit(1); }
- name: upload resolc let out = JSON.parse(stdout);
uses: actions/upload-release-asset@v1 let bytecode = out.contracts['MyContract.sol']['MyContract'].evm.bytecode.object
env: console.log(bytecode);
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: if(!bytecode.startsWith('50564d')) { process.exit(1); }
upload_url: ${{ needs.create-release.outputs.upload_url }} "
asset_path: ./resolc/resolc
asset_name: resolc-static-linux - name: compress wasm artifact
asset_content_type: application/octet-stream run: |
tar --strip-components 3 -czf resolc-wasm.tar.gz \
- name: upload resolc.js ./target/wasm32-unknown-emscripten/release/resolc.js \
uses: actions/upload-release-asset@v1 ./target/wasm32-unknown-emscripten/release/resolc.wasm \
env: ./target/wasm32-unknown-emscripten/release/resolc_web.js
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: - uses: actions/upload-artifact@v4
upload_url: ${{ needs.create-release.outputs.upload_url }} with:
asset_path: ./resolc/resolc.js name: revive-wasm
asset_name: resolc.js path: |
asset_content_type: application/octet-stream resolc-wasm.tar.gz
retention-days: 1
- name: upload resolc.wasm
uses: actions/upload-release-asset@v1 create-release:
env: needs: [tag, build-linux-all, macos-universal-binary]
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} runs-on: ubuntu-24.04
with: permissions:
upload_url: ${{ needs.create-release.outputs.upload_url }} contents: write
asset_path: ./resolc/resolc.wasm outputs:
asset_name: resolc.wasm upload_url: ${{ steps.create_release.outputs.result }}
asset_content_type: application/octet-stream steps:
- name: Download revive-wasm
- name: upload resolc_web.js uses: actions/download-artifact@v4
uses: actions/upload-release-asset@v1 with:
env: name: revive-wasm
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} path: resolc-wasm/
with:
upload_url: ${{ needs.create-release.outputs.upload_url }} - name: Download revive-linux
asset_path: ./resolc/resolc_web.js uses: actions/download-artifact@v4
asset_name: resolc_web.js with:
asset_content_type: application/octet-stream name: revive-linux
path: resolc-linux/
- name: Download revive-macos
uses: actions/download-artifact@v4
with:
name: revive-macos
path: resolc-macos/
- name: create-release
uses: softprops/action-gh-release@v2
with:
body: ${{ needs.tag.outputs.RELEASE_NOTES }}
tag_name: ${{ needs.tag.outputs.PKG_VER }}
name: ${{ needs.tag.outputs.PKG_VER }}
draft: true
files: |
./resolc-linux/resolc-static-linux.tar.gz
./resolc-macos/resolc-macos.tar.gz
./resolc-wasm/resolc-wasm.tar.gz
+42 -16
View File
@@ -1,5 +1,5 @@
![CI](https://github.com/paritytech/revive/actions/workflows/rust.yml/badge.svg) ![CI](https://github.com/paritytech/revive/actions/workflows/rust.yml/badge.svg)
[![Docs](https://img.shields.io/badge/Docs-contracts.polkadot.io-brightgreen.svg)](https://contracts.polkadot.io) [![Docs](https://img.shields.io/badge/Docs-contracts.polkadot.io-brightgreen.svg)](https://contracts.polkadot.io/revive_compiler/)
# revive # revive
@@ -14,10 +14,7 @@ This is experimental software in active development and not ready just yet for p
Discussion around the development is hosted on the [Polkadot Forum](https://forum.polkadot.network/t/contracts-update-solidity-on-polkavm/6949#a-new-solidity-compiler-1). Discussion around the development is hosted on the [Polkadot Forum](https://forum.polkadot.network/t/contracts-update-solidity-on-polkavm/6949#a-new-solidity-compiler-1).
## Installation ## Installation
Please consult [the documentation](https://contracts.polkadot.io/revive_compiler/installation) for installation instructions.
`resolc` depends on the [solc](https://github.com/ethereum/solidity) binary installed on your system.
Download and install the `resolc` frontend executable for your platform from our [releases](https://github.com/paritytech/revive/releases).
## Building from source ## Building from source
@@ -25,22 +22,46 @@ Building revive requires a [stable Rust installation](https://rustup.rs/) and a
### LLVM ### LLVM
`revive` depends on a custom build of LLVM `v18.1.8` with the RISC-V _embedded_ target, including the `compiler-rt` builtins. Use the provided [revive-llvm](crates/llvm-builder/README.md) utility to compile a compatible LLVM build locally and point `$LLVM_SYS_181_PREFIX` to the installation afterwards. `revive` depends on a custom build of LLVM `v18.1.8` with the RISC-V _embedded_ target, including the `compiler-rt` builtins. You can either download a build from our releases (recommended for older hardware) or build it from source.
<details>
<summary>Download from our LLVM releases</summary>
Download the [latest LLVM build](https://github.com/paritytech/revive/releases?q=LLVM+binaries+release&expanded=true) from our releases.
> **MacOS** users need to clear the `downloaded` attribute from all binaries after extracting the archive:
> ```sh
> xattr -rc </path/to/the/extracted/archive>/target-llvm/gnu/target-final/bin/*
> ```
After extracting the archive, point `$LLVM_SYS_181_PREFIX` to it:
```sh
export LLVM_SYS_181_PREFIX=</path/to/the/extracted/archive>/target-llvm/gnu/target-final
```
</details>
<details>
<summary>Building from source</summary>
Use the provided [revive-llvm](crates/llvm-builder/README.md) utility to compile a compatible LLVM build locally and point `$LLVM_SYS_181_PREFIX` to the installation afterwards.
The `Makefile` provides a shortcut target to obtain a compatible LLVM build: The `Makefile` provides a shortcut target to obtain a compatible LLVM build:
```bash ```sh
make install-llvm make install-llvm
export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final
``` ```
</details>
### The `resolc` Solidity frontend ### The `resolc` Solidity frontend
To build the `resolc` Solidity frontend executable, make sure you have obtained a compatible LLVM build using [revive-llvm](crates/llvm-builder/README.md) and did export the `LLVM_SYS_181_PREFIX` environment variable pointing to it (see [above](#LLVM)). To build the `resolc` Solidity frontend executable, make sure you have obtained a compatible LLVM build and did export the `LLVM_SYS_181_PREFIX` environment variable pointing to it (see [above](#LLVM)).
To install the `resolc` Solidity frontend executable: To install the `resolc` Solidity frontend executable:
```bash ```sh
make install-bin make install-bin
resolc --version resolc --version
``` ```
@@ -49,7 +70,10 @@ resolc --version
Cross-compile the `resolc.js` frontend executable to Wasm for running it in a Node.js or browser environment. The `REVIVE_LLVM_TARGET_PREFIX` environment variable is used to control the target environment LLVM dependency. Cross-compile the `resolc.js` frontend executable to Wasm for running it in a Node.js or browser environment. The `REVIVE_LLVM_TARGET_PREFIX` environment variable is used to control the target environment LLVM dependency.
```bash <details>
<summary>Instructions for cross-compilation to wasm32-unknown-emscripten</summary>
```sh
# Build the host LLVM dependency with PolkaVM target support # Build the host LLVM dependency with PolkaVM target support
make install-llvm make install-llvm
export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final
@@ -65,21 +89,23 @@ make install-wasm
make test-wasm make test-wasm
``` ```
### Development </details>
## Development
Please consult the [Makefile](Makefile) targets to learn how to run tests and benchmarks. Please consult the [Makefile](Makefile) targets to learn how to run tests and benchmarks.
Ensure that your branch passes `make test` locally when submitting a pull request. Ensure that your branch passes `make test` locally when submitting a pull request.
## Design overview ### Design overview
See the [relevant section in our documentation](https://contracts.polkadot.io/revive_compiler/architecture) to learn more about how the compiler works.
`revive` uses [solc](https://github.com/ethereum/solidity/), the Ethereum Solidity compiler, as the [Solidity frontend](crates/solidity/src/lib.rs) to process smart contracts written in Solidity. The YUL IR code (or legacy EVM assembly as a fallback for older `solc` versions) emitted by `solc` is then translated to LLVM IR, targetting [Polkadots `revive` pallet](https://docs.rs/pallet-revive/latest/pallet_revive/trait.SyscallDoc.html). [Frontend](https://github.com/matter-labs/era-compiler-solidity) and [code generator](https://github.com/matter-labs/era-compiler-llvm-context) are based of ZKSync `zksolc` (the project started as a fork of the era compiler).
[Frontend](https://github.com/matter-labs/era-compiler-solidity) and [code generator](https://github.com/matter-labs/era-compiler-llvm-context) are based of ZKSync `zksolc`.
## Tests ### Tests
Before running the tests, ensure that Geth (Go Ethereum) is installed on your system. Follow the installation guide here: [Installing Geth](https://geth.ethereum.org/docs/getting-started/installing-geth). Before running the tests, ensure that Geth (Go Ethereum) is installed on your system. Follow the installation guide here: [Installing Geth](https://geth.ethereum.org/docs/getting-started/installing-geth).
Once Geth is installed, you can run the tests using the following command: Once Geth is installed, you can run the tests using the following command:
```bash ```sh
make test make test
``` ```
+8 -1
View File
@@ -7,4 +7,11 @@ To create a new pre-release:
1. Merge a release PR which updates the `-dev.X` versions in the workspace `Cargo.toml` and updates the `CHANGELOG.md` accordingly. The release workflow will attempt to build and publish a new release whenever the latest git tag does not match the cargo package version. 1. Merge a release PR which updates the `-dev.X` versions in the workspace `Cargo.toml` and updates the `CHANGELOG.md` accordingly. The release workflow will attempt to build and publish a new release whenever the latest git tag does not match the cargo package version.
2. Wait for the `Release` workflow to finish. If the workflow fails after the `build-linux-all` step, check if a tag has been created and delete it before restarting or pushing updates. Note: It's more convenient to debug the release workflow in a fork (the fork has to be under the `paritytech` org to access `parity-large` runners). 2. Wait for the `Release` workflow to finish. If the workflow fails after the `build-linux-all` step, check if a tag has been created and delete it before restarting or pushing updates. Note: It's more convenient to debug the release workflow in a fork (the fork has to be under the `paritytech` org to access `parity-large` runners).
3. Check draft release on [Releases page](https://github.com/paritytech/revive/releases) and publish (should contain `resolc.js`, `resolc.wasm`, `resolc-web.js`, and `resolc-static-linux` release assets) 3. Check draft release on [Releases page](https://github.com/paritytech/revive/releases) and publish (should contain `resolc.js`, `resolc.wasm`, `resolc-web.js`, and `resolc-static-linux` release assets)
4. Update the [contract-docs](https://github.com/paritytech/contract-docs/) accordingly 4. Update the [contract-docs](https://github.com/paritytech/contract-docs/) accordingly
# LLVM release
To create a new LLVM release, run "Release LLVM" workflow. Use current LLVM version as parameter, e.g. `18.1.8`.
Version suffix will be resolved automatically.
The workflows will create new GitHub release, and upload LLVM binaries.
Next release of resolc will use newly created binaries.
+3 -1
View File
@@ -83,6 +83,7 @@ fn clone_build_and_clean_musl() -> anyhow::Result<()> {
/// This test verifies that the LLVM repository can be successfully cloned and built in debug mode /// This test verifies that the LLVM repository can be successfully cloned and built in debug mode
/// with tests and coverage enabled. /// with tests and coverage enabled.
#[test] #[test]
#[cfg(target_os = "linux")]
fn debug_build_with_tests_coverage() -> anyhow::Result<()> { fn debug_build_with_tests_coverage() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?; let test_dir = common::TestDir::with_lockfile(None)?;
@@ -107,6 +108,7 @@ fn debug_build_with_tests_coverage() -> anyhow::Result<()> {
/// This test verifies that the LLVM repository can be successfully built with address sanitizer. /// This test verifies that the LLVM repository can be successfully built with address sanitizer.
#[test] #[test]
#[cfg(target_os = "linux")]
fn build_with_sanitizers() -> anyhow::Result<()> { fn build_with_sanitizers() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?; let test_dir = common::TestDir::with_lockfile(None)?;
@@ -129,7 +131,7 @@ fn build_with_sanitizers() -> anyhow::Result<()> {
/// Tests the clone, build, and clean process of the LLVM repository for the emscripten target. /// Tests the clone, build, and clean process of the LLVM repository for the emscripten target.
#[test] #[test]
#[cfg(any(target_os = "linux", target_os = "macos"))] #[cfg(target_os = "linux")]
fn clone_build_and_clean_emscripten() -> anyhow::Result<()> { fn clone_build_and_clean_emscripten() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?; let test_dir = common::TestDir::with_lockfile(None)?;
let command = Command::cargo_bin(common::REVIVE_LLVM)?; let command = Command::cargo_bin(common::REVIVE_LLVM)?;
@@ -212,22 +212,6 @@ impl<'ctx> Function<'ctx> {
} }
} }
/// Sets the exception handler attributes.
pub fn set_exception_handler_attributes(
llvm: &'ctx inkwell::context::Context,
declaration: Declaration<'ctx>,
) {
Self::set_attributes(llvm, declaration, vec![Attribute::NoInline], false);
}
/// Sets the CXA-throw attributes.
pub fn set_cxa_throw_attributes(
llvm: &'ctx inkwell::context::Context,
declaration: Declaration<'ctx>,
) {
Self::set_attributes(llvm, declaration, vec![Attribute::NoProfile], false);
}
/// Sets the pure function attributes. /// Sets the pure function attributes.
pub fn set_pure_function_attributes( pub fn set_pure_function_attributes(
llvm: &'ctx inkwell::context::Context, llvm: &'ctx inkwell::context::Context,
@@ -943,7 +943,7 @@ impl FunctionCall {
Name::BlobHash => { Name::BlobHash => {
let _arguments = self.pop_arguments_llvm::<D, 1>(context)?; let _arguments = self.pop_arguments_llvm::<D, 1>(context)?;
anyhow::bail!( anyhow::bail!(
"{} The `BLOBHASH` instruction is not supported until zkVM v1.5.0", "{} The `BLOBHASH` instruction is not supported in revive",
location location
); );
} }
@@ -958,7 +958,7 @@ impl FunctionCall {
} }
Name::BlobBaseFee => { Name::BlobBaseFee => {
anyhow::bail!( anyhow::bail!(
"{} The `BLOBBASEFEE` instruction is not supported until zkVM v1.5.0", "{} The `BLOBBASEFEE` instruction is not supported in revive",
location location
); );
} }