Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Feb 2018 19:34:06 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r463259 - in head/Mk: Scripts Uses
Message-ID:  <201802281934.w1SJY6QK004522@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Wed Feb 28 19:34:05 2018
New Revision: 463259
URL: https://svnweb.freebsd.org/changeset/ports/463259

Log:
  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)

Modified:
  head/Mk/Scripts/functions.sh
  head/Mk/Uses/compiler.mk

Modified: head/Mk/Scripts/functions.sh
==============================================================================
--- head/Mk/Scripts/functions.sh	Wed Feb 28 18:53:10 2018	(r463258)
+++ head/Mk/Scripts/functions.sh	Wed Feb 28 19:34:05 2018	(r463259)
@@ -164,7 +164,7 @@ export_ports_env() {
 
 	validate_env MAKE PORTSDIR
 
-	uses="python"
+	uses="python compiler:features"
 
 	make_env="\
 		_PORTS_ENV_CHECK=1 \

Modified: head/Mk/Uses/compiler.mk
==============================================================================
--- head/Mk/Uses/compiler.mk	Wed Feb 28 18:53:10 2018	(r463258)
+++ head/Mk/Uses/compiler.mk	Wed Feb 28 19:34:05 2018	(r463259)
@@ -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



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