From eb773ce071339316034e1dc89156dd686db6bbc2 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 19 Aug 2025 11:29:53 +1200 Subject: [PATCH 1/6] Reapply "Workflow adjustments" This reverts commit b640a16b07ec7c313ee3d97a4a84b0eccd3d59f9. --- .github/workflows/extra-builds.yml | 16 +++- .github/workflows/test-build.yml | 36 +++++---- .github/workflows/test-compile.yml | 16 +++- .github/workflows/test-sanitizers.yml | 105 ++++++++++++++++++++++++++ .github/workflows/test-verific.yml | 16 +++- 5 files changed, 161 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/test-sanitizers.yml diff --git a/.github/workflows/extra-builds.yml b/.github/workflows/extra-builds.yml index 458eb76a6..11fd42a6c 100644 --- a/.github/workflows/extra-builds.yml +++ b/.github/workflows/extra-builds.yml @@ -1,6 +1,14 @@ name: Test extra build flows -on: [push, pull_request] +on: + # always test main + push: + branches: + - main + # test PRs + pull_request: + # allow triggering tests, ignores skip check + workflow_dispatch: jobs: pre_job: @@ -11,11 +19,11 @@ jobs: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 with: + # don't run on documentation changes paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]' # cancel previous builds if a new commit is pushed - cancel_others: 'true' - # only run on push *or* pull_request, not both - concurrent_skipping: 'same_content_newer' + # but never cancel main + cancel_others: ${{ github.ref != 'refs/heads/main' }} vs-prep: name: Prepare Visual Studio build diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index f9574594a..f44dee1ba 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -1,6 +1,14 @@ name: Build and run tests -on: [push, pull_request] +on: + # always test main + push: + branches: + - main + # test PRs + pull_request: + # allow triggering tests, ignores skip check + workflow_dispatch: jobs: pre_job: @@ -11,11 +19,12 @@ jobs: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 with: + # don't run on documentation changes paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]' # cancel previous builds if a new commit is pushed - cancel_others: 'true' - # only run on push *or* pull_request, not both - concurrent_skipping: 'same_content_newer' + # but never cancel main + cancel_others: ${{ github.ref != 'refs/heads/main' }} + pre_docs_job: runs-on: ubuntu-latest outputs: @@ -24,15 +33,16 @@ jobs: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 with: + # don't run on readme changes paths_ignore: '["**/README.md"]' # cancel previous builds if a new commit is pushed - cancel_others: 'true' - # only run on push *or* pull_request, not both - concurrent_skipping: 'same_content_newer' + # but never cancel main + cancel_others: ${{ github.ref != 'refs/heads/main' }} build-yosys: name: Reusable build runs-on: ${{ matrix.os }} + # pre_job is a subset of pre_docs_job, so we can always build for pre_docs_job needs: pre_docs_job if: needs.pre_docs_job.outputs.should_skip != 'true' env: @@ -40,7 +50,6 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - sanitizer: [undefined, address] fail-fast: false steps: - name: Checkout Yosys @@ -58,7 +67,6 @@ jobs: mkdir build cd build make -f ../Makefile config-$CC - echo 'SANITIZER = ${{ matrix.sanitizer }}' >> Makefile.conf make -f ../Makefile -j$procs ENABLE_LTO=1 - name: Log yosys-config output @@ -74,7 +82,7 @@ jobs: - name: Store build artifact uses: actions/upload-artifact@v4 with: - name: build-${{ matrix.os }}-${{ matrix.sanitizer }} + name: build-${{ matrix.os }} path: build.tar retention-days: 1 @@ -85,12 +93,9 @@ jobs: if: needs.pre_job.outputs.should_skip != 'true' env: CC: clang - ASAN_OPTIONS: halt_on_error=1 - UBSAN_OPTIONS: halt_on_error=1 strategy: matrix: os: [ubuntu-latest, macos-latest] - sanitizer: [undefined, address] fail-fast: false steps: - name: Checkout Yosys @@ -139,7 +144,7 @@ jobs: - name: Download build artifact uses: actions/download-artifact@v4 with: - name: build-${{ matrix.os }}-${{ matrix.sanitizer }} + name: build-${{ matrix.os }} - name: Uncompress build shell: bash @@ -209,7 +214,6 @@ jobs: strategy: matrix: os: [ubuntu-latest] - sanitizer: [undefined, address] fail-fast: false steps: - name: Checkout Yosys @@ -223,7 +227,7 @@ jobs: - name: Download build artifact uses: actions/download-artifact@v4 with: - name: build-${{ matrix.os }}-${{ matrix.sanitizer }} + name: build-${{ matrix.os }} - name: Uncompress build shell: bash diff --git a/.github/workflows/test-compile.yml b/.github/workflows/test-compile.yml index 7a706e69a..f208b911a 100644 --- a/.github/workflows/test-compile.yml +++ b/.github/workflows/test-compile.yml @@ -1,6 +1,14 @@ name: Compiler testing -on: [push, pull_request] +on: + # always test main + push: + branches: + - main + # test PRs + pull_request: + # allow triggering tests, ignores skip check + workflow_dispatch: jobs: pre_job: @@ -11,11 +19,11 @@ jobs: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 with: + # don't run on documentation changes paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]' # cancel previous builds if a new commit is pushed - cancel_others: 'true' - # only run on push *or* pull_request, not both - concurrent_skipping: 'same_content_newer' + # but never cancel main + cancel_others: ${{ github.ref != 'refs/heads/main' }} test-compile: runs-on: ${{ matrix.os }} diff --git a/.github/workflows/test-sanitizers.yml b/.github/workflows/test-sanitizers.yml new file mode 100644 index 000000000..fb76d1266 --- /dev/null +++ b/.github/workflows/test-sanitizers.yml @@ -0,0 +1,105 @@ +name: Check clang sanitizers + +on: + # always test main + push: + branches: + - main + # ignore PRs due to time needed + # allow triggering tests, ignores skip check + workflow_dispatch: + +jobs: + pre_job: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@v5 + with: + # don't run on documentation changes + paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]' + + run_san: + name: Build and run tests + runs-on: ${{ matrix.os }} + needs: pre_job + if: needs.pre_job.outputs.should_skip != 'true' + env: + CC: clang + ASAN_OPTIONS: halt_on_error=1 + UBSAN_OPTIONS: halt_on_error=1 + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + sanitizer: ['undefined,address'] + fail-fast: false + steps: + - name: Checkout Yosys + uses: actions/checkout@v4 + with: + submodules: true + persist-credentials: false + + - name: Setup environment + uses: ./.github/actions/setup-build-env + + - name: Build + shell: bash + run: | + mkdir build + cd build + make -f ../Makefile config-$CC + echo 'SANITIZER = ${{ matrix.sanitizer }}' >> Makefile.conf + make -f ../Makefile -j$procs ENABLE_LTO=1 + + - name: Log yosys-config output + run: | + ./yosys-config || true + + - name: Get iverilog + shell: bash + run: | + git clone https://github.com/steveicarus/iverilog.git + cd iverilog + echo "IVERILOG_GIT=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Get vcd2fst + shell: bash + run: | + git clone https://github.com/mmicko/libwave.git + mkdir -p ${{ github.workspace }}/.local/ + cd libwave + cmake . -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/.local + make -j$procs + make install + + - name: Cache iverilog + id: cache-iverilog + uses: actions/cache@v4 + with: + path: .local/ + key: ${{ matrix.os }}-${IVERILOG_GIT} + + - name: Build iverilog + if: steps.cache-iverilog.outputs.cache-hit != 'true' + shell: bash + run: | + mkdir -p ${{ github.workspace }}/.local/ + cd iverilog + autoconf + CC=gcc CXX=g++ ./configure --prefix=${{ github.workspace }}/.local + make -j$procs + make install + + - name: Run tests + shell: bash + run: | + make -j$procs test TARGETS= EXTRA_TARGETS= CONFIG=$CC + + - name: Report errors + if: ${{ failure() }} + shell: bash + run: | + find tests/**/*.err -print -exec cat {} \; diff --git a/.github/workflows/test-verific.yml b/.github/workflows/test-verific.yml index 013c9f8ca..9af07b920 100644 --- a/.github/workflows/test-verific.yml +++ b/.github/workflows/test-verific.yml @@ -1,6 +1,14 @@ name: Build and run tests with Verific (Linux) -on: [push, pull_request] +on: + # always test main + push: + branches: + - main + # test PRs + pull_request: + # allow triggering tests, ignores skip check + workflow_dispatch: jobs: pre-job: @@ -11,11 +19,11 @@ jobs: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 with: + # don't run on documentation changes paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]' # cancel previous builds if a new commit is pushed - cancel_others: 'true' - # only run on push *or* pull_request, not both - concurrent_skipping: 'same_content_newer' + # but never cancel main + cancel_others: ${{ github.ref != 'refs/heads/main' }} test-verific: needs: pre-job From b42be1df80470eba66ebb1e120379c44edf89652 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 19 Aug 2025 10:40:42 +1200 Subject: [PATCH 2/6] ci: Fix test-cells --- .github/workflows/test-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index f44dee1ba..acc295f4a 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -176,7 +176,6 @@ jobs: strategy: matrix: os: [ubuntu-latest] - sanitizer: [undefined] steps: - name: Checkout Yosys uses: actions/checkout@v4 @@ -189,7 +188,7 @@ jobs: - name: Download build artifact uses: actions/download-artifact@v4 with: - name: build-${{ matrix.os }}-${{ matrix.sanitizer }} + name: build-${{ matrix.os }} - name: Uncompress build shell: bash From d63f43acf0c532b6c0f04e41f873f9c7dec18dd9 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 19 Aug 2025 10:46:02 +1200 Subject: [PATCH 3/6] ci: iverilog before yosys --- .github/workflows/test-sanitizers.yml | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-sanitizers.yml b/.github/workflows/test-sanitizers.yml index fb76d1266..d4dfb9d84 100644 --- a/.github/workflows/test-sanitizers.yml +++ b/.github/workflows/test-sanitizers.yml @@ -45,19 +45,6 @@ jobs: - name: Setup environment uses: ./.github/actions/setup-build-env - - name: Build - shell: bash - run: | - mkdir build - cd build - make -f ../Makefile config-$CC - echo 'SANITIZER = ${{ matrix.sanitizer }}' >> Makefile.conf - make -f ../Makefile -j$procs ENABLE_LTO=1 - - - name: Log yosys-config output - run: | - ./yosys-config || true - - name: Get iverilog shell: bash run: | @@ -93,6 +80,24 @@ jobs: make -j$procs make install + - name: Check iverilog + shell: bash + run: | + iverilog -V + + - name: Build + shell: bash + run: | + mkdir build + cd build + make -f ../Makefile config-$CC + echo 'SANITIZER = ${{ matrix.sanitizer }}' >> Makefile.conf + make -f ../Makefile -j$procs ENABLE_LTO=1 + + - name: Log yosys-config output + run: | + ./yosys-config || true + - name: Run tests shell: bash run: | From 94d07872e6b29b72c91eb673d30208f9235fa5e5 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 19 Aug 2025 11:12:11 +1200 Subject: [PATCH 4/6] test-sanitizers.yml: Build in-tree Should fix missing `../../yosys-abc` --- .github/workflows/test-sanitizers.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-sanitizers.yml b/.github/workflows/test-sanitizers.yml index d4dfb9d84..5639f6286 100644 --- a/.github/workflows/test-sanitizers.yml +++ b/.github/workflows/test-sanitizers.yml @@ -88,11 +88,9 @@ jobs: - name: Build shell: bash run: | - mkdir build - cd build - make -f ../Makefile config-$CC + make config-$CC echo 'SANITIZER = ${{ matrix.sanitizer }}' >> Makefile.conf - make -f ../Makefile -j$procs ENABLE_LTO=1 + make -j$procs ENABLE_LTO=1 - name: Log yosys-config output run: | From 1cdf058df476d413bbdd486541a9cd1da426dbbd Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 19 Aug 2025 11:02:34 +1200 Subject: [PATCH 5/6] ci: Fix iverilog version caching --- .github/workflows/test-build.yml | 5 +++-- .github/workflows/test-sanitizers.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index acc295f4a..16ad98bec 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -107,11 +107,12 @@ jobs: uses: ./.github/actions/setup-build-env - name: Get iverilog + id: get-iverilog shell: bash run: | git clone https://github.com/steveicarus/iverilog.git cd iverilog - echo "IVERILOG_GIT=$(git rev-parse HEAD)" >> $GITHUB_ENV + echo "IVERILOG_GIT=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Get vcd2fst shell: bash @@ -128,7 +129,7 @@ jobs: uses: actions/cache@v4 with: path: .local/ - key: ${{ matrix.os }}-${IVERILOG_GIT} + key: ${{ matrix.os }}-${{ steps.get-iverilog.outputs.IVERILOG_GIT }} - name: Build iverilog if: steps.cache-iverilog.outputs.cache-hit != 'true' diff --git a/.github/workflows/test-sanitizers.yml b/.github/workflows/test-sanitizers.yml index 5639f6286..255b9daa5 100644 --- a/.github/workflows/test-sanitizers.yml +++ b/.github/workflows/test-sanitizers.yml @@ -46,11 +46,12 @@ jobs: uses: ./.github/actions/setup-build-env - name: Get iverilog + id: get-iverilog shell: bash run: | git clone https://github.com/steveicarus/iverilog.git cd iverilog - echo "IVERILOG_GIT=$(git rev-parse HEAD)" >> $GITHUB_ENV + echo "IVERILOG_GIT=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Get vcd2fst shell: bash @@ -67,7 +68,7 @@ jobs: uses: actions/cache@v4 with: path: .local/ - key: ${{ matrix.os }}-${IVERILOG_GIT} + key: ${{ matrix.os }}-${{ steps.get-iverilog.outputs.IVERILOG_GIT }} - name: Build iverilog if: steps.cache-iverilog.outputs.cache-hit != 'true' From 3ca2b7951fb35f1714a4b2dbb69f8e199ea94997 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 19 Aug 2025 17:05:51 +1200 Subject: [PATCH 6/6] memlib: Fix ubsan --- passes/memory/memlib.cc | 2 +- passes/memory/memlib.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/passes/memory/memlib.cc b/passes/memory/memlib.cc index 8a7adc9ac..3a8c3c06e 100644 --- a/passes/memory/memlib.cc +++ b/passes/memory/memlib.cc @@ -878,7 +878,7 @@ struct Parser { } } } - var.clk_en = find_single_cap(pdef.clken, cram.options, portopts, "clken"); + var.clk_en = find_single_cap(pdef.clken, cram.options, portopts, "clken") != nullptr; } const PortWidthDef *wdef = find_single_cap(pdef.width, cram.options, portopts, "width"); if (wdef) { diff --git a/passes/memory/memlib.h b/passes/memory/memlib.h index 43dec7386..7394baf4e 100644 --- a/passes/memory/memlib.h +++ b/passes/memory/memlib.h @@ -109,7 +109,7 @@ struct PortVariant { PortKind kind; int clk_shared; ClkPolKind clk_pol; - bool clk_en; + bool clk_en = false; bool width_tied; int min_wr_wide_log2; int max_wr_wide_log2;