Skip to content

Commit 72da100

Browse files
committed
clang.mk: paper over new macOS and upstream defaults.
As soon as 2024Q1 branches, we should: 1. Do a bulk build with all these -Wno-error tweaks removed, so we can see how much is broken. 2. If it's "too much" breakage and we'll have to keep overriding these compiler defaults for "a while", find a way to accomplish them with fewer compiler invocations. (Some ideas: define a default FORCE_C_STD, or apply overrides keyed on CC_VERSION or similar.) Do a bulk build to make sure things continue to work as before. 3. Otherwise, fix as much as we can before 2024Q2. This will help with gcc 14 (which has many similar new defaults) as well.
1 parent 6f2e1a3 commit 72da100

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

mk/compiler/clang.mk

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: clang.mk,v 1.42 2023/10/18 08:48:51 jperkin Exp $
1+
# $NetBSD: clang.mk,v 1.43 2024/03/19 21:12:47 schmonz Exp $
22
#
33
# This is the compiler definition for the clang compiler.
44
#
@@ -80,15 +80,44 @@ CWRAPPERS_PREPEND.cc+= -Qunused-arguments
8080
_WRAP_EXTRA_ARGS.CXX+= -Qunused-arguments
8181
CWRAPPERS_APPEND.cxx+= -Qunused-arguments
8282

83-
# Xcode 12 has a zealous new default. Turn it off until we're ready,
84-
# while allowing callers (or users, via CFLAGS/CPPFLAGS) to override.
85-
.if ${OPSYS} == "Darwin"
86-
_NOERROR_IMPLICIT_cmd= ${CCPATH} -\#\#\# -E -x c /dev/null 2>&1 \
83+
# Xcode 12 and upstream Clang 16 have a zealous new default that the
84+
# wide world of random third-party software isn't ready for. Turn it
85+
# back off by default.
86+
#
87+
# Packages and users can override via CFLAGS/CPPFLAGS.
88+
_NOERROR_IMPLICIT_cmd= ${CCPATH} -\#\#\# -E -x c /dev/null \
89+
2>&1 \
8790
| ${GREP} -q Werror=implicit-function-declaration \
8891
&& ${ECHO} -Wno-error=implicit-function-declaration \
8992
|| ${TRUE}
9093
CWRAPPERS_PREPEND.cc+= ${_NOERROR_IMPLICIT_cmd:sh}
91-
.endif
94+
95+
# Xcode 15 (Apple clang-1500.3.9.4) and upstream Clang 16 have several
96+
# more zealous new defaults. We can't default them off as precisely
97+
# (they don't show up in `clang -###` output), so we simply attempt to
98+
# turn them off for any clang that doesn't complain when we try.
99+
#
100+
# Packages and users can override via CFLAGS/CPPFLAGS.
101+
#
102+
# As soon as 2024Q1 branches, we should:
103+
#
104+
# 1. Do a bulk build with all these -Wno-error tweaks removed, so we can
105+
# see how much is broken.
106+
# 2. If it's "too much" breakage and we'll have to keep overriding these
107+
# compiler defaults for "a while", find a way to accomplish them with
108+
# fewer compiler invocations. (Some ideas: define a default
109+
# FORCE_C_STD, or apply overrides keyed on CC_VERSION or similar.) Do
110+
# a bulk build to make sure things continue to work as before.
111+
# 3. Otherwise, fix as much as we can before 2024Q2. This will help with
112+
# gcc 14 (which has many similar new defaults) as well.
113+
_WERROR_CLANG16= implicit-int int-conversion incompatible-pointer-types
114+
_NOERROR_CLANG16_cmd= for _warn_ in ${_WERROR_CLANG16}; do \
115+
${CCPATH} -\#\#\# -Wno-error=$${_warn_} -x c /dev/null \
116+
>/dev/null 2>&1 \
117+
&& ${ECHO} -Wno-error=$${_warn_} \
118+
|| ${TRUE}; \
119+
done
120+
CWRAPPERS_PREPEND.cc+= ${_NOERROR_CLANG16_cmd:sh}
92121

93122
.for _version_ in ${_CXX_STD_VERSIONS}
94123
_CXX_STD_FLAG.${_version_}?= -std=${_version_}

0 commit comments

Comments
 (0)