git: a26a1d677383 - 2023Q2 - emulators/virtualbox-ose: on 14 "Failed to construct device 'VMMDev' instance #0 (VERR_INTERNAL_ERROR_3)"

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Thu, 01 Jun 2023 14:57:26 UTC
The branch 2023Q2 has been updated by vvd:

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

commit a26a1d677383f569c833afc39e0db01d3e7a67ab
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2023-06-01 14:44:38 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2023-06-01 14:57:11 +0000

    emulators/virtualbox-ose: on 14 "Failed to construct device 'VMMDev' instance #0 (VERR_INTERNAL_ERROR_3)"
    
    Force llvm from ports from 11 to 14 - by default it'll pick 14.
    Use VBOX_LLVM_VER in make.conf to define different llvm.
    
    PR:                     270189
    Reviewed by:            cy, grahamperrin
    Tested by:              cy, grahamperrin, groenveld@acm.org, rkoberman@gmail.com
    Approved by:            arrowd
    Differential Revision:  https://reviews.freebsd.org/D40254
    
    (cherry picked from commit e6b21a9e3f0a605c06d54737a8ff4d6db82dabe5)
---
 emulators/virtualbox-ose/Makefile | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile
index d6de1b73c8b7..5f6a1975304a 100644
--- a/emulators/virtualbox-ose/Makefile
+++ b/emulators/virtualbox-ose/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	virtualbox-ose
 PORTVERSION=	6.1.44
+PORTREVISION=	2
 CATEGORIES=	emulators
 MASTER_SITES=	https://download.virtualbox.org/virtualbox/${PORTVERSION}/
 DISTFILES=	VirtualBox-${PORTVERSION}${EXTRACT_SUFX} ${GUESTADDITIONS}
@@ -216,14 +217,25 @@ EXTRA_PATCHES+=	${PATCHDIR}/extrapatch-src_VBox_Devices_PC_DevFwCommon.cpp
 .endif
 
 .if ${CHOSEN_COMPILER_TYPE} == clang
-# llvm10 in FreeBSD before r364284 miscompiles virtualbox 6.1 causing errors.
-# force llvm11 from ports
+# 1) llvm10 in FreeBSD before r364284 miscompiles virtualbox 6.1 causing errors.
+# 2) llvm15 in FreeBSD miscompiles virtualbox 6.1 causing errors: PR#270189.
+# Force llvm from ports.
 .if ${OPSYS} == FreeBSD && \
-    (${OSVERSION} < 1203502 || ${OSVERSION} >= 1300000 && ${OSVERSION} < 1300109)
+    (${OSVERSION} < 1203502 || ${OSVERSION} >= 1300000 && ${OSVERSION} < 1300109 || \
+    ${OSVERSION} >= 1302505 && ${OSVERSION} < 1400000 || ${OSVERSION} >= 1400079)
+# USES must be before .include <bsd.port.pre.mk>, but CHOSEN_COMPILER_TYPE must be after.
+# This is a workaround with possibility to define different llvm via VBOX_LLVM_VER in make.conf.
+#USES+=		llvm:min=11,max=14
+#CC=		clang${LLVM_VERSION}
+#CXX=		clang++${LLVM_VERSION}
 BUILD_DEPENDS+=	clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}
 CC=		clang${VBOX_LLVM_VER}
 CXX=		clang++${VBOX_LLVM_VER}
-VBOX_LLVM_VER?=	11
+.if ${LLVM_DEFAULT} < 11 || ${LLVM_DEFAULT} > 14
+VBOX_LLVM_VER?=	14
+.else
+VBOX_LLVM_VER?=	${LLVM_DEFAULT}
+.endif
 .endif
 PATCH_DEPENDS+=	${LOCALBASE}/share/kBuild/tools/GXX3.kmk:devel/kBuild
 EXTRA_PATCHES+=	${PATCHDIR}/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk