diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2018-03-01 03:34:05 +0800 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2018-03-01 03:34:05 +0800 |
commit | bf6ab8030d5dbf8ef2b6184f3f6056ac0fc22e52 (patch) | |
tree | d00902b8de66fd81a3165ca4cdc1f572f28d1cd1 /Mk | |
parent | 040dfe80b171cff0059233e055ee66f4a7a79754 (diff) | |
download | freebsd-ports-gnome-bf6ab8030d5dbf8ef2b6184f3f6056ac0fc22e52.tar.gz freebsd-ports-gnome-bf6ab8030d5dbf8ef2b6184f3f6056ac0fc22e52.tar.zst freebsd-ports-gnome-bf6ab8030d5dbf8ef2b6184f3f6056ac0fc22e52.zip |
Add compiler.mk to PORTS_ENV.
This only handles the default CC=cc but is enough to significantly improve
INDEX/Poudriere ports var gathering due to reducing around a dozen cc
fork+exec for every port that all have the same result. These values
are reused during the port build as well which reduces more fork+exec
contention there.
Approved by: portmgr (implicit)
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/Scripts/functions.sh | 2 | ||||
-rw-r--r-- | Mk/Uses/compiler.mk | 33 |
2 files changed, 31 insertions, 4 deletions
diff --git a/Mk/Scripts/functions.sh b/Mk/Scripts/functions.sh index 252a357f9873..096d50efff5a 100644 --- a/Mk/Scripts/functions.sh +++ b/Mk/Scripts/functions.sh @@ -164,7 +164,7 @@ export_ports_env() { validate_env MAKE PORTSDIR - uses="python" + uses="python compiler:features" make_env="\ _PORTS_ENV_CHECK=1 \ diff --git a/Mk/Uses/compiler.mk b/Mk/Uses/compiler.mk index 0e247bbd7204..23fbf15e4a7c 100644 --- a/Mk/Uses/compiler.mk +++ b/Mk/Uses/compiler.mk @@ -37,6 +37,9 @@ compiler_ARGS= env VALID_ARGS= c++11-lib c++11-lang c++14-lang c11 features openmp env nestedfct c++0x gcc-c++11-lib +_CC_hash:= ${CC:hash} +_CXX_hash:= ${CXX:hash} + .if ${compiler_ARGS} == gcc-c++11-lib _COMPILER_ARGS+= features gcc-c++11-lib .elif ${compiler_ARGS} == c++11-lib @@ -66,7 +69,13 @@ _COMPILER_ARGS= # _COMPILER_ARGS+= features .endif +.if defined(_CCVERSION_${_CC_hash}) +_CCVERSION= ${_CCVERSION_${_CC_hash}} +.else _CCVERSION!= ${CC} --version +_CCVERSION_${_CC_hash}= ${_CCVERSION} +PORTS_ENV_VARS+= _CCVERSION_${_CC_hash} +.endif COMPILER_VERSION= ${_CCVERSION:M[0-9].[0-9]*:tW:C/([0-9]).([0-9]).*/\1\2/g} .if ${_CCVERSION:Mclang} COMPILER_TYPE= clang @@ -76,7 +85,10 @@ COMPILER_TYPE= gcc ALT_COMPILER_VERSION= 0 ALT_COMPILER_TYPE= none -_ALTCCVERSION= +_ALTCCVERSION= none +.if defined(_ALTCCVERSION_${_CC_hash}) +_ALTCCVERSION= ${_ALTCCVERSION_${_CC_hash}} +.else .if ${COMPILER_TYPE} == gcc && exists(/usr/bin/clang) .if ${ARCH} == amd64 || ${ARCH} == i386 # clang often non-default for a reason _ALTCCVERSION!= /usr/bin/clang --version @@ -84,11 +96,14 @@ _ALTCCVERSION!= /usr/bin/clang --version .elif ${COMPILER_TYPE} == clang && exists(/usr/bin/gcc) _ALTCCVERSION!= /usr/bin/gcc --version .endif +_ALTCCVERSION_${_CC_hash}= ${_ALTCCVERSION} +PORTS_ENV_VARS+= _ALTCCVERSION_${_CC_hash} +.endif ALT_COMPILER_VERSION= ${_ALTCCVERSION:M[0-9].[0-9]*:tW:C/([0-9]).([0-9]).*/\1\2/g} .if ${_ALTCCVERSION:Mclang} ALT_COMPILER_TYPE= clang -.elif !empty(_ALTCCVERSION) +.elif ${_ALTCCVERSION} != none ALT_COMPILER_TYPE= gcc .endif @@ -109,7 +124,13 @@ CHOSEN_COMPILER_TYPE= gcc .endif .if ${_COMPILER_ARGS:Mfeatures} +.if defined(_CXXINTERNAL_${_CXX_hash}) +_CXXINTERNAL= ${_CXXINTERNAL_${_CXX_hash}} +.else _CXXINTERNAL!= ${CXX} -\#\#\# /dev/null 2>&1 +_CXXINTERNAL_${_CXX_hash}= ${_CXXINTERNAL} +PORTS_ENV_VARS+= _CXXINTERNAL_${_CXX_hash} +.endif .if ${_CXXINTERNAL:M\"-lc++\"} COMPILER_FEATURES= libc++ .else @@ -124,7 +145,13 @@ _LANG=c .if ${CXXSTD:M${std}} _LANG=c++ .endif -OUTPUT_${std}!= echo | ${CC} -std=${std} -c -x ${_LANG} /dev/null -o /dev/null 2>&1; echo +.if defined(OUTPUT_${std:hash}_${_CC_hash}) +OUTPUT_${std}= ${OUTPUT_${std:hash}_${_CC_hash}} +.else +OUTPUT_${std}!= ${CC} -std=${std} -c -x ${_LANG} /dev/null -o /dev/null 2>&1; echo yes +OUTPUT_${std:hash}_${_CC_hash}= ${OUTPUT_${std}} +PORTS_ENV_VARS+= OUTPUT_${std:hash}_${_CC_hash} +.endif .if !${OUTPUT_${std}:M*error*} COMPILER_FEATURES+= ${std} .endif |