tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: macOS clang has enabled -Werror=implicit-int



On 11 Mar 2024, at 14:37, Amitai Schleier wrote:

The recent yacc-shave thread was about a problem introduced only with the latest macOS Command Line Tools, not with the latest full Xcode. We've solved that well enough for the moment in pkgsrc-current.

This thread is about a problem that I believe exists in both. Yay!
[...]
We can't handle this case the exact same way, unfortunately, because -Werror=implicit-int doesn't show up in `clang -###` output.

Same goes for int-conversion and incompatible-pointer-types (example: print/ghostscript-agpl without patches/patch-pdf_pdf__sec.c).

Given the impending freeze, barring objections or easy improvements, I plan to commit the following workaround in the next couple days.

Post-freeze we can certainly revisit whether this is sufficiently livably implemented. That'd also be a good time to find out the extent of the damage these new defaults wold actually cause.

- Amitai

Index: mk/compiler/clang.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/compiler/clang.mk,v
retrieving revision 1.42
diff -u -p -r1.42 clang.mk
--- mk/compiler/clang.mk	18 Oct 2023 08:48:51 -0000	1.42
+++ mk/compiler/clang.mk	17 Mar 2024 16:04:43 -0000
@@ -80,15 +80,30 @@ CWRAPPERS_PREPEND.cc+=	-Qunused-argument
 _WRAP_EXTRA_ARGS.CXX+=	-Qunused-arguments
 CWRAPPERS_APPEND.cxx+=	-Qunused-arguments

-# Xcode 12 has a zealous new default. Turn it off until we're ready,
-# while allowing callers (or users, via CFLAGS/CPPFLAGS) to override.
-.if ${OPSYS} == "Darwin"
-_NOERROR_IMPLICIT_cmd=	${CCPATH} -\#\#\# -E -x c /dev/null 2>&1 \
+# Xcode 12 and upstream Clang 16 have a zealous new default that the
+# wide world of random third-party software isn't ready for. Turn it
+# back off by default.
+# Packages and users can override via CFLAGS/CPPFLAGS.
+_NOERROR_IMPLICIT_cmd=	${CCPATH} -\#\#\# -E -x c /dev/null \
+			2>&1 \
 			| ${GREP} -q Werror=implicit-function-declaration \
 			&& ${ECHO} -Wno-error=implicit-function-declaration \
 			|| ${TRUE}
 CWRAPPERS_PREPEND.cc+=	${_NOERROR_IMPLICIT_cmd:sh}
-.endif
+
+# Xcode 15 (Apple clang-1500.3.9.4) and upstream Clang 16 have several
+# more zealous new defaults. We can't default them off as precisely
+# (they don't show up in `clang -###` output), so we simply attempt to
+# turn them off for any clang that doesn't complain when we try.
+# Packages and users can override via CFLAGS/CPPFLAGS.
+_WERROR_CLANG16= implicit-int int-conversion incompatible-pointer-types
+_NOERROR_CLANG16_cmd=   for _warn_ in ${_WERROR_CLANG16}; do \
+ ${CCPATH} -\#\#\# -Wno-error=$${_warn_} -x c /dev/null \
+                        >/dev/null 2>&1 \
+                        && ${ECHO} -Wno-error=$${_warn_} \
+                        || ${TRUE}; \
+                        done
+CWRAPPERS_PREPEND.cc+=  ${_NOERROR_CLANG16_cmd:sh}

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


Home | Main Index | Thread Index | Old Index