diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2015-10-20 20:15:25 +0000 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2015-10-20 20:15:25 +0000 |
commit | c197d1a9f750051ae14c18eccbe64db5d75a1d03 (patch) | |
tree | 6c9babdd3ba09fca033c58c105e9814f9efa43ee /share/mk | |
parent | f8f03021517d1601d80a92e9ddcc7c0103f9d912 (diff) | |
download | FreeBSD-src-c197d1a9f750051ae14c18eccbe64db5d75a1d03.zip FreeBSD-src-c197d1a9f750051ae14c18eccbe64db5d75a1d03.tar.gz |
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
Diffstat (limited to 'share/mk')
-rw-r--r-- | share/mk/bsd.compiler.mk | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index dcdf598..46cc8c3 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -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]*} | 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 |