git: bf02e174350c - main - science/qt6-quick3dphysics: Add SIMD option

From: Jason E. Hale <jhale_at_FreeBSD.org>
Date: Sat, 28 Oct 2023 17:31:05 UTC
The branch main has been updated by jhale:

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

commit bf02e174350cd0b77640d114941a18517cd5f26f
Author:     Jason E. Hale <jhale@FreeBSD.org>
AuthorDate: 2023-10-28 17:01:41 +0000
Commit:     Jason E. Hale <jhale@FreeBSD.org>
CommitDate: 2023-10-28 17:31:00 +0000

    science/qt6-quick3dphysics: Add SIMD option
    
    This fixes building on i386 when SSE2 instructions are not available [1].
    
    Vector intrinsics require either SSE2 or NEON intruction sets, so this
    option is only available for aarch64, amd64, armv7, and i386. Off by
    default on i386, since the package builders build for the least common
    denominator and don't assume that the processor has SSE2 like the
    headers in PhysX do.
    
    Reported by:    pkg-fallout [1]
---
 science/qt6-quick3dphysics/Makefile | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/science/qt6-quick3dphysics/Makefile b/science/qt6-quick3dphysics/Makefile
index 2f8ac5d7d9f6..578413a0b34a 100644
--- a/science/qt6-quick3dphysics/Makefile
+++ b/science/qt6-quick3dphysics/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	quick3dphysics
 DISTVERSION=	${QT6_VERSION}
+PORTREVISION=	1
 CATEGORIES=	science
 PKGNAMEPREFIX=	qt6-
 
@@ -12,7 +13,32 @@ LIB_DEPENDS=	libxkbcommon.so:x11/libxkbcommon
 
 USES=		cmake compiler:c++17-lang gl pkgconfig qt-dist:6
 USE_GL=		opengl
+USE_LDCONFIG=	yes
 USE_LOCALE=	C.UTF-8
 USE_QT=		base declarative quick3d shadertools
 
+OPTIONS_DEFINE_aarch64=	SIMD
+OPTIONS_DEFINE_amd64=	SIMD
+OPTIONS_DEFINE_armv7=	SIMD
+OPTIONS_DEFINE_i386=	SIMD
+OPTIONS_DEFAULT_aarch64=SIMD
+OPTIONS_DEFAULT_amd64=	SIMD
+OPTIONS_DEFAULT_armv7=	SIMD
+
+.include <bsd.port.options.mk>
+
+# Either SSE2 or NEON instruction sets are required on i386/amd64 or armv7/
+# aarch64, respectively, to compile vector intrinsics. However i386 does not
+# guarantee SSE2, nor does armv7 NEON, but from what I understand, llvm implies
+# NEON for armv7. If the SIMD option is selected on i386 and SSE2 is not
+# available, we ignore. SIMD support on other platforms is not implemented.
+
+.if ${PORT_OPTIONS:MSIMD}
+.  if ${ARCH} == "i386" && empty(MACHINE_CPU:Msse2)
+IGNORE=		sse2 instructions required
+.  endif
+.else
+CFLAGS+=	-DPX_SIMD_DISABLED
+.endif
+
 .include <bsd.port.mk>