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