@@ -8,30 +8,60 @@ 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+ config_setting (
27+ name = "windows_strict_warnings" ,
28+ constraint_values = ["@platforms//os:windows" ],
29+ flag_values = {":strict_warnings" : "on" },
30+ )
31+
32+ # IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS)
33+ instrument_hooks_cflags = [
34+ "-Wno-format-security" ,
35+ "-Wno-unused-but-set-variable" ,
36+ "-Wno-unused-const-variable" ,
37+ "-Wno-type-limits" ,
38+ "-Wno-uninitialized" ,
39+ # When cross-compiling:
40+ "-Wno-constant-conversion" ,
41+ "-Wno-incompatible-pointer-types" ,
42+ "-Wno-unused-function" ,
43+ ]
44+
45+ instrument_hooks_cflags_windows = [
46+ "/wd4101" , # unreferenced local variable (equivalent to -Wno-unused-variable)
47+ "/wd4189" , # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
48+ "/wd4100" , # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
49+ "/wd4245" , # signed/unsigned mismatch
50+ "/wd4132" , # const object should be initialized
51+ "/wd4146" , # unary minus operator applied to unsigned type
52+ ]
53+
1154# Instrument-hooks library with warning suppressions
1255cc_library (
1356 name = "instrument_hooks" ,
1457 srcs = ["instrument-hooks/dist/core.c" ],
1558 hdrs = glob (["instrument-hooks/includes/*.h" ]),
1659 includes = ["instrument-hooks/includes" ],
1760 copts = select ({
18- ":windows" : [
19- "/wd4101" , # unreferenced local variable (equivalent to -Wno-unused-variable)
20- "/wd4189" , # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
21- "/wd4100" , # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
22- "/wd4245" , # signed/unsigned mismatch
23- "/wd4132" , # const object should be initialized
24- "/wd4146" , # unary minus operator applied to unsigned type
25- ],
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- ],
61+ ":windows_strict_warnings" : ["/W4" ,"/WX" ] + instrument_hooks_cflags_windows ,
62+ ":windows" : instrument_hooks_cflags_windows ,
63+ ":strict_warnings_enabled" : ["-Wall" , "-Werror" ] + instrument_hooks_cflags ,
64+ "//conditions:default" : instrument_hooks_cflags ,
3565 }),
3666 visibility = ["//visibility:public" ],
3767)
0 commit comments