git: 482804eb2cc0 - main - audio/flac: fix build of x86 intrinsic-optimized code for clang 14+

From: Christian Weisgerber <naddy_at_FreeBSD.org>
Date: Sun, 09 Oct 2022 15:21:52 UTC
The branch main has been updated by naddy:

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

commit 482804eb2cc0482d2e0e87dfc9d1e7bf6eb78d02
Author:     Christian Weisgerber <naddy@FreeBSD.org>
AuthorDate: 2022-10-09 15:09:16 +0000
Commit:     Christian Weisgerber <naddy@FreeBSD.org>
CommitDate: 2022-10-09 15:21:43 +0000

    audio/flac: fix build of x86 intrinsic-optimized code for clang 14+
    
    Add upstream fix "Assume Clang supports x86 intrinsics up to FMA"
    to keep support for SSSE3, AVX2, etc. when compiled with clang
    versions 14 and later.
    
    Obtained from:  https://github.com/xiph/flac/commit/90c0562d4eb302b01d9b82c75a7f6a66261c5546
    MFH:            2022Q4
---
 audio/flac/Makefile                                |  1 +
 .../files/patch-src_libFLAC_include_private_cpu.h  | 41 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/audio/flac/Makefile b/audio/flac/Makefile
index b0d23cd0a4ca..29c6f0fe134a 100644
--- a/audio/flac/Makefile
+++ b/audio/flac/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	flac
 PORTVERSION=	1.4.1
+PORTREVISION=	1
 CATEGORIES=	audio
 MASTER_SITES=	https://downloads.xiph.org/releases/flac/ \
 		https://ftp.osuosl.org/pub/xiph/releases/flac/
diff --git a/audio/flac/files/patch-src_libFLAC_include_private_cpu.h b/audio/flac/files/patch-src_libFLAC_include_private_cpu.h
new file mode 100644
index 000000000000..9837d6f10ae2
--- /dev/null
+++ b/audio/flac/files/patch-src_libFLAC_include_private_cpu.h
@@ -0,0 +1,41 @@
+Assume Clang supports x86 intrinsics up to FMA
+https://github.com/xiph/flac/commit/90c0562d4eb302b01d9b82c75a7f6a66261c5546
+
+--- src/libFLAC/include/private/cpu.h.orig	2022-09-21 18:57:31 UTC
++++ src/libFLAC/include/private/cpu.h
+@@ -82,28 +82,14 @@
+ #elif defined __clang__ && __has_attribute(__target__) /* clang */
+   #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
+   #define FLAC__FAST_MATH_TARGET(x) __attribute__ ((__target__ (x)))
+-  #if __has_builtin(__builtin_ia32_maxps)
+-    #define FLAC__SSE_SUPPORTED 1
+-  #endif
+-  #if __has_builtin(__builtin_ia32_pmuludq128)
+-    #define FLAC__SSE2_SUPPORTED 1
+-  #endif
+-  #if __has_builtin(__builtin_ia32_pabsd128)
+-    #define FLAC__SSSE3_SUPPORTED 1
+-  #endif
+-  #if __has_builtin(__builtin_ia32_pmuldq128)
+-    #define FLAC__SSE4_1_SUPPORTED 1
+-  #endif
++  #define FLAC__SSE_SUPPORTED 1
++  #define FLAC__SSE2_SUPPORTED 1
++  #define FLAC__SSSE3_SUPPORTED 1
++  #define FLAC__SSE4_1_SUPPORTED 1
+   #ifdef FLAC__USE_AVX
+-    #if __has_builtin(__builtin_ia32_maxps256)
+-      #define FLAC__AVX_SUPPORTED 1
+-    #endif
+-    #if __has_builtin(__builtin_ia32_pabsd256)
+-      #define FLAC__AVX2_SUPPORTED 1
+-    #endif
+-    #if __has_builtin(__builtin_ia32_vfmaddps)
+-      #define FLAC__FMA_SUPPORTED 1
+-    #endif
++    #define FLAC__AVX_SUPPORTED 1
++    #define FLAC__AVX2_SUPPORTED 1
++    #define FLAC__FMA_SUPPORTED 1
+   #endif
+ #elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */
+   #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))