1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-16 03:24:07 +00:00

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)
This commit is contained in:
Bryan Drewery 2018-02-28 19:34:05 +00:00
parent 4ddc75fd13
commit dc15d9f81f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=463259
2 changed files with 31 additions and 4 deletions

View File

@ -164,7 +164,7 @@ export_ports_env() {
validate_env MAKE PORTSDIR
uses="python"
uses="python compiler:features"
make_env="\
_PORTS_ENV_CHECK=1 \

View File

@ -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