aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2018-10-23 06:31:25 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2018-10-23 06:31:25 +0000
commit74f6548619cdef063d5beebe52c1aafc67df2cd0 (patch)
treee4e5105367532cb214e891fcaf0b79e6ffd7c228 /share
parentc5c5072bb0d088216ac3f8602929274a543e1057 (diff)
downloadsrc-74f6548619cdef063d5beebe52c1aafc67df2cd0.tar.gz
src-74f6548619cdef063d5beebe52c1aafc67df2cd0.zip
Only compute the X_COMPILER_*/X_LINKER_* variables when needed
When building CheriBSD we have to set XLD/XCC/XCFLAGS on the command line. This triggers the $XCC != $CC case in bsd.compiler.mk (and the same for LD in bsd.linker.mk) which causes it to call ${XCC} --version and ${XLD} --version (plus various awk+sed+echo calls) in every subdirectory. For incremental builds and stages that only walk the source tree this is often the majority of the time spent in that directory. By only computing the value of the X_COMPILER_*/X_LINKER_* variables if _WANT_TOOLCHAIN_CROSS_VARS is set we can reduce the number of cc/ld calls to once per build stage instead of once per recursive make. With this change (and no changes to the sources) the `make includes` stage now takes 28 seconds at -j1 instead of 86 seconds. Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17046
Notes
Notes: svn path=/head/; revision=339636
Diffstat (limited to 'share')
-rw-r--r--share/mk/bsd.compiler.mk11
-rw-r--r--share/mk/bsd.linker.mk8
2 files changed, 17 insertions, 2 deletions
diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk
index 3bbca41fdf86..a528bb02b2b3 100644
--- a/share/mk/bsd.compiler.mk
+++ b/share/mk/bsd.compiler.mk
@@ -116,7 +116,16 @@ ccache-print-options: .PHONY
.endif # exists(${CCACHE_BIN})
.endif # ${MK_CCACHE_BUILD} == "yes"
-.for cc X_ in CC $${_empty_var_} XCC X_
+_cc_vars=CC $${_empty_var_}
+.if !empty(_WANT_TOOLCHAIN_CROSS_VARS)
+# Only the toplevel makefile needs to compute the X_COMPILER_* variables.
+# Skipping the computation of the unused X_COMPILER_* in the subdirectory
+# makefiles can save a noticeable amount of time when walking the whole source
+# tree (e.g. during make includes, etc.).
+_cc_vars+=XCC X_
+.endif
+
+.for cc X_ in ${_cc_vars}
.if ${cc} == "CC" || !empty(XCC)
# Try to import COMPILER_TYPE and COMPILER_VERSION from parent make.
# The value is only used/exported for the same environment that impacts
diff --git a/share/mk/bsd.linker.mk b/share/mk/bsd.linker.mk
index caf4fccbae0f..35cfe7128202 100644
--- a/share/mk/bsd.linker.mk
+++ b/share/mk/bsd.linker.mk
@@ -26,7 +26,13 @@
.if !target(__<bsd.linker.mk>__)
__<bsd.linker.mk>__:
-.for ld X_ in LD $${_empty_var_} XLD X_
+_ld_vars=LD $${_empty_var_}
+.if !empty(_WANT_TOOLCHAIN_CROSS_VARS)
+# Only the toplevel makefile needs to compute the X_LINKER_* variables.
+_ld_vars+=XLD X_
+.endif
+
+.for ld X_ in ${_ld_vars}
.if ${ld} == "LD" || !empty(XLD)
# Try to import LINKER_TYPE and LINKER_VERSION from parent make.
# The value is only used/exported for the same environment that impacts