public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Ionen Wolkens" <ionen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtbase/
Date: Tue,  5 Sep 2023 13:05:47 +0000 (UTC)	[thread overview]
Message-ID: <1693918871.aa6feab907d063181e5bebeb052c3bd72843449b.ionen@gentoo> (raw)

commit:     aa6feab907d063181e5bebeb052c3bd72843449b
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Sat Sep  2 06:09:58 2023 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Tue Sep  5 13:01:11 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aa6feab9

dev-qt/qtbase: workaround x86intrin test and feature selection

qtbase does a single "big" test for all basic cpu features, and if
CXXFLAGS have any matching -mno-* then they will override Qt's
flags and the test fails. Surprised by this, Qt aborts unless
explicitly disable the feature.

Test can be bypassed, but then it does not perform per-flags
tests and will fail to build as-is.

Like bug #913400, debated a few options:

1. cpu_flags_x86_* to enable each feature, but given this is tied to
   compiler flags we'd still need to test them to avoid failures and
   not much better off, not to mention bug #913400 may have added its
   own -mno-* that go against these.

2. Patching cmake files so it always pass its e.g. -mavx2 after the
   user's flags (when needed), and does not rely on -march=haswell
   given that does not override. But fwiw these files do get
   installed and will alter expected behavior, and handling
   -march is more annoying.

3. Patch out the bit that makes the x86intrin test prevent building
   unless explicitly disabled, and let it auto-disable x86intrin
   entirely if tests fail (subpar for performance if ignored).

4. Do self-tests and disable features that will fail, this has the
   advantage that revdeps will not try to use these either.

5. One option to bug #913400 was to force simpler flags, which
   would also solve this.

Picked #4 for now, not that particularly like it given it feels
like automagic. Hoping will be more temporary than qsimd_p.h
workarounds. Better than doing nothing either way, is a no-op
for non-affected users.

Bug: https://bugs.gentoo.org/908420
Closes: https://bugs.gentoo.org/913400
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 dev-qt/qtbase/qtbase-6.5.2-r1.ebuild | 36 +++++++++++++++++++++++++++++++++++-
 dev-qt/qtbase/qtbase-6.5.9999.ebuild | 36 +++++++++++++++++++++++++++++++++++-
 dev-qt/qtbase/qtbase-6.9999.ebuild   | 36 +++++++++++++++++++++++++++++++++++-
 3 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/dev-qt/qtbase/qtbase-6.5.2-r1.ebuild b/dev-qt/qtbase/qtbase-6.5.2-r1.ebuild
index 5fa82d9c7db0..57694adc046b 100644
--- a/dev-qt/qtbase/qtbase-6.5.2-r1.ebuild
+++ b/dev-qt/qtbase/qtbase-6.5.2-r1.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-inherit qt6-build
+inherit flag-o-matic qt6-build toolchain-funcs
 
 DESCRIPTION="Cross-platform application development framework"
 
@@ -222,6 +222,40 @@ src_configure() {
 		-DQT_FEATURE_sql_tds=OFF # currently a no-op in CMakeLists.txt
 	)
 
+	if use amd64 || use x86; then
+		# see bug #913400 for explanations
+		local cpufeats=(
+			# list of checked cpu features in configure.cmake
+			avx avx2 avx512{bw,cd,dq,er,f,ifma,pf,vbmi,vbmi2,vl}
+			f16c rdrnd rdseed sse2 sse3 sse4_1 sse4_2 ssse3 vaes
+		)
+		# handle odd ones out not matching -m* and macros (keep same order)
+		local cpuflags=( "${cpufeats[@]}" aes sha )
+		local cpufeats+=( aesni shani )
+
+		local -a intrins
+		IFS=' ' read -ra intrins < <(
+			: "$(test-flags-CXX "${cpuflags[@]/#/-m}")"
+			$(tc-getCXX) -E -P ${_} ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | tail -n 1
+				#if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
+				#include <x86intrin.h>
+				#endif
+				$(printf '__%s__ ' "${cpuflags[@]^^}")
+			EOF
+			assert
+		)
+
+		# do nothing and leave to qtbase if no macros expanded (test failed?)
+		if [[ \ ${intrins[*]} == *\ [^_\ ]* ]]; then
+			local -i i
+			for ((i=0; i<${#cpufeats[@]}; i++)); do
+				[[ ${intrins[i]} == __* ]] &&
+					mycmakeargs+=( -DQT_FEATURE_${cpufeats[i]}=OFF )
+			done
+			mycmakeargs+=( -DTEST_x86intrin=ON )
+		fi
+	fi
+
 	qt6-build_src_configure
 }
 

diff --git a/dev-qt/qtbase/qtbase-6.5.9999.ebuild b/dev-qt/qtbase/qtbase-6.5.9999.ebuild
index 3c339f31f8b7..a71f3078a605 100644
--- a/dev-qt/qtbase/qtbase-6.5.9999.ebuild
+++ b/dev-qt/qtbase/qtbase-6.5.9999.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-inherit qt6-build
+inherit flag-o-matic qt6-build toolchain-funcs
 
 DESCRIPTION="Cross-platform application development framework"
 
@@ -217,6 +217,40 @@ src_configure() {
 		-DQT_FEATURE_sql_tds=OFF # currently a no-op in CMakeLists.txt
 	)
 
+	if use amd64 || use x86; then
+		# see bug #913400 for explanations
+		local cpufeats=(
+			# list of checked cpu features in configure.cmake
+			avx avx2 avx512{bw,cd,dq,er,f,ifma,pf,vbmi,vbmi2,vl}
+			f16c rdrnd rdseed sse2 sse3 sse4_1 sse4_2 ssse3 vaes
+		)
+		# handle odd ones out not matching -m* and macros (keep same order)
+		local cpuflags=( "${cpufeats[@]}" aes sha )
+		local cpufeats+=( aesni shani )
+
+		local -a intrins
+		IFS=' ' read -ra intrins < <(
+			: "$(test-flags-CXX "${cpuflags[@]/#/-m}")"
+			$(tc-getCXX) -E -P ${_} ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | tail -n 1
+				#if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
+				#include <x86intrin.h>
+				#endif
+				$(printf '__%s__ ' "${cpuflags[@]^^}")
+			EOF
+			assert
+		)
+
+		# do nothing and leave to qtbase if no macros expanded (test failed?)
+		if [[ \ ${intrins[*]} == *\ [^_\ ]* ]]; then
+			local -i i
+			for ((i=0; i<${#cpufeats[@]}; i++)); do
+				[[ ${intrins[i]} == __* ]] &&
+					mycmakeargs+=( -DQT_FEATURE_${cpufeats[i]}=OFF )
+			done
+			mycmakeargs+=( -DTEST_x86intrin=ON )
+		fi
+	fi
+
 	qt6-build_src_configure
 }
 

diff --git a/dev-qt/qtbase/qtbase-6.9999.ebuild b/dev-qt/qtbase/qtbase-6.9999.ebuild
index 3c339f31f8b7..a71f3078a605 100644
--- a/dev-qt/qtbase/qtbase-6.9999.ebuild
+++ b/dev-qt/qtbase/qtbase-6.9999.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-inherit qt6-build
+inherit flag-o-matic qt6-build toolchain-funcs
 
 DESCRIPTION="Cross-platform application development framework"
 
@@ -217,6 +217,40 @@ src_configure() {
 		-DQT_FEATURE_sql_tds=OFF # currently a no-op in CMakeLists.txt
 	)
 
+	if use amd64 || use x86; then
+		# see bug #913400 for explanations
+		local cpufeats=(
+			# list of checked cpu features in configure.cmake
+			avx avx2 avx512{bw,cd,dq,er,f,ifma,pf,vbmi,vbmi2,vl}
+			f16c rdrnd rdseed sse2 sse3 sse4_1 sse4_2 ssse3 vaes
+		)
+		# handle odd ones out not matching -m* and macros (keep same order)
+		local cpuflags=( "${cpufeats[@]}" aes sha )
+		local cpufeats+=( aesni shani )
+
+		local -a intrins
+		IFS=' ' read -ra intrins < <(
+			: "$(test-flags-CXX "${cpuflags[@]/#/-m}")"
+			$(tc-getCXX) -E -P ${_} ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | tail -n 1
+				#if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
+				#include <x86intrin.h>
+				#endif
+				$(printf '__%s__ ' "${cpuflags[@]^^}")
+			EOF
+			assert
+		)
+
+		# do nothing and leave to qtbase if no macros expanded (test failed?)
+		if [[ \ ${intrins[*]} == *\ [^_\ ]* ]]; then
+			local -i i
+			for ((i=0; i<${#cpufeats[@]}; i++)); do
+				[[ ${intrins[i]} == __* ]] &&
+					mycmakeargs+=( -DQT_FEATURE_${cpufeats[i]}=OFF )
+			done
+			mycmakeargs+=( -DTEST_x86intrin=ON )
+		fi
+	fi
+
 	qt6-build_src_configure
 }
 


             reply	other threads:[~2023-09-05 13:05 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 13:05 Ionen Wolkens [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-26 12:29 [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtbase/ Ionen Wolkens
2025-02-26  8:47 Ionen Wolkens
2025-02-26  8:47 Ionen Wolkens
2025-02-26  8:47 Ionen Wolkens
2025-02-22 14:46 Arthur Zamarin
2025-02-20 22:38 James Le Cuirot
2025-02-02 12:27 Ionen Wolkens
2024-12-27 12:02 Sam James
2024-12-18  4:37 Ionen Wolkens
2024-12-18  4:37 Ionen Wolkens
2024-12-03 18:16 Ionen Wolkens
2024-11-02 14:10 Arthur Zamarin
2024-11-01  6:35 Arthur Zamarin
2024-10-09  6:22 Ionen Wolkens
2024-09-03  7:44 Ionen Wolkens
2024-09-02 17:52 Ionen Wolkens
2024-08-26 22:08 Ionen Wolkens
2024-08-25 20:27 Eli Schwartz
2024-07-25  6:22 Ionen Wolkens
2024-07-25  6:22 Ionen Wolkens
2024-07-25  6:22 Ionen Wolkens
2024-07-22 22:53 Ionen Wolkens
2024-07-21 12:54 Ionen Wolkens
2024-07-08 16:40 Arthur Zamarin
2024-07-08 10:09 Sam James
2024-07-03  0:39 Ionen Wolkens
2024-06-02  8:22 Ionen Wolkens
2024-04-02  6:09 Arthur Zamarin
2024-03-30  0:29 Ionen Wolkens
2024-03-25 22:10 Ionen Wolkens
2024-03-24 18:39 Ionen Wolkens
2024-03-22  6:16 Arthur Zamarin
2024-02-29  2:09 Ionen Wolkens
2024-01-23 14:36 Ionen Wolkens
2024-01-23 14:36 Ionen Wolkens
2024-01-19 22:13 Ionen Wolkens
2024-01-08 21:09 Ionen Wolkens
2024-01-08 12:59 Ionen Wolkens
2024-01-08 12:59 Ionen Wolkens
2024-01-07 15:20 Ionen Wolkens
2024-01-07 15:20 Ionen Wolkens
2023-12-18  1:37 Ionen Wolkens
2023-12-01 19:48 Jakov Smolić
2023-12-01  7:04 Ionen Wolkens
2023-12-01  6:21 Sam James
2023-12-01  6:21 Sam James
2023-11-30  5:29 Ionen Wolkens
2023-11-29 22:33 Sam James
2023-10-27 11:40 Ionen Wolkens
2023-10-27 11:40 Ionen Wolkens
2023-10-22  4:51 Ionen Wolkens
2023-10-17 21:19 Ionen Wolkens
2023-10-10 18:09 Ionen Wolkens
2023-10-10 14:51 Ionen Wolkens
2023-09-26 15:16 Ionen Wolkens
2023-09-26 12:24 Ionen Wolkens
2023-09-24 17:51 Ionen Wolkens
2023-09-24 17:09 WANG Xuerui
2023-09-24 17:09 WANG Xuerui
2023-09-22 20:53 Sam James
2023-09-20  8:32 Ionen Wolkens
2023-09-19  3:02 Ionen Wolkens
2023-09-19  3:02 Ionen Wolkens
2023-09-17  2:11 Ionen Wolkens
2023-09-17  1:59 Ionen Wolkens
2023-09-13 16:42 Ionen Wolkens
2023-09-13 16:42 Ionen Wolkens
2023-09-12 11:44 Ionen Wolkens
2023-09-12 11:44 Ionen Wolkens
2023-09-12  1:28 Sam James
2023-09-12  1:26 Sam James
2023-09-12  0:13 Ionen Wolkens
2023-09-11 22:59 Sam James
2023-09-09 16:22 Ionen Wolkens
2023-09-09 16:22 Ionen Wolkens
2023-09-09 16:22 Ionen Wolkens
2023-09-06  8:49 Ionen Wolkens
2023-09-05 14:31 Ionen Wolkens
2023-06-10 14:33 Jimi Huotari
2023-06-10 14:33 Jimi Huotari
2023-06-02 15:39 Jimi Huotari
2023-05-24  6:52 Jimi Huotari
2023-05-23  2:52 Sam James
2023-05-06 11:26 Jimi Huotari
2023-04-17 19:39 Jimi Huotari
2023-04-17 19:39 Jimi Huotari
2023-03-26 16:59 Jimi Huotari
2023-03-19 13:09 Jimi Huotari
2023-02-09 10:02 Andreas Sturmlechner
2023-01-05 22:39 Jimi Huotari
2022-12-01 19:19 Andreas Sturmlechner
2022-09-24 14:32 Andreas Sturmlechner
2022-08-02 22:00 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1693918871.aa6feab907d063181e5bebeb052c3bd72843449b.ionen@gentoo \
    --to=ionen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox