Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 898644 - dev-qt/qtbase-6.4.2 - src/corelib/global/qsimd_p.h:218:8: error: #error "Please enable all x86 -64-v3 extensions; you probably want to use -march=haswell or -march=x86-64-v3 instead of -mavx2"
Summary: dev-qt/qtbase-6.4.2 - src/corelib/global/qsimd_p.h:218:8: error: #error "Plea...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Qt Bug Alias
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2023-03-01 23:45 UTC by Mike Gilbert
Modified: 2023-09-14 20:43 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
build log (dev-qt:qtbase-6.4.2:20230301-211155.log,46.68 KB, text/plain)
2023-03-01 23:45 UTC, Mike Gilbert
Details
Don't error on partial support for x86-64 v3/v4 (0001-Don-t-error-on-partial-support-for-x86-64-v3-v4.patch,1.86 KB, patch)
2023-03-02 03:14 UTC, Mike Gilbert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Gilbert gentoo-dev 2023-03-01 23:45:26 UTC
Created attachment 855490 [details]
build log

> FAILED: src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/global/qfloat16.cpp.o 
> /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -DQT_BOOTSTRAPPED -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_TYPESAFE_FLAGS -DQT_USE_QSTRINGBUILDER -DQT_VERSION_MAJOR=6 -DQT_VERSION_MINOR=4 -DQT_VERSION_PATCH=2 -DQT_VERSION_STR=\"6.4.2\" -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/src/corelib/Core_autogen/include -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/src/corelib -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/src/corelib -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/src/corelib/global -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/src/corelib/kernel -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/src/corelib/../3rdparty/tinycbor/src -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2 -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/src/corelib/../3rdparty/forkfd -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/src/corelib/.rcc -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/mkspecs/linux-g++ -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/src/tools/bootstrap/.. -I/x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/src/tools/bootstrap/../../3rdparty/tinycbor/src  -O2 -pipe -march=amdfam10 -O2 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -ffunction-sections -fdata-sections -Wsuggest-override -std=gnu++17 -MD -MT src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/global/qfloat16.cpp.o -MF src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/global/qfloat16.cpp.o.d -o src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/global/qfloat16.cpp.o -c /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/src/corelib/global/qfloat16.cpp
> In file included from /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/qsimd_p.h:1,
>                  from /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2/src/corelib/global/qfloat16.cpp:6:
> /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/../../../../../../qtbase-everywhere-src-6.4.2/src/corelib/global/qsimd_p.h:218:8: error: #error "Please enable all x86-64-v3 extensions; you probably want to use -march=haswell or -march=x86-64-v3 instead of -mavx2"
>   218 | #      error "Please enable all x86-64-v3 extensions; you probably want to use -march=haswell or -march=x86-64-v3 instead of -mavx2"
>       |        ^~~~~
> /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/../../../../../../qtbase-everywhere-src-6.4.2/src/corelib/global/qsimd_p.h:215:38: error: ‘__AVX2__’ was not declared in this scope
>   215 | #  define ARCH_HASWELL_MACROS       (__AVX2__ + __BMI2__ + __FMA__ + __LZCNT__)
>       |                                      ^~~~~~~~
> /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/../../../../../../qtbase-everywhere-src-6.4.2/src/corelib/global/qsimd_p.h:220:15: note: in expansion of macro ‘ARCH_HASWELL_MACROS’
>   220 | static_assert(ARCH_HASWELL_MACROS, "Undeclared identifiers indicate which features are missing.");
>       |               ^~~~~~~~~~~~~~~~~~~
> /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/../../../../../../qtbase-everywhere-src-6.4.2/src/corelib/global/qsimd_p.h:215:49: error: ‘__BMI2__’ was not declared in this scope
>   215 | #  define ARCH_HASWELL_MACROS       (__AVX2__ + __BMI2__ + __FMA__ + __LZCNT__)
>       |                                                 ^~~~~~~~
> /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/../../../../../../qtbase-everywhere-src-6.4.2/src/corelib/global/qsimd_p.h:220:15: note: in expansion of macro ‘ARCH_HASWELL_MACROS’
>   220 | static_assert(ARCH_HASWELL_MACROS, "Undeclared identifiers indicate which features are missing.");
>       |               ^~~~~~~~~~~~~~~~~~~
> /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/../../../../../../qtbase-everywhere-src-6.4.2/src/corelib/global/qsimd_p.h:215:60: error: ‘__FMA__’ was not declared in this scope
>   215 | #  define ARCH_HASWELL_MACROS       (__AVX2__ + __BMI2__ + __FMA__ + __LZCNT__)
>       |                                                            ^~~~~~~
> /x/portage/dev-qt/qtbase-6.4.2/work/qtbase-everywhere-src-6.4.2_build/include/QtCore/6.4.2/QtCore/private/../../../../../../qtbase-everywhere-src-6.4.2/src/corelib/global/qsimd_p.h:220:15: note: in expansion of macro ‘ARCH_HASWELL_MACROS’
>   220 | static_assert(ARCH_HASWELL_MACROS, "Undeclared identifiers indicate which features are missing.");
>       |               ^~~~~~~~~~~~~~~~~~~
Portage 3.0.45.1_p3 (python 3.11.2-final-0, default/linux/amd64/17.1/desktop/plasma/systemd/merged-usr, gcc-12, glibc-2.36-r7, 6.1.14-dist x86_64)
=================================================================
System uname: Linux-6.1.14-dist-x86_64-AMD_Phenom-tm-_II_X6_1055T_Processor-with-glibc2.36
KiB Mem:    32872752 total,   5061340 free
KiB Swap:          0 total,         0 free
Head commit of repository gentoo: ac8ec5e1b89f51d87708d7a5620464280ef1a484

sh bash 5.2_p15-r2
ld GNU ld (Gentoo 2.40 p2) 2.40.0
ccache version 4.7.4 [enabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p15-r2::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.36.0-r2::gentoo
dev-lang/python:           2.7.18_p16-r1::gentoo, 3.9.16_p1::gentoo, 3.10.10_p1::gentoo, 3.11.2_p1::gentoo
dev-lang/rust:             1.67.1::gentoo
dev-util/ccache:           4.7.4::gentoo
dev-util/cmake:            3.25.2::gentoo
dev-util/meson:            1.0.0::gentoo
sys-apps/baselayout:       2.13-r1::gentoo
sys-apps/sandbox:          2.30-r1::gentoo
sys-apps/systemd:          253::gentoo
sys-devel/autoconf:        2.13-r7::gentoo, 2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.40-r2::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r1::gentoo
sys-devel/gcc:             12.2.1_p20230121-r1::gentoo
sys-devel/gcc-config:      2.10::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             15.0.7::gentoo
sys-devel/llvm:            15.0.7::gentoo
sys-devel/make:            4.4::gentoo
sys-kernel/linux-headers:  6.2::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r7::gentoo
sys-libs/libselinux:       3.4::gentoo
Repositories:

gentoo
    location: /home/floppym/repos/gentoo
    sync-type: git
    sync-uri: ssh://git@git.gentoo.org/repo/gentoo.git
    priority: -1000
    volatile: True

floppym
    location: /home/floppym/repos/floppym
    masters: gentoo
    priority: 30
    volatile: True

cross
    location: /home/floppym/repos/cross
    masters: gentoo
    priority: 40
    volatile: True

local
    location: /home/floppym/repos/local
    masters: gentoo
    priority: 40
    volatile: True

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=amdfam10"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/ssl/certs /usr/share/themes"
CXXFLAGS="-O2 -pipe -march=amdfam10"
DISTDIR="/data/cache/distfiles"
EMERGE_DEFAULT_OPTS="--binpkg-respect-use=y --binpkg-changed-deps=y --dynamic-deps=n --quiet-build=n --quiet-fail=y --with-bdeps=y --jobs=6 --verbose-conflicts"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -march=amdfam10"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg buildpkg-live ccache cgroup clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox multilib-strict network-sandbox parallel-fetch parallel-install preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms sign strict unknown-features-warn unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe -march=amdfam10"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
PKGDIR="/data/cache/binpkgs"
PORTAGE_COMPRESS="gzip"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--ipv4"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/x"
SHELL="/bin/zsh"
USE="X a52 aac acl acpi activities alsa amd64 appindicator branding bzip2 cairo caps cdda cdr cli crypt css cups dbus declarative dri dts dvd dvdr encode exif filecaps flac fontconfig gdbm gif gpm gtk gui iconv icu idn imap ipv6 jpeg kde kwallet lcms libglvnd libnotify libtirpc lzma mad mng mp3 mp4 mpeg mtp multilib ncurses nls nptl offensive ogg opengl pam pango pcre pdf plasma png policykit ppds pulseaudio qml qt5 readline sdl seccomp semantic-desktop sound spell ssl startup-notification svg systemd taglib test-rust theora threads tiff truetype udev udisks unicode upower usb vaapi vdpau vim-syntax vorbis wayland widgets wxwidgets x264 xattr xcb xcomposite xft xinerama xml xv xvid zlib zsh-completion" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 3dnow 3dnowext popcnt sse3 sse4a" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi efi-64 pc" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10 python3_11 python3_9" RUBY_TARGETS="ruby31" USERLAND="GNU" VIDEO_CARDS="radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Mike Gilbert gentoo-dev 2023-03-02 01:52:32 UTC
Removing "-march=amdfam10" from CXXFLAGS resolves the issue.

It looks like this check in qsimd_p.h will trigger an error the selected march has partial support for what Qt upstream terms "x86-64 version 3".

https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/global/qsimd_p.h?h=6.4.2#n204

I think it would make more sense to disable the SIMD optimizations if not all of the required instructions are available.
Comment 2 Mike Gilbert gentoo-dev 2023-03-02 03:14:02 UTC
Created attachment 855500 [details, diff]
Don't error on partial support for x86-64 v3/v4

This resolves the build failure for me.

I can't find any uses of the __haswell__ or __skylake_avx512__ macros, so the whole check seems kind of pointless. I left them intact just in case upstream uses them in the future.

I really don't feel like arguing with upstream about this, so I would appreciate it if we could just carry this downstream. I'll submit PRs for the gentoo and the qt overlay tomorrow.
Comment 3 Chiitoo gentoo-dev 2023-03-02 17:58:25 UTC
I don't mind the patch if it works.  :]

I guess here's at least part of the reasoning for the check to be as it is:

https://code.qt.io/cgit/qt/qtbase.git/commit/src/corelib/global/qsimd_p.h?h=6.5&id=ad65bbe4c06
Comment 4 Mike Gilbert gentoo-dev 2023-03-02 19:01:31 UTC
I reported the issue upstream.

https://bugreports.qt.io/browse/QTBUG-111698

I'll merge the gentoo PR in the meantime.
Comment 5 Larry the Git Cow gentoo-dev 2023-03-02 19:18:38 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=32189d086ac2495b35ea6ed5547b584b731e8532

commit 32189d086ac2495b35ea6ed5547b584b731e8532
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2023-03-02 16:36:53 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-03-02 19:18:29 +0000

    dev-qt/qtbase: apply patch for -march compat
    
    Upstream expects people to use specific -march values, but that just causes
    problems for Gentoo users. Remove the offending check.
    
    Bug: https://bugs.gentoo.org/898644
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 dev-qt/qtbase/files/qtbase-6-march.patch | 46 ++++++++++++++++++++++++++++++++
 dev-qt/qtbase/qtbase-6.4.2.ebuild        |  4 +++
 2 files changed, 50 insertions(+)
Comment 6 Chiitoo gentoo-dev 2023-03-02 19:24:34 UTC
Thanks!

I'll do the overlay one tomorrow if it requires an extra bit set.
Comment 7 Mike Gilbert gentoo-dev 2023-03-02 19:35:20 UTC
Yeah, I'm unable to push to qt.git.

> % git push
> ERROR: Permission to gentoo/qt.git denied to floppym.
Comment 8 Larry the Git Cow gentoo-dev 2023-03-03 10:08:44 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/qt.git/commit/?id=b765522c50168e50a5e07e46d6e0b650c2a11bd0

commit b765522c50168e50a5e07e46d6e0b650c2a11bd0
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2023-03-02 16:29:40 +0000
Commit:     Jimi Huotari <chiitoo@gentoo.org>
CommitDate: 2023-03-03 10:02:56 +0000

    dev-qt/qtbase: apply patch for -march compat
    
    Upstream expects people to use specific -march values, but that just causes
    problems for Gentoo users. Remove the offending check.
    
    Bug: https://bugs.gentoo.org/898644
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>
    Closes: https://github.com/gentoo/qt/pull/266
    Signed-off-by: Jimi Huotari <chiitoo@gentoo.org>

 dev-qt/qtbase/files/qtbase-6-march.patch | 46 ++++++++++++++++++++++++++++++++
 dev-qt/qtbase/qtbase-6.4.9999.ebuild     |  4 +++
 dev-qt/qtbase/qtbase-6.5.9999.ebuild     |  4 +++
 dev-qt/qtbase/qtbase-6.9999.ebuild       |  4 +++
 4 files changed, 58 insertions(+)
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-12 16:07:43 UTC
This came up on the forums at https://forums.gentoo.org/viewtopic-p-8792269.html. 

Looks like the patch got lost, I don't see it in 6.5.1-r1 at least?
Comment 10 Chiitoo gentoo-dev 2023-06-12 19:59:27 UTC
It was reverted here due to an upstream change so I'm not sure it's the same issue, or the fix doesn't cover some case(s):

https://gitweb.gentoo.org/proj/qt.git/commit/?id=c83e0543f5565aef59b04ef30e70a9705dc65a5f
Comment 11 Mike Gilbert gentoo-dev 2023-06-12 20:54:23 UTC
Upstream seems to prefer to play whack-a-mole with CPU flags. I would suggest sending users experiencing issues upstream.
Comment 12 Mike Gilbert gentoo-dev 2023-06-12 20:55:53 UTC
Marking this fixed since my issue was resolved. File new bugs for any new issues please.
Comment 13 Luke A. Guest 2023-06-13 09:02:54 UTC
I'm getting the same issues on an fx-8350. I did wonder if distcc was causing it as the other machine on the network is haswell, but turned off distcc and still get the same errors.
Comment 14 Larry the Git Cow gentoo-dev 2023-09-05 13:05:44 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=47709089ee12235f32005aa2295aec843164af16

commit 47709089ee12235f32005aa2295aec843164af16
Author:     Ionen Wolkens <ionen@gentoo.org>
AuthorDate: 2023-09-02 00:04:21 +0000
Commit:     Ionen Wolkens <ionen@gentoo.org>
CommitDate: 2023-09-05 13:01:11 +0000

    qt6-build.eclass: workaround mismatching cpu flags sets
    
    qsimd_p.h tries determine if x86-64-v3 or v4 sets supported by the
    compiler+flags seem complete, and errors out if not. This works out
    rather badly on Gentoo, even -march=native can fail with some hard.
    
    With qsimd_p.h being a private header this only affects dev-qt/*
    packages, but fwics still need to fix all of dev-qt/* at once given
    they are going to be using private bits from qtbase.
    
    Debated a few options for this:
    
    1. Patch headers (like old fix from bug #898644), but just not setting
       e.g. __haswell__ is not enough when __AVX2__ still confuses some
       code. Then unsetting these without going through the compiler leads
       to left over macros and more confusion. Besides... changing system
       headers behavior (why is __AVX2__ undef with -mavx2!?) only in
       distros tend to end in disaster.
    
    2. Detect issues in qtbase ebuild, then disable x86intrin altogether
       if needed (carries over to other modules) + warn users (aka figure
       it out yourself). Not really great, users may also end up
       mismatching flags between dev-qt/ to fix this and then run into
       issues anyway.
    
    3. Backport the next (wip/unmerged) upstream fix[1] but wait, looks
       like we are currently still playing whack-a-mole:
    #  if defined(__AVX2__)
    // List of features present with -march=x86-64-v3 and not architecturally
    // implied by __AVX2__
    #    define ARCH_HASWELL_MACROS     \
        (__AVX2__ && __BMI__ && __BMI2__ && __F16C__ \
         && __FMA__ && __LZCNT__ && __POPCNT__)
    #    if ARCH_HASWELL_MACROS == 0
    #      error "Please enable all x86-64-v3 extensions; <snip>
        ...so -mno-avx2 -mfma (bug #908420) is fine, older (bug #898644)
        is too, but if for any reason (VMs, buggy hardware, or the machine
        without F16C from bug #910419) anything else is disabled, then the
        issue is still there and may in fact trigger more than before.
    
    4. Similarly to #2, detect issues but in the eclass. Then append
       -mno-* as needed to flags. Not too bad but passing -mno-*
       leads us to bug #913400.
    
    5. Based on users flags, pick highest usable -march=x86-64-v* and
       strip everything else (or strip -march too...). Messy and think
       users wouldn't be happy about this. It would be what upstream
       likely wants us to do though, and causes no further problems.
    
    Ultimately went with #4 for now, bug #913400 needs fixing either way.
    - missing from set in #3 += -mno-avx2 (until #3, also -mno-fma)
    - missing the AVX512* checked in qsimd_h += -mno-avx512*
    (then let compiler disable features that depend on these)
    
    Not great but better than doing nothing, no-op for non-affected users.
    
    [1] https://codereview.qt-project.org/c/qt/qtbase/+/498799
    
    Bug: https://bugs.gentoo.org/898644
    Bug: https://bugs.gentoo.org/913400
    Closes: https://bugs.gentoo.org/908420
    Signed-off-by: Ionen Wolkens <ionen@gentoo.org>

 eclass/qt6-build.eclass | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
Comment 15 Larry the Git Cow gentoo-dev 2023-09-14 20:43:48 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d863cc9d8ea3722e0ecd6c17e89d88830b45f4fb

commit d863cc9d8ea3722e0ecd6c17e89d88830b45f4fb
Author:     Ionen Wolkens <ionen@gentoo.org>
AuthorDate: 2023-09-13 12:58:55 +0000
Commit:     Ionen Wolkens <ionen@gentoo.org>
CommitDate: 2023-09-14 20:39:35 +0000

    qt6-build.eclass: skip matching fma in 6.5.3+
    
    Should no longer hard fail if lack AVX2 while have FMA, however it does
    (still) require to disable AVX2 if lacking anything else for any reason
    (e.g. broken VMs, oddball hardware, perhaps even users intentionally
    disabling a feature because they have a problem with it).
    
    Generally few users should see their flags modified.
    
    Feel the ideal would be for upstream to simply not use features that
    are disabled rather than error about an incomplete set, or just not
    use AVX2 if incomplete.
    
    Bug: https://bugs.gentoo.org/898644
    Bug: https://bugs.gentoo.org/908420
    Bug: https://bugs.gentoo.org/913843
    Signed-off-by: Ionen Wolkens <ionen@gentoo.org>

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