git: e96c049f2810 - main - devel/llvm-{cheri,cheriot,morello}: XTOOLCHAIN option

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Tue, 23 Jan 2024 23:33:06 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e96c049f2810240608054d7821d1debaf4a16698

commit e96c049f2810240608054d7821d1debaf4a16698
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-01-23 23:30:34 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-01-23 23:30:34 +0000

    devel/llvm-{cheri,cheriot,morello}: XTOOLCHAIN option
    
    Make the cross toolchain file optional and disable it completely for
    cheriot where the compiler targets an architecture we'll ever support
    (RV32E).
---
 devel/llvm-cheri/Makefile   | 19 +++++++++++--------
 devel/llvm-cheriot/Makefile |  2 ++
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/devel/llvm-cheri/Makefile b/devel/llvm-cheri/Makefile
index dd5e4588cd6a..92cc81b45ad6 100644
--- a/devel/llvm-cheri/Makefile
+++ b/devel/llvm-cheri/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	llvm
 PORTVERSION=	${LLVM_MAJOR}.0.d${SNAPDATE}
-PORTREVISION=	0
+PORTREVISION=	1
 CATEGORIES=	devel lang
 PKGNAMESUFFIX=	${LLVM_SUFFIX}
 
@@ -69,8 +69,8 @@ GH_TAGNAME=	${LLVM_COMMIT}
 .sinclude "${.PARSEDIR}/Makefile.snapshot"
 .endif
 
-OPTIONS_DEFINE=	CLANG DOCS LIT LLD STATIC_LIBS
-OPTIONS_DEFAULT=	CLANG LIT LLD
+OPTIONS_DEFINE=	CLANG DOCS LIT LLD STATIC_LIBS XTOOLCHAIN
+OPTIONS_DEFAULT=	CLANG LIT LLD XTOOLCHAIN
 OPTIONS_SUB=	yes
 
 CLANG_DESC=		Build clang
@@ -78,8 +78,6 @@ CLANG_PORTDOCS=		clang
 CLANG_USES=		perl5
 # scan-build does require, but users can install it manually.
 CLANG_USE=		PERL5=build
-PLIST_FILES+=		share/toolchains/llvm${LLVM_SUFFIX}.mk
-SUB_FILES+=		xtoolchain.mk
 DOCS_BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sphinx>=0,1:textproc/py-sphinx@${PY_FLAVOR} \
 			${PYTHON_PKGNAMEPREFIX}recommonmark>=0.0.20180530:textproc/py-recommonmark@${PY_FLAVOR}
 DOCS_CMAKE_ON=		-DLLVM_ENABLE_SPHINX=ON \
@@ -95,6 +93,9 @@ LLD_DESC=		Install lld linker
 LLD_PORTDOCS=		lld
 LLDB_DESC=		Install lldb, the LLVM debugger
 LLDB_BUILD_DEPENDS=	swig:devel/swig
+XTOOLCHAIN_DESC=	Install cross toolchain file
+XTOOLCHAIN_PLIST_FILES+=share/toolchains/llvm${LLVM_SUFFIX}.mk
+XTOOLCHAIN_SUB_FILES+=	xtoolchain.mk
 STATIC_LIBS_DESC=	Install static libraries (does not effect sanitizers)
 
 LLVM_TARGETS?=		AArch64;ARM;PowerPC;RISCV;X86
@@ -171,9 +172,6 @@ post-patch-LLD-on:
 			${PATCH_WRKSRC}/lld/docs/conf.py
 
 post-install:
-	${MKDIR} ${STAGEDIR}${PREFIX}/share/toolchains/
-	${INSTALL_DATA} ${WRKDIR}/xtoolchain.mk \
-	    ${STAGEDIR}${PREFIX}/share/toolchains/llvm${LLVM_SUFFIX}.mk
 	${INSTALL_SCRIPT} ${WRKDIR}/llvm-wrapper.sh \
 	    ${STAGEDIR}${PREFIX}/bin/${COMMAND_PREFIX}${FIRST_COMMAND}${COMMAND_SUFFIX}
 .for command in ${COMMANDS:C/^/XXXX/1:NXXXX*}
@@ -220,6 +218,11 @@ post-install-LLDB-on:
 	${RM} ${STAGEDIR}${LLVM_PREFIX}/lib/python*/site-packages/lib
 .endif
 
+post-install-XTOOLCHAIN-on:
+	${MKDIR} ${STAGEDIR}${PREFIX}/share/toolchains
+	${INSTALL_DATA} ${WRKDIR}/xtoolchain.mk \
+	    ${STAGEDIR}${PREFIX}/share/toolchains/llvm${LLVM_SUFFIX}.mk
+
 post-install-CLANG-on:
 	${LN} -f ${STAGEDIR}${LLVM_PREFIX}/bin/clang \
 	    ${STAGEDIR}${LLVM_PREFIX}/bin/clang-cpp
diff --git a/devel/llvm-cheriot/Makefile b/devel/llvm-cheriot/Makefile
index ff1635c3cb02..9bcbbf066e25 100644
--- a/devel/llvm-cheriot/Makefile
+++ b/devel/llvm-cheriot/Makefile
@@ -9,6 +9,8 @@ DISTINFO_FILE=	${.CURDIR}/distinfo
 DESCR=		${.CURDIR}/pkg-descr
 PLIST=		${.CURDIR}/pkg-plist
 
+OPTIONS_EXCLUDE=	XTOOLCHAIN
+
 LLVM_TARGETS=          RISCV
 CMAKE_FLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=riscv32-unknown-unknown