summaryrefslogtreecommitdiff
path: root/mk/compiler
diff options
context:
space:
mode:
authorschmonz <schmonz@pkgsrc.org>2020-09-21 13:09:21 +0000
committerschmonz <schmonz@pkgsrc.org>2020-09-21 13:09:21 +0000
commit62dfa8462fd9968886f04bbe110c0cd43c3ad445 (patch)
treeaf1e9d6524e0ccc034d7dbe5f09469025b25637e /mk/compiler
parentf780807a9a02c03d1c59b21b9ac9952fade394e5 (diff)
downloadpkgsrc-62dfa8462fd9968886f04bbe110c0cd43c3ad445.tar.gz
Xcode 12 (or its associated Command Line Tools) ships with default-on
-Werror=implicit-function-declaration, which will be great someday when we're ready for it. Until then, on macOS, detect this situation and tell the cc wrapper to prepend -Wno-error=implicit-function-declaration. Taking mail/qmail as our example, this fixes the build on Catalina with "Apple clang version 12.0.0 (clang-1200.0.32.2)". Adding -Werror=implicit-function-declaration to CPPFLAGS or CFLAGS (in mk.conf or on the command line) re-fails the build, as expected, with a pile of "error: implicit declaration of function". Also as expected, a full -Werror fails earlier on one of the many other problems with qmail's code. For clang on non-macOS platforms, no change. clang-and-wrapper-ok: joerg@ during-the-freeze-ok: gdt@
Diffstat (limited to 'mk/compiler')
-rw-r--r--mk/compiler/clang.mk12
1 files changed, 11 insertions, 1 deletions
diff --git a/mk/compiler/clang.mk b/mk/compiler/clang.mk
index b9264142741..3956bda314b 100644
--- a/mk/compiler/clang.mk
+++ b/mk/compiler/clang.mk
@@ -1,4 +1,4 @@
-# $NetBSD: clang.mk,v 1.25 2020/04/17 13:36:26 joerg Exp $
+# $NetBSD: clang.mk,v 1.26 2020/09/21 13:09:21 schmonz Exp $
#
# This is the compiler definition for the clang compiler.
#
@@ -96,6 +96,16 @@ CWRAPPERS_PREPEND.cc+= -Qunused-arguments -fcommon
_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 \
+ | ${GREP} -q Werror=implicit-function-declaration \
+ && ${ECHO} -Wno-error=implicit-function-declaration \
+ || ${TRUE}
+CWRAPPERS_PREPEND.cc+= ${_NOERROR_IMPLICIT_cmd:sh}
+.endif
+
.for _version_ in ${_CXX_STD_VERSIONS}
_CXX_STD_FLAG.${_version_}?= -std=${_version_}
.endfor