From bc397fe6c5fe556e6bb6c452c9ab81d3ae1b00bf Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 17:02:16 +0000 Subject: [PATCH 1/2] Sync TapHouse v8: tidy.sh checks each file once; STYLE.md's banner line scripts/sync.sh from TapHouse v8 (8c0e101) and the drift check's pin moved from v7 to v8 in .github/workflows/style.yml: - scripts/tidy.sh: the no-argument sweep checks each file in the compile database once (clang-tidy -p checks all of a file's compile commands in one call, so one call per entry checked a file compiled n times n^2 times), and builds its list without mapfile, so macOS bash 3.2 runs it (tap/TapHouse#14). - STYLE.md: the per-file banner template states the family's copyright line, "Copyright Timothy Place and the contributors" (tap/TapHouse#13). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf --- .github/workflows/style.yml | 4 ++-- STYLE.md | 7 +++++-- scripts/tidy.sh | 23 +++++++++++++++++------ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index bc3a602..01a6574 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -26,9 +26,9 @@ concurrency: jobs: drift: - uses: tap/taphouse/.github/workflows/drift-check.yml@v7 + uses: tap/taphouse/.github/workflows/drift-check.yml@v8 with: - ref: v7 + ref: v8 icon: PythonTap clang-format: diff --git a/STYLE.md b/STYLE.md index ebfcf54..903a0a6 100644 --- a/STYLE.md +++ b/STYLE.md @@ -91,12 +91,15 @@ greenfield `*Tap` code follows the naming rules above. - **Extension:** `.h` for headers (family-wide). - **Header guard:** `#pragma once` (first line after the banner). Universally supported by GCC/Clang/MSVC; replaces the `#ifndef`/`#define`/`#endif` triple. -- **Per-file banner:** three lines — +- **Per-file banner:** the `@file` / `@brief` pair, then the SPDX line and + the family's copyright line, which names the author and the library's + contributors (`` is the repo's name: DspTap, SampleRateTap, …; + the year is the file's) — ```cpp /// @file spsc_ring.h /// @brief Lock-free single-producer single-consumer ring buffer. // SPDX-License-Identifier: MIT - // Copyright 2025-2026 Timothy Place. + // Copyright 2026 Timothy Place and the contributors ``` - **Doc comments:** `///` triple-slash with `@`-style commands (`@param`, `@return`, `@throws`, `@pre`). Not the `\`-command dialect. diff --git a/scripts/tidy.sh b/scripts/tidy.sh index fecc294..2c590eb 100755 --- a/scripts/tidy.sh +++ b/scripts/tidy.sh @@ -46,22 +46,33 @@ if [ "${TIDY_RECONFIGURE:-0}" = "1" ] || [ ! -f "$build/compile_commands.json" ] cmake -B "$build" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON >/dev/null fi -# File list: the given TUs, or — matching CI exactly — every project TU in the -# database with third_party/ and fetched deps (_deps) excluded. +# File list: the given TUs, or — matching CI — every project TU in the +# database with third_party/ and fetched deps (_deps) excluded, each FILE once. +# `clang-tidy -p` checks every compile command the database holds for a file, +# so a source compiled several times under different -D (benchmark workloads, +# size probes) must be listed once: one entry per command checked a file +# compiled n times n^2 times (SampleRateTap's CI sweep, 40 entries for one +# workload source, ran past its 30-minute timeout; listed once, under five +# minutes). Built with a read loop, not mapfile, so macOS /bin/bash 3.2 runs +# the sweep too. +files=() if [ "$#" -gt 0 ]; then files=("$@") else - mapfile -t files < <(python3 -c " + while IFS= read -r f; do + files+=("$f") + done < <(python3 -c " import json -for e in json.load(open('$build/compile_commands.json')): - f = e['file'] +files = [e['file'] for e in json.load(open('$build/compile_commands.json'))] +for f in dict.fromkeys(files): if 'third_party' not in f and '_deps' not in f: print(f)") fi echo "== clang-tidy ($tidy) over ${#files[@]} file(s) ==" fail=0 -for f in "${files[@]}"; do +# ${files[@]+...}: an empty list under set -u is an error before bash 4.4. +for f in ${files[@]+"${files[@]}"}; do out="$("$tidy" -p "$build" "$f" 2>/dev/null || true)" # Test the captured output in-process, never through a pipe. Under pipefail, # `printf '%s\n' "$out" | grep -q …` fails whenever grep quits at its first From 5a85af22481f16973fea25035c38ba76984a49c9 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 17:27:16 +0000 Subject: [PATCH 2/2] =?UTF-8?q?CI:=20the=20glue's=20TSan=20row=20builds=20?= =?UTF-8?q?with=20Clang=20=E2=80=94=20GCC=2014+=20cannot=20under=20TSan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ubuntu-latest moved to Ubuntu 26.04 and GCC 15, and linux-max-glue (tsan) stopped compiling, on main as on every branch: "attributes are not allowed on a function-definition", 14 times in each of the glue test's two TUs, all from min-api's readerwriterqueue. min-api pins it at a500a29, whose atomicops.h asks __has_feature(thread_sanitizer) and then puts AE_NO_TSAN, __attribute__((no_sanitize("thread"))), after the declarator of function definitions: a place Clang accepts and GCC refuses. GCC had no __has_feature before 14, so under GCC 13 the macro was empty and the row built. readerwriterqueue fixed it in 5904a29; min-api's tip still pins a500a29. The macro is used on atomicops.h's own definitions too, so nothing force-included ahead of it can empty it without redefining a builtin. The row builds with Clang instead (the image has 20-22), installing Clang's sanitizer runtimes when the image lacks them (a recommends in Ubuntu, not a depends); the release and asan-ubsan rows name gcc/g++, as they ran before. Configuring the glue test for TSan with GCC 14 or later now stops with a message that says this and what to use, until the pinned atomicops.h knows __SANITIZE_THREAD__ (5904a29's test), when the check retires itself. Checked locally: GCC 14 + TSan reproduces CI's errors and now stops at configure; GCC 13 + TSan and GCC 14 + ASan/UBSan configure as before; Clang 18 + TSan builds and the glue test passes (233 assertions in 17 test cases, no TSan report); the GCC release build passes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FaMFrPxB5YeqohNoxCyuLM --- .github/workflows/build.yml | 21 +++++++++++++++++++ CLAUDE.md | 3 ++- .../projects/tap.python_tilde/CMakeLists.txt | 15 +++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a1877b..508e58a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -79,6 +79,9 @@ jobs: # The glue test under sanitizers as well (plan 9.3): tap.python's lock, and a reload racing a # message on another thread, live in the glue, which the core's battery cannot see. + # The tsan row builds with Clang: from GCC 14 on (ubuntu-latest's is 15), GCC cannot compile the + # readerwriterqueue min-api pins under TSan, which puts no_sanitize("thread") after a function's + # declarator, where only Clang accepts it. The source/projects CMakeLists says when that ends. linux-max-glue: name: linux-max-glue (${{ matrix.name }}) runs-on: ubuntu-latest @@ -89,12 +92,18 @@ jobs: - name: release build_type: Release sanitize: "" + cc: gcc + cxx: g++ - name: asan-ubsan build_type: Debug sanitize: "address,undefined" + cc: gcc + cxx: g++ - name: tsan build_type: Debug sanitize: "thread" + cc: clang + cxx: clang++ steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: @@ -113,10 +122,22 @@ jobs: if: matrix.sanitize != '' run: sudo sysctl vm.mmap_rnd_bits=28 + # Ubuntu packages Clang's sanitizer runtimes apart from Clang (a recommends, not a depends), + # so install them for the runner's default clang when the image does not have them. + - name: Install Clang's sanitizer runtimes + if: matrix.cxx == 'clang++' + run: | + v=$(clang++ -dumpversion | cut -d. -f1) + dpkg -s "libclang-rt-$v-dev" >/dev/null 2>&1 \ + || { sudo apt-get update -q && sudo apt-get install -y -q "libclang-rt-$v-dev"; } + clang++ --version | head -1 + - name: Configure run: > cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_C_COMPILER=${{ matrix.cc }} + -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DPython3_EXECUTABLE="$(which python)" -DTAP_PYTHON_SANITIZE="${{ matrix.sanitize }}" diff --git a/CLAUDE.md b/CLAUDE.md index 6240270..4d41495 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -132,7 +132,8 @@ python3 runtime-tests/run.py ``` CI (`build.yml`): `linux-core` and `linux-max-glue` (each release, asan-ubsan, tsan — the glue -test's `TAP_PYTHON_SANITIZE`, as the core's; the release row also runs `scripts/check-docs.py`), `book`, `macos` (universal + `lipo`/`otool` checks, including +test's `TAP_PYTHON_SANITIZE`, as the core's — the glue's tsan row builds with Clang, since GCC 14+ +cannot compile min-api's pinned readerwriterqueue under TSan, and configure says so; the release row also runs `scripts/check-docs.py`), `book`, `macos` (universal + `lipo`/`otool` checks, including no absolute rpath, and the package assembled, which fails without `init/tap.python.txt`), `windows`. `style.yml`: TapHouse drift check, clang-format, clang-tidy (a clang-tidy failure or crash fails the gate, not just a finding). Workflows run with `contents: read`, pin third-party actions by commit SHA (tag noted beside it), and cancel diff --git a/source/projects/tap.python_tilde/CMakeLists.txt b/source/projects/tap.python_tilde/CMakeLists.txt index b01000d..4272b4e 100644 --- a/source/projects/tap.python_tilde/CMakeLists.txt +++ b/source/projects/tap.python_tilde/CMakeLists.txt @@ -172,6 +172,21 @@ if (TAP_PYTHON_SANITIZE AND TARGET ${PROJECT_NAME}_test) # stops at in every test; the rest of UBSan stays on list(APPEND _sanitize -fno-sanitize=vptr) endif () + if (TAP_PYTHON_SANITIZE MATCHES "thread" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14) + # GCC answers __has_feature from GCC 14 on, and under TSan the readerwriterqueue min-api pins + # (a500a29) then puts no_sanitize("thread") after the declarator of function definitions, + # where only Clang accepts it (GCC 13 has no __has_feature, so the macro stayed empty). Its + # 5904a29 fixed that, and is the first to test __SANITIZE_THREAD__: until min-api pins it, + # say so here rather than in a page of compile errors. CI's tsan row builds with Clang. + file(READ "${C74_MIN_API_DIR}/include/readerwriterqueue/atomicops.h" _atomicops) + if (NOT _atomicops MATCHES "__SANITIZE_THREAD__") + message(FATAL_ERROR + "TAP_PYTHON_SANITIZE=thread: GCC ${CMAKE_CXX_COMPILER_VERSION} cannot compile the " + "readerwriterqueue min-api pins under ThreadSanitizer. Configure with Clang " + "(-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++), or GCC 13.") + endif () + endif () target_compile_options(${PROJECT_NAME}_test PRIVATE ${_sanitize} -fno-omit-frame-pointer) target_link_options(${PROJECT_NAME}_test PRIVATE ${_sanitize}) set_tests_properties(${PROJECT_NAME}_test PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0")