Author: bdrewery
Date: Tue Oct 20 20:15:25 2015
New Revision: 289659
URL: https://svnweb.freebsd.org/changeset/base/289659

Log:
  Pass COMPILER_TYPE and COMPILER_VERSION to sub-makes to avoid redundant
  lookups.
  
  This uses a special variable name based on a hash of ${CC}, ${PATH}, and
  ${MACHINE} to ensure that a cached value is not used if any of these
  values changes to use a new compiler.
  
  Before this there were 34,620 fork/exec from bsd.compiler.mk during a 
buildworld.
  After this there are 608.  More improvement is needed to cache a value from
  the top-level before descending into subdirs in the various build phases.
  
  Reviewed by:  brooks (earlier version)
  MFC after:    3 weeks
  Sponsored by: EMC / Isilon Storage Division
  Differential Revision:        https://reviews.freebsd.org/D3898

Modified:
  head/share/mk/bsd.compiler.mk

Modified: head/share/mk/bsd.compiler.mk
==============================================================================
--- head/share/mk/bsd.compiler.mk       Tue Oct 20 20:12:42 2015        
(r289658)
+++ head/share/mk/bsd.compiler.mk       Tue Oct 20 20:15:25 2015        
(r289659)
@@ -25,6 +25,18 @@
 .if !target(__<bsd.compiler.mk>__)
 __<bsd.compiler.mk>__:
 
+# Try to import COMPILER_TYPE and COMPILER_VERSION from parent make.
+# The value is only used/exported for the same environment that impacts
+# CC and COMPILER_* settings here.
+_exported_vars=        COMPILER_TYPE COMPILER_VERSION
+_cc_hash=      ${CC}${MACHINE}${PATH}
+_cc_hash:=     ${_cc_hash:hash}
+.for var in ${_exported_vars}
+.if defined(${var}.${_cc_hash})
+${var}=        ${${var}.${_cc_hash}}
+.endif
+.endfor
+
 .if ${MACHINE} == "common"
 # common is a pseudo machine for architecture independent
 # generated files - thus there is no compiler.
@@ -54,6 +66,14 @@ COMPILER_VERSION!=echo ${_v:M[1-9].[0-9]
 .undef _v
 .endif
 
+# Export the values so sub-makes don't have to look them up again, using the
+# hash key computed above.
+.for var in ${_exported_vars}
+${var}.${_cc_hash}:=   ${${var}}
+.export-env ${var}.${_cc_hash}
+.undef ${var}.${_cc_hash}
+.endfor
+
 .if ${COMPILER_TYPE} == "clang" || \
        (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800)
 COMPILER_FEATURES=     c++11
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to