From a68cea1d36d55ebbdb8edd7b54346c9daf50c2d3 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Mon, 17 Jun 2024 12:05:19 +0100 Subject: [PATCH] feat: support build with sanitizers --- .github/workflows/sanitizers.yml | 58 ++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 516c0560..151dc2ad 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -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: @@ -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 @@ -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 }}'