From 02c4ce2cc49bb50fb1fec5891e9bc9af93e9403d Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Tue, 4 Aug 2026 22:48:45 -0400 Subject: [PATCH 1/5] Reduce macOS runner usage in testing-make.yml --- .github/workflows/testing-make.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/testing-make.yml b/.github/workflows/testing-make.yml index 8755309d4437..ce82e35eb153 100644 --- a/.github/workflows/testing-make.yml +++ b/.github/workflows/testing-make.yml @@ -21,7 +21,7 @@ on: - "python_bindings/**" - "pyproject.toml" - # Don't ignore uv.lock as it influences dependency resolution + - "uv.lock" - "README.md" - "CODE_OF_CONDUCT.md" @@ -58,8 +58,6 @@ jobs: steps: - uses: actions/checkout@v7 - - uses: astral-sh/setup-uv@v7 - - name: Install dependencies run: | if [ "$RUNNER_OS" = "Linux" ]; then @@ -82,30 +80,28 @@ jobs: echo "LLVM_CONFIG=$(brew --prefix "llvm@${LLVM_VERSION}")/bin/llvm-config" | tee -a "$GITHUB_ENV" fi - uv sync --group ci-base --no-install-project - echo "${GITHUB_WORKSPACE}/.venv/bin" | tee -a "$GITHUB_PATH" - echo "VIRTUAL_ENV=${GITHUB_WORKSPACE}/.venv" | tee -a "$GITHUB_ENV" echo "MAKEFLAGS=-j $(getconf _NPROCESSORS_ONLN)" | tee -a "$GITHUB_ENV" - run: make build_tests + if: runner.os != 'macOS' - run: make test_internal - if: ${{ !cancelled() }} + if: ${{ !cancelled() && runner.os != 'macOS' }} - run: make test_correctness - if: ${{ !cancelled() }} + if: ${{ !cancelled() && runner.os != 'macOS' }} - run: make test_generator - if: ${{ !cancelled() }} + if: ${{ !cancelled() && runner.os != 'macOS' }} - run: make test_error - if: ${{ !cancelled() }} + if: ${{ !cancelled() && runner.os != 'macOS' }} - run: make test_warning - if: ${{ !cancelled() }} + if: ${{ !cancelled() && runner.os != 'macOS' }} - run: make test_apps if: ${{ !cancelled() }} - run: make test_tutorial - if: ${{ !cancelled() }} + if: ${{ !cancelled() && runner.os != 'macOS' }} From 13a3369655ef0fa4302328061454074c6c326a31 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Wed, 5 Aug 2026 01:52:59 -0400 Subject: [PATCH 2/5] Port run-clang-tidy.sh to Ubuntu Co-Authored-By: Claude Sonnet 5 --- run-clang-tidy.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/run-clang-tidy.sh b/run-clang-tidy.sh index 1a6c1125c3e7..3331e79058eb 100755 --- a/run-clang-tidy.sh +++ b/run-clang-tidy.sh @@ -25,6 +25,13 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" # export CLANG_TIDY_LLVM_INSTALL_DIR=/opt/homebrew/opt/llvm@X # # Where X matches the EXPECTED_VERSION below. +# +# On Linux, Ubuntu's packaged libwabt.a isn't built with -fPIC, so it can't +# be linked into libHalide.so. This script won't build wabt for you; point +# wabt_ROOT at a wabt install built with -DCMAKE_POSITION_INDEPENDENT_CODE=ON +# (and, e.g., -DUSE_INTERNAL_SHA256=ON to avoid an OpenSSL dependency): +# +# export wabt_ROOT=/path/to/wabt/install EXPECTED_VERSION=21 @@ -44,6 +51,11 @@ if [ "$(uname)" == "Darwin" ]; then _DEFAULT_LLVM_LOCATION="/opt/homebrew/opt/llvm@$EXPECTED_VERSION" else _DEFAULT_LLVM_LOCATION="/usr/lib/llvm-$EXPECTED_VERSION" + + if [ -z "${wabt_ROOT:-}" ]; then + echo "wabt_ROOT must point to a wabt install built with -DCMAKE_POSITION_INDEPENDENT_CODE=ON on Linux." 1>&2 + exit 1 + fi fi J=$(get_thread_count) @@ -115,7 +127,7 @@ if [[ $(${CC} --version) =~ .*Homebrew.* ]]; then fi echo Configuring Halide... -cmake -S "${ROOT_DIR}" -B "${CLANG_TIDY_BUILD_DIR}" -Wno-dev -DWITH_TESTS=OFF +cmake -S "${ROOT_DIR}" -B "${CLANG_TIDY_BUILD_DIR}" -Wno-dev -DWITH_TESTS=OFF -DHalide_WASM_BACKEND=wabt [ -e "${CLANG_TIDY_BUILD_DIR}/compile_commands.json" ] From 67c3cbb224886c17e7b5f3acefc87eca44a17289 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Wed, 5 Aug 2026 01:53:06 -0400 Subject: [PATCH 3/5] Fix clang-tidy errors in tutorial lesson 09 Co-Authored-By: Claude Sonnet 5 --- tutorial/lesson_09_update_definitions.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tutorial/lesson_09_update_definitions.cpp b/tutorial/lesson_09_update_definitions.cpp index 721b20f7c460..d3f9d9fb3171 100644 --- a/tutorial/lesson_09_update_definitions.cpp +++ b/tutorial/lesson_09_update_definitions.cpp @@ -15,6 +15,7 @@ // source tree. #include "Halide.h" +#include #include // We're going to be using x86 SSE intrinsics later on in this lesson. @@ -174,7 +175,7 @@ int main() { // Check the results match: for (int y = 0; y < 100; y++) { for (int x = 0; x < 100; x++) { - if (fabs(halide_result(x, y) - c_result[y][x]) > 0.01f) { + if (std::abs(halide_result(x, y) - c_result[y][x]) > 0.01f) { printf("halide_result(%d, %d) = %f instead of %f\n", x, y, halide_result(x, y), c_result[y][x]); return -1; @@ -800,6 +801,7 @@ int main() { #endif // Run this one hundred times so we can average the timing results. + // NOLINTBEGIN for (int iters = 0; iters < 100; iters++) { #pragma omp parallel for @@ -890,6 +892,7 @@ int main() { free(clamped_storage); } } + // NOLINTEND // Skip the timing comparison if we don't have openmp // enabled. Otherwise it's unfair to C. From 9debc7276bd57b69daf0aada246ceb01d4e12bb9 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Wed, 5 Aug 2026 01:53:19 -0400 Subject: [PATCH 4/5] Move clang-tidy workflow to Ubuntu runners Co-Authored-By: Claude Sonnet 5 --- .github/workflows/clang-tidy.yml | 48 ++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 6b03f7a5207c..4ab354b926d1 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -18,20 +18,62 @@ concurrency: permissions: contents: read +env: + LLVM_VERSION: '21' + WABT_VERSION: '1.0.39' + jobs: check_clang_tidy: if: "!contains(github.event.pull_request.labels.*.name, 'skip_buildbots')" name: Check clang-tidy - runs-on: macos-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 # We intentionally don't use VCPKG here so that we get some # notification that the ecosystem is moving on without us. - name: Install clang-tidy & dependencies - run: brew install flatbuffers llvm@21 lld@21 pybind11 wabt + run: | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc + echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${LLVM_VERSION} main" | \ + sudo tee "/etc/apt/sources.list.d/llvm-${LLVM_VERSION}.list" + sudo apt-get update + sudo apt-get install -y \ + "clang-${LLVM_VERSION}" \ + "clang-tidy-${LLVM_VERSION}" \ + "clang-tools-${LLVM_VERSION}" \ + flatbuffers-compiler \ + flatbuffers-compiler-dev \ + "libclang-${LLVM_VERSION}-dev" \ + "libclang-cpp${LLVM_VERSION}-dev" \ + libflatbuffers-dev \ + "liblld-${LLVM_VERSION}-dev" \ + libjpeg-turbo8-dev \ + libpng-dev \ + "lld-${LLVM_VERSION}" \ + "llvm-${LLVM_VERSION}-dev" \ + ninja-build \ + pybind11-dev + + # Ubuntu's packaged libwabt.a isn't built with -fPIC, so it can't be + # linked into libHalide.so -- build our own instead. + - name: Build wabt + run: | + git clone --depth=1 --recurse-submodules -b "${WABT_VERSION}" \ + https://github.com/WebAssembly/wabt /tmp/wabt-src + cmake -G Ninja -S /tmp/wabt-src -B /tmp/wabt-build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DCMAKE_INSTALL_PREFIX=/opt/wabt \ + -DWITH_EXCEPTIONS=ON \ + -DBUILD_TESTS=OFF \ + -DBUILD_TOOLS=OFF \ + -DBUILD_LIBWASM=OFF \ + -DUSE_INTERNAL_SHA256=ON + cmake --build /tmp/wabt-build --target install - name: Run clang-tidy run: ./run-clang-tidy.sh env: - CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@21 + CLANG_TIDY_LLVM_INSTALL_DIR: /usr/lib/llvm-${{ env.LLVM_VERSION }} + wabt_ROOT: /opt/wabt From d3ec3846e18abe3769790c0c71416e669ecbd1e7 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Thu, 6 Aug 2026 10:03:02 -0700 Subject: [PATCH 5/5] Fix tutorial lesson 09 clang-tidy errors without NOLINT Blanket NOLINT markers are distracting in a tutorial, so fix the underlying complaints instead: - Replace the manual malloc/free of the circular buffer with a std::vector, which also removes a cast and the explicit free. - Make clamped_width a size_t so the row offsets are computed in a wide type. - Take row pointers with &clamped_storage[...], matching how the input and output rows are accessed. The remaining two complaints are inherent to the lesson, which deliberately hand-writes x86 SSE, so disable those checks for tutorials: portability-simd-intrinsics, and cppcoreguidelines-pro- type-cstyle-cast, which the top-level .clang-tidy already disables. Co-authored-by: Claude Opus 5 --- tutorial/.clang-tidy | 2 ++ tutorial/lesson_09_update_definitions.cpp | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tutorial/.clang-tidy b/tutorial/.clang-tidy index 76f1f3cbac3e..8c12a5dbd1b3 100644 --- a/tutorial/.clang-tidy +++ b/tutorial/.clang-tidy @@ -18,6 +18,7 @@ Checks: > -cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-cstyle-cast, -cppcoreguidelines-pro-type-reinterpret-cast, -cppcoreguidelines-pro-type-vararg, -hicpp-avoid-c-arrays, @@ -37,6 +38,7 @@ Checks: > -modernize-use-nodiscard, -modernize-use-trailing-return-type, -performance-enum-size, + -portability-simd-intrinsics, -readability-function-cognitive-complexity, -readability-identifier-length, -readability-isolate-declaration, diff --git a/tutorial/lesson_09_update_definitions.cpp b/tutorial/lesson_09_update_definitions.cpp index d3f9d9fb3171..39a0b0cc7389 100644 --- a/tutorial/lesson_09_update_definitions.cpp +++ b/tutorial/lesson_09_update_definitions.cpp @@ -17,6 +17,7 @@ #include "Halide.h" #include #include +#include // We're going to be using x86 SSE intrinsics later on in this lesson. #ifdef __SSE2__ @@ -801,7 +802,6 @@ int main() { #endif // Run this one hundred times so we can average the timing results. - // NOLINTBEGIN for (int iters = 0; iters < 100; iters++) { #pragma omp parallel for @@ -812,8 +812,8 @@ int main() { // (smallest power of two greater than 5). Each thread // needs its own allocation, so it must occur here. - int clamped_width = input.width() + 4; - uint8_t *clamped_storage = (uint8_t *)malloc(clamped_width * 8); + size_t clamped_width = input.width() + 4; + std::vector clamped_storage(clamped_width * 8); for (int yi = 0; yi < 32; yi++) { int y = y_base + yi; @@ -828,7 +828,7 @@ int main() { // Figure out which row of the circular buffer // we're filling in using bitmasking: uint8_t *clamped_row = - clamped_storage + (cy & 7) * clamped_width; + &clamped_storage[(cy & 7) * clamped_width]; // Figure out which row of the input we're reading // from by clamping the y coordinate: @@ -856,7 +856,7 @@ int main() { // The update step for maximum for (int max_y = y - 2; max_y <= y + 2; max_y++) { uint8_t *clamped_row = - clamped_storage + (max_y & 7) * clamped_width; + &clamped_storage[(max_y & 7) * clamped_width]; for (int max_x = x_base - 2; max_x <= x_base + 2; max_x++) { __m128i v = _mm_loadu_si128( (__m128i const *)(clamped_row + max_x + 2)); @@ -873,7 +873,7 @@ int main() { // The update step for minimum. for (int min_y = y - 2; min_y <= y + 2; min_y++) { uint8_t *clamped_row = - clamped_storage + (min_y & 7) * clamped_width; + &clamped_storage[(min_y & 7) * clamped_width]; for (int min_x = x_base - 2; min_x <= x_base + 2; min_x++) { __m128i v = _mm_loadu_si128( (__m128i const *)(clamped_row + min_x + 2)); @@ -888,11 +888,8 @@ int main() { _mm_storeu_si128((__m128i *)(output_row + x_base), spread); } } - - free(clamped_storage); } } - // NOLINTEND // Skip the timing comparison if we don't have openmp // enabled. Otherwise it's unfair to C.