@@ -51,8 +51,11 @@ CWARNFLAGS+= -Werror
51
51
CWARNFLAGS+ = -Wall -Wno-format-y2k
52
52
.endif # WARNS >= 2
53
53
.if ${WARNS} >= 3
54
- CWARNFLAGS+ = -W -Wno-unused-parameter -Wstrict-prototypes\
55
- -Wmissing-prototypes -Wpointer-arith
54
+ CWARNFLAGS+ = -W -Wno-unused-parameter
55
+ .if ${COMPILER_TYPE} == "clang"
56
+ CWARNFLAGS+ = -Wstrict-prototypes
57
+ .endif
58
+ CWARNFLAGS+ = -Wmissing-prototypes -Wpointer-arith
56
59
.endif # WARNS >= 3
57
60
.if ${WARNS} >= 4
58
61
CWARNFLAGS+ = -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\
@@ -62,7 +65,7 @@ CWARNFLAGS+= -Wcast-align
62
65
.endif # !NO_WCAST_ALIGN !NO_WCAST_ALIGN.${COMPILER_TYPE}
63
66
.endif # WARNS >= 4
64
67
.if ${WARNS} >= 6
65
- CWARNFLAGS+ = -Wchar-subscripts -Winline - Wnested-externs \
68
+ CWARNFLAGS+ = -Wchar-subscripts -Wnested-externs \
66
69
-Wold-style-definition
67
70
.if !defined(NO_WMISSING_VARIABLE_DECLARATIONS)
68
71
CWARNFLAGS.clang+ = -Wmissing-variable-declarations
@@ -77,42 +80,26 @@ CWARNFLAGS.clang+= -Wthread-safety
77
80
CWARNFLAGS+ = -Wno-uninitialized
78
81
.endif # WARNS >=2 && WARNS <= 4
79
82
CWARNFLAGS+ = -Wno-pointer-sign
83
+ .if !defined(NO_WDATE_TIME)
84
+ CWARNFLAGS+ = -Wdate-time
85
+ .endif # NO_WDATE_TIME
80
86
# Clang has more warnings enabled by default, and when using -Wall, so if WARNS
81
87
# is set to low values, these have to be disabled explicitly.
82
88
.if ${WARNS} <= 6
83
89
CWARNFLAGS.clang+ = -Wno-empty-body -Wno-string-plus-int
84
- .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30400
85
90
CWARNFLAGS.clang+ = -Wno-unused-const-variable
86
- .endif
87
- .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 130000
88
- CWARNFLAGS.clang+ = -Wno-error=unused-but-set-variable
89
- .endif
90
- .endif
91
- .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 140000
92
- NO_WBITWISE_INSTEAD_OF_LOGICAL = -Wno-bitwise-instead-of-logical
93
- .endif
94
91
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000
95
- NO_WARRAY_PARAMETER = -Wno-array-parameter
96
- NO_WSTRICT_PROTOTYPES = -Wno-strict-prototypes
97
- NO_WDEPRECATED_NON_PROTOTYPE =-Wno-deprecated-non-prototype
92
+ CWARNFLAGS.clang+ = -Wno-error=unused-but-set-parameter
98
93
.endif
99
94
.endif # WARNS <= 6
100
95
.if ${WARNS} <= 3
101
96
CWARNFLAGS.clang+ = -Wno-tautological-compare -Wno-unused-value\
102
97
-Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion
103
- .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
104
98
CWARNFLAGS.clang+ = -Wno-unused-local-typedef
105
- .endif
106
- .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 40000
107
99
CWARNFLAGS.clang+ = -Wno-address-of-packed-member
108
- .endif
109
100
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 90100
110
101
CWARNFLAGS.gcc+ = -Wno-address-of-packed-member
111
102
.endif
112
- .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 70000 && \
113
- ${MACHINE_CPUARCH} == "arm" && !${MACHINE_ARCH:Marmv[67]*}
114
- CWARNFLAGS.clang+ = -Wno-atomic-alignment
115
- .endif
116
103
.endif # WARNS <= 3
117
104
.if ${WARNS} <= 2
118
105
CWARNFLAGS.clang+ = -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter
@@ -125,9 +112,33 @@ CWARNFLAGS.clang+= -Wno-array-bounds
125
112
.endif # NO_WARRAY_BOUNDS
126
113
.if defined(NO_WMISLEADING_INDENTATION) && \
127
114
((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 100000) || \
128
- ( ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100) )
115
+ ${COMPILER_TYPE} == "gcc")
129
116
CWARNFLAGS+ = -Wno-misleading-indentation
130
117
.endif # NO_WMISLEADING_INDENTATION
118
+ .if ${COMPILER_VERSION} >= 130000
119
+ NO_WUNUSED_BUT_SET_VARIABLE = -Wno-unused-but-set-variable
120
+ .endif
121
+ .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 140000
122
+ NO_WBITWISE_INSTEAD_OF_LOGICAL = -Wno-bitwise-instead-of-logical
123
+ .endif
124
+ .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000
125
+ NO_WARRAY_PARAMETER = -Wno-array-parameter
126
+ NO_WSTRICT_PROTOTYPES = -Wno-strict-prototypes
127
+ NO_WDEPRECATED_NON_PROTOTYPE =-Wno-deprecated-non-prototype
128
+ .endif
129
+ .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50200
130
+ NO_WUNUSED_BUT_SET_VARIABLE =-Wno-unused-but-set-variable
131
+ .endif
132
+ .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 100100
133
+ NO_WZERO_LENGTH_BOUNDS = -Wno-zero-length-bounds
134
+ .endif
135
+ .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 110100
136
+ NO_WARRAY_PARAMETER = -Wno-array-parameter
137
+ .endif
138
+ .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120100
139
+ NO_WUSE_AFTER_FREE = -Wno-use-after-free
140
+ NO_WDANGLING_POINTER = -Wno-dangling-pointer
141
+ .endif
131
142
.endif # WARNS
132
143
133
144
.if defined(FORMAT_AUDIT)
@@ -137,7 +148,7 @@ WFORMAT= 1
137
148
.if ${WFORMAT} > 0
138
149
# CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
139
150
CWARNFLAGS+ = -Wformat=2 -Wno-format-extra-args
140
- .if ${WARNS} <= 3
151
+ .if ${WARNS :U0 } <= 3
141
152
CWARNFLAGS.clang+ = -Wno-format-nonliteral
142
153
.endif # WARNS <= 3
143
154
.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
@@ -149,8 +160,15 @@ CWARNFLAGS+= -Werror
149
160
CWARNFLAGS+ = -Wno-format
150
161
.endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE}
151
162
163
+ # GCC
164
+ # We should clean up warnings produced with these flags.
165
+ # They were originally added as a quick hack to enable gcc5/6.
166
+ # The base system requires at least GCC 6.4, but some ports
167
+ # use this file with older compilers. Request an exprun
168
+ # before changing these.
169
+ .if ${COMPILER_TYPE} == "gcc"
152
170
# GCC 5.2.0
153
- .if ${COMPILER_TYPE} == "gcc" && ${ COMPILER_VERSION} >= 50200
171
+ .if ${COMPILER_VERSION} >= 50200
154
172
CWARNFLAGS+ = -Wno-error=address \
155
173
-Wno-error=array-bounds \
156
174
-Wno-error=attributes \
@@ -160,17 +178,15 @@ CWARNFLAGS+= -Wno-error=address \
160
178
-Wno-error=deprecated-declarations \
161
179
-Wno-error=enum-compare \
162
180
-Wno-error=extra \
163
- -Wno-error=inline \
164
181
-Wno-error=logical-not-parentheses \
165
182
-Wno-error=strict-aliasing \
166
183
-Wno-error=uninitialized \
167
- -Wno-error=unused-but-set-variable \
168
184
-Wno-error=unused-function \
169
185
-Wno-error=unused-value
170
186
.endif
171
187
172
188
# GCC 6.1.0
173
- .if ${COMPILER_TYPE} == "gcc" && ${ COMPILER_VERSION} >= 60100
189
+ .if ${COMPILER_VERSION} >= 60100
174
190
CWARNFLAGS+ = -Wno-error=empty-body \
175
191
-Wno-error=maybe-uninitialized \
176
192
-Wno-error=nonnull-compare \
@@ -180,7 +196,7 @@ CWARNFLAGS+= -Wno-error=empty-body \
180
196
.endif
181
197
182
198
# GCC 7.1.0
183
- .if ${COMPILER_TYPE} == "gcc" && ${ COMPILER_VERSION} >= 70100
199
+ .if ${COMPILER_VERSION} >= 70100
184
200
CWARNFLAGS+ = -Wno-error=bool-operation \
185
201
-Wno-error=deprecated \
186
202
-Wno-error=expansion-to-defined \
@@ -196,7 +212,7 @@ CWARNFLAGS+= -Wno-error=bool-operation \
196
212
.endif
197
213
198
214
# GCC 8.1.0
199
- .if ${COMPILER_TYPE} == "gcc" && ${ COMPILER_VERSION} >= 80100
215
+ .if ${COMPILER_VERSION} >= 80100
200
216
CWARNFLAGS+ = -Wno-error=aggressive-loop-optimizations \
201
217
-Wno-error=cast-function-type \
202
218
-Wno-error=catch-value \
@@ -206,11 +222,37 @@ CWARNFLAGS+= -Wno-error=aggressive-loop-optimizations \
206
222
-Wno-error=stringop-truncation
207
223
.endif
208
224
209
- .if ${COMPILER_TYPE} == "gcc"
225
+ # GCC 9.2.0
226
+ .if ${COMPILER_VERSION} >= 90200
227
+ .if ${MACHINE_ARCH} == "i386"
228
+ CWARNFLAGS+ = -Wno-error=overflow
229
+ .endif
230
+ .endif
231
+
232
+ # GCC 12.1.0
233
+ .if ${COMPILER_VERSION} >= 120100
234
+ # These warnings are raised by headers in libc++ so are disabled
235
+ # globally for all C++
236
+ CXXWARNFLAGS+ = -Wno-literal-suffix \
237
+ -Wno-error=unknown-pragmas
238
+ .endif
239
+
240
+ # GCC 13.1.0
241
+ .if ${COMPILER_VERSION} >= 130100
242
+ # These warnings are raised by headers in libc++ so are disabled
243
+ # globally for all C++
244
+ CXXWARNFLAGS+ = -Wno-dangling-reference
245
+ .endif
246
+
210
247
# GCC produces false positives for functions that switch on an
211
248
# enum (GCC bug 87950)
212
249
CWARNFLAGS+ = -Wno-return-type
250
+
251
+ # GCC's own arm_neon.h triggers various warnings
252
+ .if ${MACHINE_CPUARCH} == "aarch64"
253
+ CWARNFLAGS+ = -Wno-system-headers
213
254
.endif
255
+ .endif # gcc
214
256
215
257
# How to handle MidnightBSD custom printf format specifiers.
216
258
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
@@ -226,20 +268,27 @@ CWARNFLAGS+= -Wno-unknown-pragmas
226
268
# This warning is utter nonsense
227
269
CFLAGS+ = -Wno-format-zero-length
228
270
271
+ .if ${COMPILER_TYPE} == "clang"
272
+ # The headers provided by clang are incompatible with the FreeBSD headers.
273
+ # If the version of clang is not one that has been patched to omit the
274
+ # incompatible headers, we need to compile with -nobuiltininc and add the
275
+ # resource dir to the end of the search paths. This ensures that headers such as
276
+ # immintrin.h are still found but stddef.h, etc. are picked up from FreeBSD.
277
+ #
278
+ # XXX: This is a hack to support complete external installs of clang while
279
+ # we work to synchronize our decleration guards with those in the clang tree.
280
+ .if ${MK_CLANG_BOOTSTRAP :Uno} == "no" && \
281
+ ${COMPILER_RESOURCE_DIR} != "unknown" && !defined(BOOTSTRAPPING)
282
+ CFLAGS+ =-nobuiltininc -idirafter ${COMPILER_RESOURCE_DIR}/include
283
+ .endif
284
+ .endif
285
+
229
286
CLANG_OPT_SMALL = -mstack-alignment=8 -mllvm -inline-threshold=3
230
287
.if ${COMPILER_VERSION} < 130000
231
288
CLANG_OPT_SMALL+ = -mllvm -simplifycfg-dup-ret
232
289
.endif
233
- .if ${COMPILER_VERSION} >= 30500 && ${COMPILER_VERSION} < 30700
234
- CLANG_OPT_SMALL+ = -mllvm -enable-gvn=false
235
- .else
236
290
CLANG_OPT_SMALL+ = -mllvm -enable-load-pre=false
237
- .endif
238
291
CFLAGS.clang+ = -Qunused-arguments
239
- .if ${MACHINE_CPUARCH} == "sparc64"
240
- # Don't emit .cfi directives, since we must use GNU as on sparc64, for now.
241
- CFLAGS.clang+ = -fno-dwarf2-cfi-asm
242
- .endif # SPARC64
243
292
# The libc++ headers use c++11 extensions. These are normally silenced because
244
293
# they are treated as system headers, but we explicitly disable that warning
245
294
# suppression when building the base system to catch bugs in our headers.
0 commit comments