commit:     d2d4b0b7154f57c9962e01d75b27b8aacbd8764e
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 11 10:52:55 2024 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Wed Dec 11 11:44:35 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2d4b0b7

qt6-build.eclass: add workaround for cpus with broken rdrand/rdseed

Not perfect but it should prevent failures for the average user.
Formerly meant to check if -march=native is in *FLAGS, but it
shouldn't matter as long as it is not cross.

Can't test myself, but it should work in theory.

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

 eclass/qt6-build.eclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/eclass/qt6-build.eclass b/eclass/qt6-build.eclass
index a0ca9c619405..75630843c087 100644
--- a/eclass/qt6-build.eclass
+++ b/eclass/qt6-build.eclass
@@ -335,6 +335,18 @@ _qt6-build_sanitize_cpu_flags() {
                done
        fi
 
+       # some cpus have broken rdrand/rdseed and it's enabled regardless
+       # with -march=native, Qt detects this and fails (bug #922498)
+       if [[ ! -v sanitize ]] &&
+               ! tc-is-cross-compiler &&
+               # the kernel also detects this and removes it from cpuinfo
+               [[ -r /proc/cpuinfo && $(</proc/cpuinfo) != *rdrand* ]] &&
+               tc-cpp-is-true __RDRND__ ${CXXFLAGS} ${CPPFLAGS}
+       then
+               einfo "Detected CPU with (likely) broken rdrand/rdseed (bug 
#922498)"
+               sanitize=1
+       fi
+
        [[ -v sanitize ]] || return 0 # *should* be fine as-is
 
        # determine highest(known) usable x86-64 feature level

Reply via email to