Lines Matching +full:clang +full:- +full:format

1 # SPDX-License-Identifier: GPL-2.0
10 KBUILD_CFLAGS += -Wall
11 KBUILD_CFLAGS += -Wextra
12 KBUILD_CFLAGS += -Wundef
13 KBUILD_CFLAGS += -Werror=implicit-function-declaration
14 KBUILD_CFLAGS += -Werror=implicit-int
15 KBUILD_CFLAGS += -Werror=return-type
16 KBUILD_CFLAGS += -Werror=strict-prototypes
17 KBUILD_CFLAGS += -Wno-format-security
18 KBUILD_CFLAGS += -Wno-trigraphs
19 KBUILD_CFLAGS += $(call cc-option, -Wno-frame-address)
20 KBUILD_CFLAGS += $(call cc-option, -Wno-address-of-packed-member)
21 KBUILD_CFLAGS += -Wmissing-declarations
22 KBUILD_CFLAGS += -Wmissing-prototypes
25 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
28 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
31 # The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
32 KBUILD_CFLAGS += -Wno-gnu
34 # Clang checks for overflow/truncation with '%p', while GCC does not:
36 KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow-non-kprintf)
37 KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation-non-kprintf)
39 # Clang may emit a warning when a const variable, such as the dummy variables
44 # other non-const members, or the containing object is not const so the field
47 # because -Wuninitialized will still flag when an uninitialized const variable
49 KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
53 KBUILD_CFLAGS += -Wno-main
57 KBUILD_CFLAGS += $(call cc-option, -Wno-dangling-pointer)
60 # Function array parameters should, however, be usable, but -Wvla will
61 # warn for those. Clang has no way yet to distinguish between the VLA
63 # https://github.com/llvm/llvm-project/issues/57098
65 KBUILD_CFLAGS += $(call cc-option,-Wvla-larger-than=1)
68 KBUILD_CFLAGS += -Wno-pointer-sign
72 # globally built with -Wcast-function-type.
73 KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
75 # Currently, disable -Wstringop-overflow for GCC 11, globally.
76 KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
77 KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
79 # Currently, disable -Wunterminated-string-initialization as broken
80 KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
84 # -Wno-alloc-size-larger-than would normally be used here, earlier versions
86 # warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX
93 KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
94 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
96 # Prohibit date/time macros, which would make the build non-deterministic
97 KBUILD_CFLAGS += -Werror=date-time
100 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
103 KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
106 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
108 KBUILD_CFLAGS += -Wunused
111 # W=1 - warnings which may be relevant and do not occur too often
115 KBUILD_CFLAGS += -Wmissing-format-attribute
116 KBUILD_CFLAGS += -Wmissing-include-dirs
117 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
119 KBUILD_CPPFLAGS += -Wundef
120 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
125 # Suppress them by using -Wno... except for W=1.
126 KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable)
127 KBUILD_CFLAGS += $(call cc-option, -Wno-unused-const-variable)
128 KBUILD_CFLAGS += $(call cc-option, -Wno-packed-not-aligned)
129 KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow)
131 KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation)
133 KBUILD_CFLAGS += $(call cc-option, -Wno-stringop-truncation)
135 KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang
138 # Clang before clang-16 would warn on default argument promotions.
139 ifneq ($(call clang-min-version, 160000),y)
140 # Disable -Wformat
141 KBUILD_CFLAGS += -Wno-format
142 # Then re-enable flags that were part of the -Wformat group that aren't
144 KBUILD_CFLAGS += -Wformat-extra-args -Wformat-invalid-specifier
145 KBUILD_CFLAGS += -Wformat-zero-length -Wnonnull
146 # Requires clang-12+.
147 ifeq ($(call clang-min-version, 120000),y)
148 KBUILD_CFLAGS += -Wformat-insufficient-args
151 KBUILD_CFLAGS += $(call cc-option, -Wno-pointer-to-enum-cast)
152 KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
153 KBUILD_CFLAGS += $(call cc-option, -Wno-unaligned-access)
154 KBUILD_CFLAGS += -Wno-enum-compare-conditional
160 # W=2 - warnings which occur quite often but may still be relevant
164 KBUILD_CFLAGS += -Wdisabled-optimization
165 KBUILD_CFLAGS += -Wshadow
166 KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
167 KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
169 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
173 # The following turn off the warnings enabled by -Wextra
174 KBUILD_CFLAGS += -Wno-missing-field-initializers
175 KBUILD_CFLAGS += -Wno-type-limits
176 KBUILD_CFLAGS += -Wno-shift-negative-value
179 KBUILD_CFLAGS += -Wno-enum-enum-conversion
183 KBUILD_CFLAGS += -Wno-maybe-uninitialized
189 # W=3 - more obscure warnings, can most likely be ignored
193 KBUILD_CFLAGS += -Wbad-function-cast
194 KBUILD_CFLAGS += -Wcast-align
195 KBUILD_CFLAGS += -Wcast-qual
196 KBUILD_CFLAGS += -Wconversion
197 KBUILD_CFLAGS += -Wpacked
198 KBUILD_CFLAGS += -Wpadded
199 KBUILD_CFLAGS += -Wpointer-arith
200 KBUILD_CFLAGS += -Wredundant-decls
201 KBUILD_CFLAGS += -Wsign-compare
202 KBUILD_CFLAGS += -Wswitch-default
204 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
208 # The following turn off the warnings enabled by -Wextra
209 KBUILD_CFLAGS += -Wno-sign-compare
210 KBUILD_CFLAGS += -Wno-unused-parameter
215 # W=e and CONFIG_WERROR - error out on warnings
219 KBUILD_CPPFLAGS += -Werror
220 KBUILD_AFLAGS += -Wa,--fatal-warnings
221 KBUILD_LDFLAGS += --fatal-warnings
222 KBUILD_USERCFLAGS += -Werror
223 KBUILD_USERLDFLAGS += -Wl,--fatal-warnings
224 KBUILD_RUSTFLAGS += -Dwarnings
227 # depend on CONFIG_ symbols), -Werror is disruptive and should be opted into.
228 # Only apply -Werror to hostprogs built after the initial Kconfig stage.
229 KBUILD_HOSTCFLAGS += -Werror
230 KBUILD_HOSTLDFLAGS += -Wl,--fatal-warnings
231 KBUILD_HOSTRUSTFLAGS += -Dwarnings