commit:     440e597f923e22b53316ca45037ed453bda43684
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Fri Feb  6 01:53:06 2026 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Fri Feb  6 02:00:13 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=440e597f

qt6-build.eclass: guard -march detection against cpp noise

Should not be necessary but it could prevent future or obscure issues,
and it is a cheap operation.

wrt bug #969664 comment #11, originally thought to have some identifier
that is sed'ed out but a flat ^-march= as the identifier is good enough
and we use it as-is to simplify a bit. Still use sed to "grep" given
it is more guaranteed to be available than grep per the PM spec for
what it is worth.

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

 eclass/qt6-build.eclass | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/eclass/qt6-build.eclass b/eclass/qt6-build.eclass
index 0b107c595bd2..7579a8d7fc46 100644
--- a/eclass/qt6-build.eclass
+++ b/eclass/qt6-build.eclass
@@ -330,17 +330,16 @@ _qt6-build_sanitize_cpu_flags() {
        # determine and the highest(known) usable x86-64 feature level
        # so users will not lose *all* CPU-specific optimizations
        local march=$(
-               $(tc-getCXX) -E -P ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | tail -n 1
+               $(tc-getCXX) -E -P ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | sed -n 
'/^-march=/p' | tail -n 1
                        #if !defined(__EVEX512__) && !defined(__clang__) && 
__GNUC__ >= 16
                        #  define __EVEX512__ 1 /* removed in gcc-16 (bug 
#956750,#969664) */
                        #endif
-                       default
                        #if (__CRC32__ + __LAHF_SAHF__ + __POPCNT__ + __SSE3__ 
+ __SSE4_1__ + __SSE4_2__ + __SSSE3__) == 7
-                       x86-64-v2
+                       -march=x86-64-v2
                        #  if (__AVX__ + __AVX2__ + __BMI__ + __BMI2__ + 
__F16C__ + __FMA__ + __LZCNT__ + __MOVBE__ + __XSAVE__) == 9
-                       x86-64-v3
+                       -march=x86-64-v3
                        #    if (__AVX512BW__ + __AVX512CD__ + __AVX512DQ__ + 
__AVX512F__ + __AVX512VL__ + __EVEX256__ + __EVEX512__) == 7
-                       x86-64-v4
+                       -march=x86-64-v4
                        #    endif
                        #  endif
                        #endif
@@ -349,7 +348,7 @@ _qt6-build_sanitize_cpu_flags() {
        )
 
        filter-flags '-march=*' "${cpuflags[@]/#/-m}" "${cpuflags[@]/#/-mno-}"
-       [[ ${march} == x86-64* ]] && append-flags $(test-flags-CXX 
-march="${march}")
+       [[ -n ${march} ]] && append-flags $(test-flags-CXX "${march}")
        einfo "C(XX)FLAGS adjusted due to frequent -march=*/-m* issues with Qt:"
        einfo "    \"${CXXFLAGS}\""
        einfo "(can override with USE=custom-cflags, but no support will be 
given)"

Reply via email to