]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Pass COMPILER_TYPE and COMPILER_VERSION to sub-makes to avoid redundant
authorbdrewery <bdrewery@FreeBSD.org>
Tue, 20 Oct 2015 20:15:25 +0000 (20:15 +0000)
committerbdrewery <bdrewery@FreeBSD.org>
Tue, 20 Oct 2015 20:15:25 +0000 (20:15 +0000)
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

share/mk/bsd.compiler.mk

index dcdf5987b5016f3f9095e5a089befe1aa5d22c70..46cc8c37d1982a62ddc57cc3cd80e1c21924804d 100644 (file)
 .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]*} | awk -F. '{print $$1 * 10000 + $$2 *
 .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