git: 68c6dcb8f6de - 2023Q2 - emulators/virtualbox-ose: error: use of undeclared identifier 'mempcpy'

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Tue, 23 May 2023 18:27:59 UTC
The branch 2023Q2 has been updated by vvd:

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

commit 68c6dcb8f6de97814ee89b00b7bb354859406dee
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2023-05-23 18:10:50 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2023-05-23 18:27:50 +0000

    emulators/virtualbox-ose: error: use of undeclared identifier 'mempcpy'
    
    1. There are no mempcpy on 12, on 13 before 1300513 and on 14 before 1400026.
    Log with error is here:
    https://lists.freebsd.org/archives/freebsd-pkg-fallout/2023-May/402233.html
    2. 12 have llvm11 in base after 1203502 (llvm12 after 1203503 and llvm13
    after 1203505), so not need to force build with llvm11 from ports.
    
    Reported by:            https://portsfallout.com/fallout?port=emulators%2Fvirtualbox-ose%24
    Reviewed by:            rene
    Approved by:            arrowd (mentor), fuz
    Differential Revision:  https://reviews.freebsd.org/D40163
    
    (cherry picked from commit a39a00bddf995d665bb4ba4e89d7403d14060a6f)
---
 emulators/virtualbox-ose/Makefile                          |  8 +++++++-
 .../files/extrapatch-src_VBox_Devices_PC_DevFwCommon.cpp   | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile
index 541d4c63ae38..d6de1b73c8b7 100644
--- a/emulators/virtualbox-ose/Makefile
+++ b/emulators/virtualbox-ose/Makefile
@@ -210,10 +210,16 @@ KMK_FLAGS+=	-j${MAKE_JOBS_NUMBER}
 
 .include <bsd.port.pre.mk>
 
+.if ${OPSYS} == FreeBSD && \
+    (${OSVERSION} < 1300513 || ${OSVERSION} >= 1400000 && ${OSVERSION} < 1400026)
+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
-.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1300109
+.if ${OPSYS} == FreeBSD && \
+    (${OSVERSION} < 1203502 || ${OSVERSION} >= 1300000 && ${OSVERSION} < 1300109)
 BUILD_DEPENDS+=	clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}
 CC=		clang${VBOX_LLVM_VER}
 CXX=		clang++${VBOX_LLVM_VER}
diff --git a/emulators/virtualbox-ose/files/extrapatch-src_VBox_Devices_PC_DevFwCommon.cpp b/emulators/virtualbox-ose/files/extrapatch-src_VBox_Devices_PC_DevFwCommon.cpp
new file mode 100644
index 000000000000..2ee34f889bb6
--- /dev/null
+++ b/emulators/virtualbox-ose/files/extrapatch-src_VBox_Devices_PC_DevFwCommon.cpp
@@ -0,0 +1,14 @@
+--- src/VBox/Devices/PC/DevFwCommon.cpp.orig
++++ src/VBox/Devices/PC/DevFwCommon.cpp
+@@ -40,6 +40,11 @@
+ #include "VBoxDD2.h"
+ #include "DevFwCommon.h"
+ 
++static inline void *
++mempcpy(void *__restrict dst, const void *__restrict src, size_t len)
++{
++	return ((char *)memcpy(dst, src, len) + len);
++}
+ 
+ /*********************************************************************************************************************************
+ *   Defined Constants And Macros                                                                                                 *