aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/clang/clang.build.mk20
-rw-r--r--share/mk/local.meta.sys.mk44
-rw-r--r--targets/pseudo/bootstrap-tools/Makefile9
3 files changed, 30 insertions, 43 deletions
diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk
index bbe8e1f4bef2..e90bd3f80648 100644
--- a/lib/clang/clang.build.mk
+++ b/lib/clang/clang.build.mk
@@ -39,26 +39,6 @@ CXXFLAGS.clang+= -stdlib=libc++
.PATH: ${LLVM_SRCS}/${SRCDIR}
-.if ${MK_DIRDEPS_BUILD} == "yes"
-.if empty(TOOLSDIR) || !exists(${TOOLSDIR}/usr/bin/clang-tblgen)
-.if ${MACHINE} == "host" && defined(BOOTSTRAPPING_TOOLS)
-.if !empty(LEGACY_TOOLS) && exists(${LEGACY_TOOLS}/usr/bin/tblgen)
-TOOLSDIR= ${LEGACY_TOOLS}
-.endif
-.endif
-.if ${MK_STAGING} == "yes" && exists(${STAGE_HOST_OBJTOP:Uno}/usr/bin/tblgen)
-TOOLSDIR= ${STAGE_HOST_OBJTOP}
-.endif
-.if exists(${LEGACY_TOOLS:Uno}/usr/bin/tblgen)
-TOOLSDIR= ${LEGACY_TOOLS}
-.endif
-.endif
-TOOLSDIR?=
-.if !empty(TOOLSDIR) && exists(${TOOLSDIR}/usr/bin/clang-tblgen)
-TBLGEN= ${TOOLSDIR}/usr/bin/tblgen
-CLANG_TBLGEN= ${TOOLSDIR}/usr/bin/clang-tblgen
-.endif
-.endif # ${MK_DIRDEPS_BUILD} == "yes"
TBLGEN?= tblgen
CLANG_TBLGEN?= clang-tblgen
diff --git a/share/mk/local.meta.sys.mk b/share/mk/local.meta.sys.mk
index c9b0a7104c16..03c4723b0b10 100644
--- a/share/mk/local.meta.sys.mk
+++ b/share/mk/local.meta.sys.mk
@@ -204,35 +204,41 @@ TRACER= ${TIME_STAMP} ${:U}
.if ${MACHINE} == "host"
MK_SHARED_TOOLCHAIN= no
.endif
+TOOLCHAIN_VARS= AS AR CC CLANG_TBLGEN CXX CPP LD NM OBJDUMP OBJCOPY RANLIB \
+ STRINGS SIZE TBLGEN
+_toolchain_bin_CLANG_TBLGEN= /usr/bin/clang-tblgen
+_toolchain_bin_CXX= /usr/bin/c++
.ifdef WITH_TOOLSDIR
TOOLSDIR?= ${HOST_OBJTOP}/tools
-.elif defined(STAGE_HOST_OBJTOP) && exists(${STAGE_HOST_OBJTOP}/usr/bin)
+.elif defined(STAGE_HOST_OBJTOP)
TOOLSDIR?= ${STAGE_HOST_OBJTOP}
.endif
-.if !empty(TOOLSDIR)
-.if ${.MAKE.LEVEL} == 0 && exists(${TOOLSDIR}/usr/bin)
-PATH:= ${PATH:S,:, ,g:@d@${exists(${TOOLSDIR}$d):?${TOOLSDIR}$d:}@:ts:}:${PATH}
+# Don't use the bootstrap tools logic on itself.
+.if ${.TARGETS:Mbootstrap-tools} == "" && \
+ !defined(BOOTSTRAPPING_TOOLS) && !empty(TOOLSDIR) && ${.MAKE.LEVEL} == 0
+.for dir in /sbin /bin /usr/sbin /usr/bin
+PATH:= ${TOOLSDIR}${dir}:${PATH}
+.endfor
.export PATH
-.if exists(${TOOLSDIR}/usr/bin/cc)
-HOST_CC?= ${TOOLSDIR}/usr/bin/cc
-CC?= ${HOST_CC}
-HOST_CXX?= ${TOOLSDIR}/usr/bin/c++
-CXX?= ${HOST_CXX}
-HOST_CPP?= ${TOOLSDIR}/usr/bin/cpp
-CPP?= ${HOST_CPP}
-.export HOST_CC CC HOST_CXX CXX HOST_CPP CPP
-.endif
+# Prefer the TOOLSDIR version of the toolchain if present vs the host version.
+.for var in ${TOOLCHAIN_VARS}
+_toolchain_bin.${var}= ${TOOLSDIR}${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
+.if exists(${_toolchain_bin.${var}})
+HOST_${var}?= ${_toolchain_bin.${var}}
+${var}?= ${HOST_${var}}
+.export HOST_${var} ${var}
.endif
+.endfor
.endif
-HOST_CC?= /usr/bin/cc
-HOST_CXX?= /usr/bin/c++
-HOST_CPP?= /usr/bin/cpp
+.for var in ${TOOLCHAIN_VARS}
+HOST_${var}?= ${_toolchain_bin_${var}:U/usr/bin/${var:tl}}
+.endfor
.if ${MACHINE} == "host"
-CC= ${HOST_CC}
-CXX= ${HOST_CXX}
-CPP= ${HOST_CPP}
+.for var in ${TOOLCHAIN_VARS}
+${var}= ${HOST_${var}}
+.endfor
.endif
.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
diff --git a/targets/pseudo/bootstrap-tools/Makefile b/targets/pseudo/bootstrap-tools/Makefile
index 30a5b894ecdc..2d38a70155a3 100644
--- a/targets/pseudo/bootstrap-tools/Makefile
+++ b/targets/pseudo/bootstrap-tools/Makefile
@@ -20,7 +20,7 @@ BSENV= \
MAKESYSPATH=${SRCTOP}/tools/build/mk:${SRCTOP}/share/mk \
TARGET=${HOST_MACHINE} TARGET_ARCH=${HOST_MACHINE_ARCH} \
WITHOUT_STAGING=1 STAGE_ROOT= BOOTSTRAPPING_TOOLS=1 \
- WORLDTMP=${BTOOLSDIR} LEGACY_TOOLS=${LEGACY_TOOLS} \
+ WORLDTMP=${BTOOLSDIR} \
INSTALL="sh ${SRCTOP}/tools/install.sh" \
PATH=${LEGACY_TOOLS}/usr/sbin:${LEGACY_TOOLS}/usr/bin:${LEGACY_TOOLS}/bin:${PATH}
@@ -67,14 +67,15 @@ cross-tools build-tools bootstrap-tools: .MAKE .META
touch $@
# MAKELEVEL=0 so that dirdeps.mk does its thing
-# LEGACY_TOOLS lets us use the bootstrapped stuff above
+# BSENV:MPATH=* lets us use the bootstrapped stuff in LEGACY_TOOLS above.
# TARGET* is so that MK_CLANG gets set correctly.
BSTCENV= \
MAKELEVEL=0 \
MACHINE=host \
- LEGACY_TOOLS=${LEGACY_TOOLS} \
+ BOOTSTRAPPING_TOOLS=1 \
TARGET=${HOST_MACHINE} \
- TARGET_ARCH=${HOST_MACHINE_ARCH}
+ TARGET_ARCH=${HOST_MACHINE_ARCH} \
+ ${BSENV:MPATH=*}
BSTCARGS= \
${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*:NMK_GCC=*} \