Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
65 changes: 48 additions & 17 deletions core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,61 @@ 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",
"-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",
srcs = ["instrument-hooks/dist/core.c"],
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"],
)
Expand Down
48 changes: 38 additions & 10 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,60 @@ 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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/instrument-hooks/includes>
$<BUILD_INTERFACE:${instrument_hooks_SOURCE_DIR}/includes>
$<INSTALL_INTERFACE:includes>
)

# 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
-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(
Expand Down Expand Up @@ -72,7 +100,7 @@ add_compile_definitions(CODSPEED_VERSION="${CODSPEED_VERSION}")
target_include_directories(
codspeed
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/instrument-hooks/includes>
$<BUILD_INTERFACE:${instrument_hooks_SOURCE_DIR}/includes>
)

# Disable valgrind compilation errors
Expand Down
Loading