git: b5c4e8520ab3 - stable/13 - Makefile.inc1: Enable requesting the universe toolchain.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Sat, 30 Nov 2024 17:11:47 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=b5c4e8520ab30b2348ed1d4bef15e879ecc0af9d

commit b5c4e8520ab30b2348ed1d4bef15e879ecc0af9d
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-08-01 21:01:57 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-30 16:51:59 +0000

    Makefile.inc1: Enable requesting the universe toolchain.
    
    make universe builds a cross toolchain under HOST_OBJTMP/tmp via the
    universe-toolchain target.  However, doing a plain 'make buildworld'
    after a universe/tinderbox run (e.g. to reproduce a failure and test
    the fix for it), will try to build a new cross toolchain under
    OBJTMP/tmp which can be tedious.  This commit adds a make variable
    (UNIVERSE_TOOLCHAIN) which can be used similar to CROSS_TOOLCHAIN to
    request an external toolchain.  If this variable is set (value doesn't
    matter), the the universe toolchain is used as an external toolchain.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D40777
    
    (cherry picked from commit 1c02497648bdf61a43dd271f6f9171a037046d8e)
---
 Makefile.inc1      | 8 ++++++++
 Makefile.libcompat | 1 +
 2 files changed, 9 insertions(+)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 9190c449878c..fc5e82d39eca 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -73,6 +73,12 @@ LOCALBASE?=	/usr/local
 .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
 .endif
 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
+.elif defined(UNIVERSE_TOOLCHAIN)
+UNIVERSE_TOOLCHAIN_PATH?=${HOST_OBJTOP}/tmp/usr/bin
+XCC?="${UNIVERSE_TOOLCHAIN_PATH}/cc"
+XCXX?="${UNIVERSE_TOOLCHAIN_PATH}/c++"
+XCPP?="${UNIVERSE_TOOLCHAIN_PATH}/cpp"
+XLD?="${UNIVERSE_TOOLCHAIN_PATH}/ld"
 .endif
 .if defined(CROSS_TOOLCHAIN_PREFIX)
 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
@@ -724,6 +730,7 @@ BMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
 BSARGS= 	DESTDIR= \
 		OBJTOP='${WORLDTMP}/obj-tools' \
 		OBJROOT='$${OBJTOP}/' \
+		UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
 		MAKEOBJDIRPREFIX= \
 		BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
 		BWPHASE=${.TARGET:C,^_,,} \
@@ -792,6 +799,7 @@ KTMAKE=		\
 		DESTDIR= \
 		OBJTOP='${WORLDTMP}/obj-kernel-tools' \
 		OBJROOT='$${OBJTOP}/' \
+		UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
 		MAKEOBJDIRPREFIX= \
 		BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
 		-DNO_CPU_CFLAGS \
diff --git a/Makefile.libcompat b/Makefile.libcompat
index 8c9d7273e5c8..58d4dbbfbee3 100644
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -30,6 +30,7 @@ LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
 LIBCOMPATWMAKE+=	${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
 			OBJTOP=${LIBCOMPAT_OBJTOP} \
 			OBJROOT='$${OBJTOP}/' \
+			UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
 			MAKEOBJDIRPREFIX= \
 			MK_MAN=no MK_HTML=no
 LIBCOMPATIMAKE+=	${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \