Changeset View
Standalone View
share/mk/bsd.compiler.mk
Show All 20 Lines | |||||
# | # | ||||
# - c++17: supports full (or nearly full) C++17 programming environment. | # - c++17: supports full (or nearly full) C++17 programming environment. | ||||
# - c++14: supports full (or nearly full) C++14 programming environment. | # - c++14: supports full (or nearly full) C++14 programming environment. | ||||
# - c++11: supports full (or nearly full) C++11 programming environment. | # - c++11: supports full (or nearly full) C++11 programming environment. | ||||
# - retpoline: supports the retpoline speculative execution vulnerability | # - retpoline: supports the retpoline speculative execution vulnerability | ||||
# mitigation. | # mitigation. | ||||
# - init-all: supports stack variable initialization. | # - 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. | # 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. | # This file may be included multiple times, but only has effect the first time. | ||||
# | # | ||||
.if !target(__<bsd.compiler.mk>__) | .if !target(__<bsd.compiler.mk>__) | ||||
__<bsd.compiler.mk>__: | __<bsd.compiler.mk>__: | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | |||||
.error "${.CURDIR}: Rerunning ${${cc}} --version to compute ${X_}COMPILER_TYPE/${X_}COMPILER_VERSION. This value should be cached!" | .error "${.CURDIR}: Rerunning ${${cc}} --version to compute ${X_}COMPILER_TYPE/${X_}COMPILER_VERSION. This value should be cached!" | ||||
.else | .else | ||||
# .info "${.CURDIR}: Running ${${cc}} --version to compute ${X_}COMPILER_TYPE/${X_}COMPILER_VERSION. ${cc}=${${cc}}" | # .info "${.CURDIR}: Running ${${cc}} --version to compute ${X_}COMPILER_TYPE/${X_}COMPILER_VERSION. ${cc}=${${cc}}" | ||||
.endif | .endif | ||||
_v!= ${${cc}:N${CCACHE_BIN}} --version || echo 0.0.0 | _v!= ${${cc}:N${CCACHE_BIN}} --version || echo 0.0.0 | ||||
.if !defined(${X_}COMPILER_TYPE) | .if !defined(${X_}COMPILER_TYPE) | ||||
. if ${${cc}:T:M*gcc*} | . if ${${cc}:T:M*gcc*} | ||||
${X_}COMPILER_TYPE:= gcc | ${X_}COMPILER_TYPE:= gcc | ||||
emaste: IMO we should explicitly mention Apple's versioning scheme to explain why there's a special… | |||||
Not Done Inline ActionsWikipedia has a table at https://en.wikipedia.org/wiki/Xcode#Toolchain_versions which ultimately just gets the information from Apple's Swift LLVM fork via e.g. https://github.com/apple/llvm-project/blob/swift-5.3.2-RELEASE/llvm/CMakeLists.txt. jrtc27: Wikipedia has a table at https://en.wikipedia.org/wiki/Xcode#Toolchain_versions which… | |||||
Done Inline ActionsSeems like there is a table here: https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_12.x_(since_Free_On-Device_Development) arichardson: Seems like there is a table here: https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_12.x_… | |||||
. elif ${${cc}:T:M*clang*} | . elif ${${cc}:T:M*clang*} | ||||
Not Done Inline ActionsProbably better off with an ${X_}CLANG_TYPE? Otherwise you'll have to use :M*clang in a load of places. jrtc27: Probably better off with an ${X_}CLANG_TYPE? Otherwise you'll have to use `:M*clang` in a load… | |||||
Done Inline ActionsThat could also work. I just noticed the warning that is causing issues is a CheriBSD-local diff, so we might not need this after all. arichardson: That could also work. I just noticed the warning that is causing issues is a CheriBSD-local… | |||||
${X_}COMPILER_TYPE:= clang | ${X_}COMPILER_TYPE:= clang | ||||
. elif ${_v:Mgcc} | . elif ${_v:Mgcc} | ||||
${X_}COMPILER_TYPE:= gcc | ${X_}COMPILER_TYPE:= gcc | ||||
. elif ${_v:M\(GCC\)} || ${_v:M*GNU} | . elif ${_v:M\(GCC\)} || ${_v:M*GNU} | ||||
${X_}COMPILER_TYPE:= gcc | ${X_}COMPILER_TYPE:= gcc | ||||
. elif ${_v:Mclang} || ${_v:M(clang-*.*.*)} | . elif ${_v:Mclang} || ${_v:M(clang-*.*.*)} | ||||
${X_}COMPILER_TYPE:= clang | ${X_}COMPILER_TYPE:= clang | ||||
. else | . else | ||||
# With GCC, cc --version prints "cc $VERSION ($PKGVERSION)", so if a | # With GCC, cc --version prints "cc $VERSION ($PKGVERSION)", so if a | ||||
# distribution overrides the default GCC PKGVERSION it is not identified. | # distribution overrides the default GCC PKGVERSION it is not identified. | ||||
# However, its -v output always says "gcc version" in it, so fall back on that. | # However, its -v output always says "gcc version" in it, so fall back on that. | ||||
_gcc_version!= ${${cc}:N${CCACHE_BIN}} -v 2>&1 | grep "gcc version" | _gcc_version!= ${${cc}:N${CCACHE_BIN}} -v 2>&1 | grep "gcc version" | ||||
. if !empty(_gcc_version) | . if !empty(_gcc_version) | ||||
${X_}COMPILER_TYPE:= gcc | ${X_}COMPILER_TYPE:= gcc | ||||
. else | . else | ||||
.error Unable to determine compiler type for ${cc}=${${cc}}. Consider setting ${X_}COMPILER_TYPE. | .error Unable to determine compiler type for ${cc}=${${cc}}. Consider setting ${X_}COMPILER_TYPE. | ||||
. endif | . endif | ||||
.undef _gcc_version | .undef _gcc_version | ||||
. endif | . endif | ||||
.endif | .endif | ||||
.if !defined(${X_}COMPILER_VERSION) | .if !defined(${X_}COMPILER_VERSION) | ||||
${X_}COMPILER_VERSION!=echo "${_v:M[1-9]*.[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' | ${X_}COMPILER_VERSION!=echo "${_v:M[1-9]*.[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' | ||||
.endif | .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 | |||||
impUnsubmitted Not Done Inline ActionsDo you want to use = or += here? imp: Do you want to use = or += here?
| |||||
arichardsonAuthorUnsubmitted Done Inline ActionsGood point, might as well use += everywhere. Will make that change before committing arichardson: Good point, might as well use += everywhere. Will make that change before committing | |||||
arichardsonAuthorUnsubmitted Done Inline ActionsLooking at it again, it's guarded by !defined(${X_}COMPILER_FEATURES) so assigning might make more sense than using += arichardson: Looking at it again, it's guarded by `!defined(${X_}COMPILER_FEATURES)` so assigning might make… | |||||
impUnsubmitted Not Done Inline ActionsSounds good to me then. I hadn't noticed that would make = fine. imp: Sounds good to me then. I hadn't noticed that would make = fine. | |||||
.endif | |||||
.undef _v | .undef _v | ||||
.endif | .endif | ||||
.if !defined(${X_}COMPILER_FREEBSD_VERSION) | .if !defined(${X_}COMPILER_FREEBSD_VERSION) | ||||
.if defined(_TOOLCHAIN_VARS_SHOULD_BE_SET) && !empty(_TOOLCHAIN_VARS_SHOULD_BE_SET) && !defined(COMPAT_32BIT) && !defined(COMPAT_64BIT) && !make(sysent) && !defined(_CRUNCHGEN) | .if defined(_TOOLCHAIN_VARS_SHOULD_BE_SET) && !empty(_TOOLCHAIN_VARS_SHOULD_BE_SET) && !defined(COMPAT_32BIT) && !defined(COMPAT_64BIT) && !make(sysent) && !defined(_CRUNCHGEN) | ||||
Not Done Inline Actions👀 jrtc27: 👀 | |||||
Done Inline Actionsoops had some debugging .info statements here. arichardson: oops had some debugging `.info` statements here. | |||||
.error "${.CURDIR}: Recomputing ${X_}COMPILER_FREEBSD_VERSION. This value should be cached!" | .error "${.CURDIR}: Recomputing ${X_}COMPILER_FREEBSD_VERSION. This value should be cached!" | ||||
.else | .else | ||||
# .info "${.CURDIR}: Computing ${X_}COMPILER_FREEBSD_VERSION. ${cc}=${${cc}}" | # .info "${.CURDIR}: Computing ${X_}COMPILER_FREEBSD_VERSION. ${cc}=${${cc}}" | ||||
.endif | .endif | ||||
${X_}COMPILER_FREEBSD_VERSION!= { echo "__FreeBSD_cc_version" | ${${cc}:N${CCACHE_BIN}} -E - 2>/dev/null || echo __FreeBSD_cc_version; } | sed -n '$$p' | ${X_}COMPILER_FREEBSD_VERSION!= { echo "__FreeBSD_cc_version" | ${${cc}:N${CCACHE_BIN}} -E - 2>/dev/null || echo __FreeBSD_cc_version; } | sed -n '$$p' | ||||
# If we get a literal "__FreeBSD_cc_version" back then the compiler | # If we get a literal "__FreeBSD_cc_version" back then the compiler | ||||
# is a non-FreeBSD build that doesn't support it or some other error | # is a non-FreeBSD build that doesn't support it or some other error | ||||
# occurred. | # occurred. | ||||
.if ${${X_}COMPILER_FREEBSD_VERSION} == "__FreeBSD_cc_version" | .if ${${X_}COMPILER_FREEBSD_VERSION} == "__FreeBSD_cc_version" | ||||
${X_}COMPILER_FREEBSD_VERSION= unknown | ${X_}COMPILER_FREEBSD_VERSION= unknown | ||||
.endif | .endif | ||||
.endif | .endif | ||||
.if !defined(${X_}COMPILER_RESOURCE_DIR) | .if !defined(${X_}COMPILER_RESOURCE_DIR) | ||||
${X_}COMPILER_RESOURCE_DIR!= ${${cc}:N${CCACHE_BIN}} -print-resource-dir 2>/dev/null || echo unknown | ${X_}COMPILER_RESOURCE_DIR!= ${${cc}:N${CCACHE_BIN}} -print-resource-dir 2>/dev/null || echo unknown | ||||
.endif | .endif | ||||
${X_}COMPILER_FEATURES= c++11 c++14 | ${X_}COMPILER_FEATURES+= c++11 c++14 | ||||
.if ${${X_}COMPILER_TYPE} == "clang" || \ | .if ${${X_}COMPILER_TYPE} == "clang" || \ | ||||
(${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 70000) | (${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 70000) | ||||
${X_}COMPILER_FEATURES+= c++17 | ${X_}COMPILER_FEATURES+= c++17 | ||||
.endif | .endif | ||||
.if ${${X_}COMPILER_TYPE} == "clang" | .if ${${X_}COMPILER_TYPE} == "clang" | ||||
${X_}COMPILER_FEATURES+= retpoline init-all | ${X_}COMPILER_FEATURES+= retpoline init-all | ||||
.endif | .endif | ||||
Show All 36 Lines |
IMO we should explicitly mention Apple's versioning scheme to explain why there's a special apple-clang. Is there some site that cross-references Apple and upstream Clang revisions?