Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Apr 2021 00:46:59 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ba1182e26376 - main - bsd.compiler.mk: detect Apple Clang for cross-builds
Message-ID:  <202104200046.13K0kxqY036841@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=ba1182e26376987fe424707b2abc4d6532b28623

commit ba1182e26376987fe424707b2abc4d6532b28623
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-04-20 00:46:36 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-04-20 00:46:36 +0000

    bsd.compiler.mk: detect Apple Clang for cross-builds
    
    Apple clang uses a different versioning scheme, so if we enable or
    disable certain warnings for Clang 11+, those might not be supported
    in Apple Clang 11+. This adds 'apple-clang' to COMPILER_FEATURES, so that
    bootstrap tools Makefiles can avoid warnings on macOS.
    
    Reviewed By:    imp
    Differential Revision: https://reviews.freebsd.org/D29680
---
 share/mk/bsd.compiler.mk | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk
index 0d8f02489f00..97198f70d5b6 100644
--- a/share/mk/bsd.compiler.mk
+++ b/share/mk/bsd.compiler.mk
@@ -26,6 +26,12 @@
 #              mitigation.
 # - init-all:  supports stack variable initialization.
 #
+# When bootstrapping on macOS, 'apple-clang' will be set in COMPILER_FEATURES
+# to differentiate Apple's version of Clang. Apple Clang uses a different
+# versioning scheme and may not support the same -W/-Wno warning flags. For a
+# mapping of Apple Clang versions to upstream clang versions see
+# https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_12.x_(since_Free_On-Device_Development)
+#
 # These variables with an X_ prefix will also be provided if XCC is set.
 #
 # This file may be included multiple times, but only has effect the first time.
@@ -202,6 +208,10 @@ ${X_}COMPILER_TYPE:=	gcc
 .if !defined(${X_}COMPILER_VERSION)
 ${X_}COMPILER_VERSION!=echo "${_v:M[1-9]*.[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
 .endif
+# Detect apple clang when bootstrapping to select appropriate warning flags.
+.if !defined(${X_}COMPILER_FEATURES) && ${_v:[*]:M*Apple clang version*}
+${X_}COMPILER_FEATURES=	apple-clang
+.endif
 .undef _v
 .endif
 .if !defined(${X_}COMPILER_FREEBSD_VERSION)
@@ -218,7 +228,7 @@ ${X_}COMPILER_FREEBSD_VERSION=	unknown
 ${X_}COMPILER_RESOURCE_DIR!=	${${cc}:N${CCACHE_BIN}} -print-resource-dir 2>/dev/null || echo unknown
 .endif
 
-${X_}COMPILER_FEATURES=		c++11 c++14
+${X_}COMPILER_FEATURES+=		c++11 c++14
 .if ${${X_}COMPILER_TYPE} == "clang" || \
 	(${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 70000)
 ${X_}COMPILER_FEATURES+=	c++17



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104200046.13K0kxqY036841>