From 3858403e1ce9cd4e84124922ddf79b87f88d978e Mon Sep 17 00:00:00 2001 From: not-matthias Date: Thu, 16 Oct 2025 10:55:13 +0200 Subject: [PATCH 1/7] feat(ci): check multiple bazel versions --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed3153a..5a231a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,7 @@ jobs: runner: "codspeed-macro" - codspeed-mode: "off" runner: "ubuntu-latest" + bazel-version: ["7.6.2", "8.4.2", "9.0.0-pre.20250921.2"] runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 @@ -119,6 +120,8 @@ jobs: - name: Build and run benchmarks run: | bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} + env: + USE_BAZEL_VERSION: ${{ matrix.bazel-version }} - name: Run the benchmarks uses: CodSpeedHQ/action@main From 7368608ecb2595f56588ad893d1316ee9855e67e Mon Sep 17 00:00:00 2001 From: not-matthias Date: Thu, 16 Oct 2025 17:56:14 +0200 Subject: [PATCH 2/7] fix(cmake): fetch instrument-hooks git repository --- core/CMakeLists.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 21b2639..b44a254 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -11,17 +11,30 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # Add the include directory include_directories(include) +include(FetchContent) +FetchContent_Declare( + instrument_hooks_repo + GIT_REPOSITORY https://github.com/CodSpeedHQ/instrument-hooks + GIT_TAG b1e401a4d031ad308edb22ed59a52253a1ebe924 +) +FetchContent_MakeAvailable(instrument_hooks_repo) +FetchContent_GetProperties(instrument_hooks_repo) +if(NOT instrument_hooks_repo_POPULATED) + FetchContent_Populate(instrument_hooks_repo) +endif() +set(instrument_hooks_SOURCE_DIR ${instrument_hooks_repo_SOURCE_DIR}) + # Add the instrument_hooks library add_library( instrument_hooks STATIC - instrument-hooks/dist/core.c + ${instrument_hooks_SOURCE_DIR}/dist/core.c ) target_include_directories( instrument_hooks PUBLIC - $ + $ $ ) @@ -72,7 +85,7 @@ add_compile_definitions(CODSPEED_VERSION="${CODSPEED_VERSION}") target_include_directories( codspeed PUBLIC $ - $ + $ ) # Disable valgrind compilation errors From 0b5906c62554a1887575b180c7a7bb52ea9e6934 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Fri, 17 Oct 2025 15:22:46 +0200 Subject: [PATCH 3/7] fixup: run cmake/bazel on many os --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a231a4..ed3153a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,7 +100,6 @@ jobs: runner: "codspeed-macro" - codspeed-mode: "off" runner: "ubuntu-latest" - bazel-version: ["7.6.2", "8.4.2", "9.0.0-pre.20250921.2"] runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 @@ -120,8 +119,6 @@ jobs: - name: Build and run benchmarks run: | bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} - env: - USE_BAZEL_VERSION: ${{ matrix.bazel-version }} - name: Run the benchmarks uses: CodSpeedHQ/action@main From efb7802374180112acd32239e94e51fa2c3a19a2 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Mon, 20 Oct 2025 10:53:06 +0200 Subject: [PATCH 4/7] chore: bump instrument-hooks --- core/instrument-hooks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/instrument-hooks b/core/instrument-hooks index b1e401a..b260b17 160000 --- a/core/instrument-hooks +++ b/core/instrument-hooks @@ -1 +1 @@ -Subproject commit b1e401a4d031ad308edb22ed59a52253a1ebe924 +Subproject commit b260b17f1eb5a2e292c112c9d399c9cd5b42c65c From bdbf665bfc6f7282d4fbd54267bfb118e245a34d Mon Sep 17 00:00:00 2001 From: not-matthias Date: Mon, 20 Oct 2025 10:52:18 +0200 Subject: [PATCH 5/7] fix: sync compiler flags with instrument-hooks; add strict mode --- core/BUILD | 64 +++++++++++++++++++++++++++++++++------------ core/CMakeLists.txt | 28 +++++++++++++++----- 2 files changed, 68 insertions(+), 24 deletions(-) diff --git a/core/BUILD b/core/BUILD index 1390823..a7ed603 100644 --- a/core/BUILD +++ b/core/BUILD @@ -8,6 +8,49 @@ config_setting( constraint_values = ["@platforms//os:windows"], ) +# Strict warnings mode +string_flag( + name = "strict_warnings", + build_setting_default = "off", + values = [ + "off", + "on", + ], +) + +config_setting( + name = "strict_warnings_enabled", + flag_values = {":strict_warnings": "on"}, +) + +config_setting( + name = "windows_strict_warnings", + constraint_values = ["@platforms//os:windows"], + flag_values = {":strict_warnings": "on"}, +) + +# IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS) +instrument_hooks_cflags = [ + "-Wno-format-security", + "-Wno-unused-but-set-variable", + "-Wno-unused-const-variable", + "-Wno-type-limits", + "-Wno-uninitialized", + # When cross-compiling: + "-Wno-constant-conversion", + "-Wno-incompatible-pointer-types", + "-Wno-unused-function", +] + +instrument_hooks_cflags_windows = [ + "/wd4101", # unreferenced local variable (equivalent to -Wno-unused-variable) + "/wd4189", # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable) + "/wd4100", # unreferenced formal parameter (equivalent to -Wno-unused-parameter) + "/wd4245", # signed/unsigned mismatch + "/wd4132", # const object should be initialized + "/wd4146", # unary minus operator applied to unsigned type +] + # Instrument-hooks library with warning suppressions cc_library( name = "instrument_hooks", @@ -15,23 +58,10 @@ cc_library( hdrs = glob(["instrument-hooks/includes/*.h"]), includes = ["instrument-hooks/includes"], copts = select({ - ":windows": [ - "/wd4101", # unreferenced local variable (equivalent to -Wno-unused-variable) - "/wd4189", # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable) - "/wd4100", # unreferenced formal parameter (equivalent to -Wno-unused-parameter) - "/wd4245", # signed/unsigned mismatch - "/wd4132", # const object should be initialized - "/wd4146", # unary minus operator applied to unsigned type - ], - "//conditions:default": [ - "-Wno-maybe-uninitialized", - "-Wno-unused-variable", - "-Wno-unused-parameter", - "-Wno-unused-but-set-variable", - "-Wno-type-limits", - "-Wno-format", - "-Wno-format-security", - ], + ":windows_strict_warnings": ["/W4","/WX"] + instrument_hooks_cflags_windows, + ":windows": instrument_hooks_cflags_windows, + ":strict_warnings_enabled": ["-Wall", "-Werror"] + instrument_hooks_cflags, + "//conditions:default": instrument_hooks_cflags, }), visibility = ["//visibility:public"], ) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b44a254..5149657 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -38,18 +38,32 @@ target_include_directories( $ ) +# Option to enable strict warnings (for CI builds) +option(CODSPEED_STRICT_WARNINGS "Enable strict warnings" OFF) + # Suppress warnings for the instrument_hooks library if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + # IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS) + set(INSTRUMENT_HOOKS_CFLAGS + -Wno-format-security + -Wno-unused-but-set-variable + -Wno-unused-const-variable + -Wno-type-limits + -Wno-uninitialized + # When cross-compiling: + -Wno-constant-conversion + -Wno-incompatible-pointer-types + -Wno-unused-function + ) + + if(CODSPEED_STRICT_WARNINGS) + list(PREPEND INSTRUMENT_HOOKS_CFLAGS -Wall -Werror) + endif() + target_compile_options( instrument_hooks PRIVATE - -Wno-maybe-uninitialized - -Wno-unused-variable - -Wno-unused-parameter - -Wno-unused-but-set-variable - -Wno-type-limits - -Wno-format - -Wno-format-security + ${INSTRUMENT_HOOKS_CFLAGS} ) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options( From 1e976841ed81106933bee3f119cf0bbe296e2793 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Mon, 20 Oct 2025 11:12:46 +0200 Subject: [PATCH 6/7] fix: ignore format errors --- core/BUILD | 1 + core/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/core/BUILD b/core/BUILD index a7ed603..4c91d3d 100644 --- a/core/BUILD +++ b/core/BUILD @@ -31,6 +31,7 @@ config_setting( # IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS) instrument_hooks_cflags = [ + "-Wno-format", "-Wno-format-security", "-Wno-unused-but-set-variable", "-Wno-unused-const-variable", diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 5149657..6a8c6ab 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -45,6 +45,7 @@ option(CODSPEED_STRICT_WARNINGS "Enable strict warnings" OFF) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") # IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS) set(INSTRUMENT_HOOKS_CFLAGS + -Wno-format -Wno-format-security -Wno-unused-but-set-variable -Wno-unused-const-variable From 4a4951fb1c6eeb93dbaae7c97fd5b7e3738b43b8 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Mon, 20 Oct 2025 11:12:27 +0200 Subject: [PATCH 7/7] chore(ci): enable strict warnings --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed3153a..2dfd6f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - name: Build tests run: | cd core/build-tests - cmake .. -DENABLE_TESTS=ON + cmake .. -DENABLE_TESTS=ON -DCODSPEED_STRICT_WARNINGS=ON make -j - name: Run tests @@ -79,7 +79,7 @@ jobs: - name: Build benchmark example run: | cd examples/google_benchmark_cmake/build - cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} .. + cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} -DCODSPEED_STRICT_WARNINGS=ON .. make -j - name: Run the benchmarks @@ -118,14 +118,14 @@ jobs: - name: Build and run benchmarks run: | - bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} + bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} --//core:strict_warnings=on - name: Run the benchmarks uses: CodSpeedHQ/action@main if: matrix.codspeed-mode != 'off' with: mode: ${{ matrix.codspeed-mode }} - run: bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} + run: bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} --//core:strict_warnings=on token: ${{ secrets.CODSPEED_TOKEN }} cmake-build: @@ -193,4 +193,4 @@ jobs: - name: Build benchmark example run: | - bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} + bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} --//core:strict_warnings=on