Skip to content

Commit 48ecee4

Browse files
committed
rework
1 parent 8b9e735 commit 48ecee4

File tree

1 file changed

+89
-40
lines changed

1 file changed

+89
-40
lines changed

share/mk/bsd.sys.mk

Lines changed: 89 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ CWARNFLAGS+= -Werror
5151
CWARNFLAGS+= -Wall -Wno-format-y2k
5252
.endif # WARNS >= 2
5353
.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
5659
.endif # WARNS >= 3
5760
.if ${WARNS} >= 4
5861
CWARNFLAGS+= -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\
@@ -62,7 +65,7 @@ CWARNFLAGS+= -Wcast-align
6265
.endif # !NO_WCAST_ALIGN !NO_WCAST_ALIGN.${COMPILER_TYPE}
6366
.endif # WARNS >= 4
6467
.if ${WARNS} >= 6
65-
CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs \
68+
CWARNFLAGS+= -Wchar-subscripts -Wnested-externs \
6669
-Wold-style-definition
6770
.if !defined(NO_WMISSING_VARIABLE_DECLARATIONS)
6871
CWARNFLAGS.clang+= -Wmissing-variable-declarations
@@ -77,42 +80,26 @@ CWARNFLAGS.clang+= -Wthread-safety
7780
CWARNFLAGS+= -Wno-uninitialized
7881
.endif # WARNS >=2 && WARNS <= 4
7982
CWARNFLAGS+= -Wno-pointer-sign
83+
.if !defined(NO_WDATE_TIME)
84+
CWARNFLAGS+= -Wdate-time
85+
.endif # NO_WDATE_TIME
8086
# Clang has more warnings enabled by default, and when using -Wall, so if WARNS
8187
# is set to low values, these have to be disabled explicitly.
8288
.if ${WARNS} <= 6
8389
CWARNFLAGS.clang+= -Wno-empty-body -Wno-string-plus-int
84-
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30400
8590
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
9491
.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
9893
.endif
9994
.endif # WARNS <= 6
10095
.if ${WARNS} <= 3
10196
CWARNFLAGS.clang+= -Wno-tautological-compare -Wno-unused-value\
10297
-Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion
103-
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
10498
CWARNFLAGS.clang+= -Wno-unused-local-typedef
105-
.endif
106-
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 40000
10799
CWARNFLAGS.clang+= -Wno-address-of-packed-member
108-
.endif
109100
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 90100
110101
CWARNFLAGS.gcc+= -Wno-address-of-packed-member
111102
.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
116103
.endif # WARNS <= 3
117104
.if ${WARNS} <= 2
118105
CWARNFLAGS.clang+= -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter
@@ -125,9 +112,33 @@ CWARNFLAGS.clang+= -Wno-array-bounds
125112
.endif # NO_WARRAY_BOUNDS
126113
.if defined(NO_WMISLEADING_INDENTATION) && \
127114
((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 100000) || \
128-
(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100))
115+
${COMPILER_TYPE} == "gcc")
129116
CWARNFLAGS+= -Wno-misleading-indentation
130117
.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
131142
.endif # WARNS
132143

133144
.if defined(FORMAT_AUDIT)
@@ -137,7 +148,7 @@ WFORMAT= 1
137148
.if ${WFORMAT} > 0
138149
#CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
139150
CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args
140-
.if ${WARNS} <= 3
151+
.if ${WARNS:U0} <= 3
141152
CWARNFLAGS.clang+= -Wno-format-nonliteral
142153
.endif # WARNS <= 3
143154
.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
@@ -149,8 +160,15 @@ CWARNFLAGS+= -Werror
149160
CWARNFLAGS+= -Wno-format
150161
.endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE}
151162

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"
152170
# GCC 5.2.0
153-
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50200
171+
.if ${COMPILER_VERSION} >= 50200
154172
CWARNFLAGS+= -Wno-error=address \
155173
-Wno-error=array-bounds \
156174
-Wno-error=attributes \
@@ -160,17 +178,15 @@ CWARNFLAGS+= -Wno-error=address \
160178
-Wno-error=deprecated-declarations \
161179
-Wno-error=enum-compare \
162180
-Wno-error=extra \
163-
-Wno-error=inline \
164181
-Wno-error=logical-not-parentheses \
165182
-Wno-error=strict-aliasing \
166183
-Wno-error=uninitialized \
167-
-Wno-error=unused-but-set-variable \
168184
-Wno-error=unused-function \
169185
-Wno-error=unused-value
170186
.endif
171187

172188
# GCC 6.1.0
173-
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100
189+
.if ${COMPILER_VERSION} >= 60100
174190
CWARNFLAGS+= -Wno-error=empty-body \
175191
-Wno-error=maybe-uninitialized \
176192
-Wno-error=nonnull-compare \
@@ -180,7 +196,7 @@ CWARNFLAGS+= -Wno-error=empty-body \
180196
.endif
181197

182198
# GCC 7.1.0
183-
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 70100
199+
.if ${COMPILER_VERSION} >= 70100
184200
CWARNFLAGS+= -Wno-error=bool-operation \
185201
-Wno-error=deprecated \
186202
-Wno-error=expansion-to-defined \
@@ -196,7 +212,7 @@ CWARNFLAGS+= -Wno-error=bool-operation \
196212
.endif
197213

198214
# GCC 8.1.0
199-
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 80100
215+
.if ${COMPILER_VERSION} >= 80100
200216
CWARNFLAGS+= -Wno-error=aggressive-loop-optimizations \
201217
-Wno-error=cast-function-type \
202218
-Wno-error=catch-value \
@@ -206,11 +222,37 @@ CWARNFLAGS+= -Wno-error=aggressive-loop-optimizations \
206222
-Wno-error=stringop-truncation
207223
.endif
208224

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+
210247
# GCC produces false positives for functions that switch on an
211248
# enum (GCC bug 87950)
212249
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
213254
.endif
255+
.endif # gcc
214256

215257
# How to handle MidnightBSD custom printf format specifiers.
216258
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
@@ -226,20 +268,27 @@ CWARNFLAGS+= -Wno-unknown-pragmas
226268
# This warning is utter nonsense
227269
CFLAGS+= -Wno-format-zero-length
228270

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+
229286
CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3
230287
.if ${COMPILER_VERSION} < 130000
231288
CLANG_OPT_SMALL+= -mllvm -simplifycfg-dup-ret
232289
.endif
233-
.if ${COMPILER_VERSION} >= 30500 && ${COMPILER_VERSION} < 30700
234-
CLANG_OPT_SMALL+= -mllvm -enable-gvn=false
235-
.else
236290
CLANG_OPT_SMALL+= -mllvm -enable-load-pre=false
237-
.endif
238291
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
243292
# The libc++ headers use c++11 extensions. These are normally silenced because
244293
# they are treated as system headers, but we explicitly disable that warning
245294
# suppression when building the base system to catch bugs in our headers.

0 commit comments

Comments
 (0)