From f7f221488a331640f06a5197048a6d3e4aa31c7c Mon Sep 17 00:00:00 2001 From: "Francisco Blas (klondike) Izquierdo Riera" Date: Tue, 4 Oct 2022 11:17:25 +0200 Subject: [PATCH] media-libs/kvazaar: fix AVX2 flags on GCC On older CPUS without support for popcnt or lzcnt compilation of kvazaar fails due to these instructions being used by the AVX2 code but the relevant flags to support them not being set by the Makefile. Upstream fixed this in commit 99423a825027c862bbfd50e112a1846a013b01a7 Backport this patch so compilation works again on systems without CPU support for these instructions. Closes: https://bugs.gentoo.org/739776 Bug: https://github.com/ultravideo/kvazaar/pull/301 Signed-off-by: Francisco Blas (klondike) Izquierdo Riera --- .../files/kvazaar-2.0.0-fix-avx2-flags.patch | 33 +++++++++++++++++++ media-libs/kvazaar/kvazaar-2.0.0.ebuild | 6 +++- media-libs/kvazaar/kvazaar-2.1.0.ebuild | 4 +++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 media-libs/kvazaar/files/kvazaar-2.0.0-fix-avx2-flags.patch diff --git a/media-libs/kvazaar/files/kvazaar-2.0.0-fix-avx2-flags.patch b/media-libs/kvazaar/files/kvazaar-2.0.0-fix-avx2-flags.patch new file mode 100644 index 00000000000..f2ae8ae4415 --- /dev/null +++ b/media-libs/kvazaar/files/kvazaar-2.0.0-fix-avx2-flags.patch @@ -0,0 +1,33 @@ +From 99423a825027c862bbfd50e112a1846a013b01a7 Mon Sep 17 00:00:00 2001 +From: "Francisco Blas (klondike) Izquierdo Riera" +Date: Tue, 4 Oct 2022 10:03:44 +0200 +Subject: [PATCH] Enable -mpopcnt and -mlzcnt on AVX2 + +When -mpopcnt or -mlzcnt are explicitly enabled or disabled +(when using -march=native for example), kvazaar builds fail +on older CPUs without support for these flags (see +https://github.com/ultravideo/kvazaar/issues/228 and +https://bugs.gentoo.org/739776 ). + +Ensuring these flags are on as done with the rest of AVX2 flags +solves the compilation issues, although it may be a better +approach to provide a configuration option so that only the +specific version matching the build system supported flags is +created in such cases. +--- + src/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Makefile.am b/src/Makefile.am +index 79880a98..c972c5be 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -226,7 +226,7 @@ endif #HAVE_PPC + if HAVE_X86 + + if HAVE_AVX2_GCC +-libavx2_la_CFLAGS = -mavx2 -mbmi -mabm -mbmi2 ++libavx2_la_CFLAGS = -mavx2 -mbmi -mabm -mpopcnt -mlzcnt -mbmi2 + endif + if HAVE_AVX2_CLANG + libavx2_la_CFLAGS = -mavx2 -mbmi -mpopcnt -mlzcnt -mbmi2 diff --git a/media-libs/kvazaar/kvazaar-2.0.0.ebuild b/media-libs/kvazaar/kvazaar-2.0.0.ebuild index 34ceb7d503f..6ef96802243 100644 --- a/media-libs/kvazaar/kvazaar-2.0.0.ebuild +++ b/media-libs/kvazaar/kvazaar-2.0.0.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 @@ -35,6 +35,10 @@ DEPEND="${RDEPEND} abi_x86_64? ( ${ASM_DEP} ) " +PATCHES=( + "${FILESDIR}/${P}-fix-avx2-flags.patch" +) + src_prepare() { default sed -e "/^dist_doc_DATA/s/COPYING //" -i Makefile.am || die diff --git a/media-libs/kvazaar/kvazaar-2.1.0.ebuild b/media-libs/kvazaar/kvazaar-2.1.0.ebuild index a7e7e1cd5a7..1d013a574e7 100644 --- a/media-libs/kvazaar/kvazaar-2.1.0.ebuild +++ b/media-libs/kvazaar/kvazaar-2.1.0.ebuild @@ -35,6 +35,10 @@ DEPEND="${RDEPEND} abi_x86_64? ( ${ASM_DEP} ) " +PATCHES=( + "${FILESDIR}/${PN}-2.0.0-fix-avx2-flags.patch" +) + src_prepare() { default sed -e "/^dist_doc_DATA/s/COPYING //" -i Makefile.am || die -- 2.34.1