summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.inc16
-rw-r--r--share/mk/bsd.compiler.mk11
-rw-r--r--share/mk/bsd.linker.mk8
3 files changed, 23 insertions, 2 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index 6f21ef9f634c..3ab706661035 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -103,8 +103,11 @@ MK_GCC_BOOTSTRAP= no
# here since we will always have the right make, unlike in src/Makefile
# Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
_NO_INCLUDE_LINKERMK= t
+# We also want the X_COMPILER* variables if we are using an external toolchain.
+_WANT_TOOLCHAIN_CROSS_VARS= t
.include "share/mk/bsd.compiler.mk"
.undef _NO_INCLUDE_LINKERMK
+.undef _WANT_TOOLCHAIN_CROSS_VARS
# src.opts.mk depends on COMPILER_FEATURES
.include "share/mk/src.opts.mk"
@@ -205,7 +208,10 @@ X${BINUTIL}?= ${${BINUTIL}}
MK_LLD_BOOTSTRAP= no
.endif
+# We also want the X_LINKER* variables if we are using an external toolchain.
+_WANT_TOOLCHAIN_CROSS_VARS= t
.include "share/mk/bsd.linker.mk"
+.undef _WANT_TOOLCHAIN_CROSS_VARS
# Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
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