Skip to content

Commit 877d9cc

Browse files
committed
fix: sync compiler flags with instrument-hooks; add strict mode
1 parent 86049c6 commit 877d9cc

File tree

2 files changed

+51
-16
lines changed

2 files changed

+51
-16
lines changed

core/BUILD

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,34 @@ config_setting(
88
constraint_values = ["@platforms//os:windows"],
99
)
1010

11+
# Strict warnings mode
12+
string_flag(
13+
name = "strict_warnings",
14+
build_setting_default = "off",
15+
values = [
16+
"off",
17+
"on",
18+
],
19+
)
20+
21+
config_setting(
22+
name = "strict_warnings_enabled",
23+
flag_values = {":strict_warnings": "on"},
24+
)
25+
26+
# IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS)
27+
instrument_hooks_cflags = [
28+
"-Wno-format-security",
29+
"-Wno-unused-but-set-variable",
30+
"-Wno-unused-const-variable",
31+
"-Wno-type-limits",
32+
"-Wno-uninitialized",
33+
# When cross-compiling:
34+
"-Wno-constant-conversion",
35+
"-Wno-incompatible-pointer-types",
36+
"-Wno-unused-function",
37+
]
38+
1139
# Instrument-hooks library with warning suppressions
1240
cc_library(
1341
name = "instrument_hooks",
@@ -23,15 +51,8 @@ cc_library(
2351
"/wd4132", # const object should be initialized
2452
"/wd4146", # unary minus operator applied to unsigned type
2553
],
26-
"//conditions:default": [
27-
"-Wno-maybe-uninitialized",
28-
"-Wno-unused-variable",
29-
"-Wno-unused-parameter",
30-
"-Wno-unused-but-set-variable",
31-
"-Wno-type-limits",
32-
"-Wno-format",
33-
"-Wno-format-security",
34-
],
54+
":strict_warnings_enabled": ["-Wall", "-Werror"] + instrument_hooks_cflags,
55+
"//conditions:default": instrument_hooks_cflags,
3556
}),
3657
visibility = ["//visibility:public"],
3758
)

core/CMakeLists.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,32 @@ target_include_directories(
3838
$<INSTALL_INTERFACE:includes>
3939
)
4040

41+
# Option to enable strict warnings (for CI builds)
42+
option(CODSPEED_STRICT_WARNINGS "Enable strict warnings" OFF)
43+
4144
# Suppress warnings for the instrument_hooks library
4245
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
46+
# IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS)
47+
set(INSTRUMENT_HOOKS_CFLAGS
48+
-Wno-format-security
49+
-Wno-unused-but-set-variable
50+
-Wno-unused-const-variable
51+
-Wno-type-limits
52+
-Wno-uninitialized
53+
# When cross-compiling:
54+
-Wno-constant-conversion
55+
-Wno-incompatible-pointer-types
56+
-Wno-unused-function
57+
)
58+
59+
if(INSTRUMENT_HOOKS_CFLAGS)
60+
list(PREPEND INSTRUMENT_HOOKS_CFLAGS -Wall -Werror)
61+
endif()
62+
4363
target_compile_options(
4464
instrument_hooks
4565
PRIVATE
46-
-Wno-maybe-uninitialized
47-
-Wno-unused-variable
48-
-Wno-unused-parameter
49-
-Wno-unused-but-set-variable
50-
-Wno-type-limits
51-
-Wno-format
52-
-Wno-format-security
66+
${INSTRUMENT_HOOKS_CFLAGS}
5367
)
5468
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
5569
target_compile_options(

0 commit comments

Comments
 (0)