Skip to content

Commit

Permalink
feat: support build with sanitizers
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbaliasnikov committed Jun 17, 2024
1 parent f9233c2 commit a68cea1
Showing 1 changed file with 37 additions and 21 deletions.
58 changes: 37 additions & 21 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ name: Sanitizers tests
on:
workflow_call:
inputs:
sanitizer:
required: true
# For more information about the supported sanitizers in Rust, see:
# https://rustc-dev-guide.rust-lang.org/sanitizers.html
rust-sanitizer:
required: false
default: 'address'
type: string
description: 'A sanitizer to build Rust code with. Possible values are: address, cfi, hwaddress, kcfi, leak, memory or thread'
# For more information about the supported sanitizers in LLVM, see `LLVM_USE_SANITIZER` option in:
# https://www.llvm.org/docs/CMake.html
llvm-sanitizer:
required: false
default: 'Address'
type: string
description: 'Sanitizer to run tests with'
description: 'A sanitizer to build LLVM with. Possible values are Address, Memory, MemoryWithOrigins, Undefined, Thread, DataFlow, and Address;Undefined'
path:
required: false
type: string
description: 'Path to tests'
description: 'Path filter of the era-compiler-tester. For example: tests/solidity/simple'
mode:
required: false
type: string
description: 'Mode to run tests with'
description: 'Mode filter for the era-compiler-tester. For example: Y+M3B3 0.8.26'
pull_request:

jobs:
Expand All @@ -24,6 +34,9 @@ jobs:
container:
image: matterlabs/llvm_runner:ubuntu22-llvm17-latest
options: -m 110g
env:
RUSTFLAGS: "-Z sanitizer=thread${{ inputs.rust-sanitizer }}"
TARGET: x86_64-unknown-linux-gnu
steps:

- name: Checkout compiler-tester
Expand All @@ -34,30 +47,33 @@ jobs:
- name: Build LLVM
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@abalias-cpr-1052-run-compiler-tester-with-address-sanitizer
with:
#builder-extra-args: "--sanitizer ${{ inputs.sanitizer }}"
builder-extra-args: "--sanitizer Address"
builder-extra-args: "--sanitizer Thread${{ inputs.llvm-sanitizer }}"
enable-assertions: true

- name: Build compiler-tester
- name: Install rustc nightly
run: |
rustup install nightly-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
RUSTFLAGS="-Z sanitizer=address" cargo +nightly build --target x86_64-unknown-linux-gnu -Zbuild-std --bin 'compiler-tester'
rustup install nightly-${TARGET}
rustup component add rust-src --toolchain nightly-${TARGET}
- name: Build compiler-tester
run: cargo +nightly build --release --target ${TARGET} -Zbuild-std --bin 'compiler-tester'

- name: Build compilers
- name: Build zksolc and zkvyper
env:
CARGO_CHECKOUT_DIR: /usr/local/cargo/git/checkouts
run: |
export RUSTFLAGS="-Z sanitizer=address"
cargo +nightly build --target x86_64-unknown-linux-gnu -Zbuild-std --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-solidity-*/*/Cargo.toml --target-dir './target-zksolc/'
cargo +nightly build --target x86_64-unknown-linux-gnu -Zbuild-std --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml --target-dir './target-zkvyper/'
cargo +nightly build --release --target ${TARGET} -Zbuild-std \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-solidity-*/*/Cargo.toml \
--target-dir './target-zksolc/'
cargo +nightly build --release --target ${TARGET} -Zbuild-std \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \
--target-dir './target-zkvyper/'
- name: Run tests with sanitizers
run: |
set -x
./target/x86_64-unknown-linux-gnu/debug/compiler-tester \
--zksolc './target-zksolc/x86_64-unknown-linux-gnu/debug/zksolc' \
--zkvyper './target-zkvyper/x86_64-unknown-linux-gnu/debug/zkvyper' \
--path='tests/solidity/simple/algorithm' --mode='Y+M3B3 0.8.26'
# --path '${{ inputs.path }}'
# --mode '${{ inputs.mode }}'
./target/${TARGET}/release/compiler-tester \
--zksolc './target-zksolc/${TARGET}/release/zksolc' \
--zkvyper './target-zkvyper/${TARGET}/release/zkvyper' \
--path '${{ inputs.path }}'
--mode '${{ inputs.mode }}'

0 comments on commit a68cea1

Please sign in to comment.