Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 773199 - dev-qt/qtcore: Build uses -msse2 -mfpmath=sse on machines without sse2
Summary: dev-qt/qtcore: Build uses -msse2 -mfpmath=sse on machines without sse2
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Qt Bug Alias
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2021-02-27 00:26 UTC by Calvin Walton
Modified: 2024-04-12 10:30 UTC (History)
3 users (show)

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


Attachments
proposed patch of qtcore ebuild (qtcore-5.15.11-r1.diff,701 bytes, patch)
2024-01-03 15:51 UTC, vanilkovy.puding
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Calvin Walton 2021-02-27 00:26:39 UTC
I was attempting to build a qt-based application on my AMD K6-3 system (CHOST=i586-pc-linx-gnu), and the qtgui library failed to build, with one of the build tools giving an illegal instruction exception inside /usr/lib/libQt5Core.so.5

Dissassembly revealed that there was a CMOV that shouldn't be there:

Dump of assembler code for function _Z19qCalculateBlockSizejjj:
   0xa79f2330 <+16>:    test   %eax,%eax
   0xa79f2332 <+18>:    mov    $0xffffffff,%edx
=> 0xa79f2337 <+23>:    cmovs  %edx,%eax
   0xa79f233a <+26>:    ret    
   0xa79f233b <+27>:    lea    0x0(%esi,%eiz,1),%esi

And the compile line for this file was:
i586-pc-linux-gnu-g++ -c -O2 -march=pentium-mmx -mtune=k6-3 -pipe -msse2 -mfpmath=sse -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -Wno-format-overflow -D_REENTRANT -fPIC -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DQFLOAT16_INCLUDE_FAST -DELF_INTERPRETER=\"/lib/ld-linux.so.2\" -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/corelib -I. -Iglobal -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/3rdparty/md5 -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/3rdparty/md4 -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/3rdparty/sha3 -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/3rdparty/harfbuzz/src -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/3rdparty/forkfd -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/3rdparty/tinycbor/src -I.rcc -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/include -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/include/QtCore -I../../include -I../../include/QtCore -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/include/QtCore/5.15.2 -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/include/QtCore/5.15.2/QtCore -I../../include/QtCore/5.15.2 -I../../include/QtCore/5.15.2/QtCore -I.moc -I.tracegen -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/mkspecs/linux-g++ -o .obj/qbytearray.o /var/tmp/portage/dev-qt/qtcore-5.15.2-r2/work/qtbase-everywhere-src-5.15.2/src/corelib/text/qbytearray.cpp

Presumably when -msse2 is passed, gcc assumes that the cpu can do i686 instructions; there were no i586es with sse2, after all. This would likely also cause issues on systems with 32-bit Athlon or Pentium 3 systems if you hit any of the SSE floating-point code.

This appears to be caused by the code in https://github.com/qt/qtbase/blob/5.15/mkspecs/features/qt_module.prf#L189

Reproducible: Always




Portage 3.0.15 (python 3.8.7-final-0, default/linux/x86/17.0/systemd, gcc-10.1.0, glibc-2.32-r7, 5.10.10 i586)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.10.10-i586-AMD-K6-tm-III_Processor-with-glibc2.1.3
KiB Mem:     1031332 total,    496304 free
KiB Swap:    4194300 total,   4178172 free
Timestamp of repository gentoo: Thu, 25 Feb 2021 17:37:14 +0000
Head commit of repository gentoo: e2d55af465c5e93921790aba696870db8c53663b

sh bash 5.1_p4
ld GNU ld (Gentoo 2.34 p6) 2.34.0
app-shells/bash:          5.1_p4::gentoo
dev-lang/perl:            5.32.0-r1::gentoo
dev-lang/python:          3.7.9-r2::gentoo, 3.8.7-r1::gentoo, 3.9.1-r1::gentoo
dev-util/cmake:           3.19.3::gentoo
sys-apps/baselayout:      2.7-r1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.69-r5::gentoo
sys-devel/automake:       1.16.3-r1::gentoo
sys-devel/binutils:       2.34-r2::gentoo
sys-devel/gcc:            10.1.0-r2::gentoo
sys-devel/gcc-config:     2.3.3::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.32-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://anongit.gentoo.org/git/repo/sync/gentoo.git
    priority: -1000
    sync-git-verify-commit-signature: yes

ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="@FREE"
CBUILD="i586-pc-linux-gnu"
CFLAGS="-O2 -march=pentium-mmx -mtune=k6-3 -pipe"
CHOST="i586-pc-linux-gnu"
CONFIG_PROTECT="/etc /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/terminfo"
CXXFLAGS="-O2 -march=pentium-mmx -mtune=k6-3 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--alphabetical --quiet-build"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY 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"
FCFLAGS="-O2 -march=pentium-mmx -mtune=k6-3 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles icecream ipc-sandbox merge-sync multilib-strict news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -march=pentium-mmx -mtune=k6-3 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_CA.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j2"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
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="/var/tmp"
USE="acl berkdb bzip2 caps cli crypt dri fortran gdbm iconv idn ipv6 jpeg libglvnd libtirpc lz4 ncurses nls nptl openmp pam pcre readline seccomp split-usr ssl systemd tcpd truetype udev unicode x86 xattr xinerama zlib zstd" ABI_X86="32" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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="3dnow 3dnowext mmx" 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" INPUT_DEVICES="libinput" KERNEL="linux" 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-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python3_8" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

dev-qt/qtcore-5.15.2-r2::gentoo was built with the following:
USE="-debug -icu -old-kernel systemd -test"
FEATURES="qa-unresolved-soname-deps binpkg-logs binpkg-docompress ipc-sandbox ebuild-locks icecream multilib-strict parallel-fetch sfperms splitdebug userfetch news binpkg-multi-instance sandbox preserve-libs strict xattr usersync config-protect-if-modified binpkg-dostrip unknown-features-warn compressdebug usersandbox unmerge-orphans unmerge-logs distlocks assume-digests merge-sync protect-owned pid-sandbox fixlafiles userpriv"
Comment 1 vanilkovy.puding 2024-01-03 15:51:44 UTC
Created attachment 881374 [details, diff]
proposed patch of qtcore ebuild

I am also affected by this bug when trying to compile qtgui for AMD K6-2. Attached modification of qtcore-5.15.11-r1.ebuild allowed me to compile qtcore and then qtgui without failure.
Comment 2 vanilkovy.puding 2024-01-08 15:30:40 UTC
As I thought about it a little more I think better solution is to modify eclass/qt5-build.eclass file. I added just one check into qt5_base_configure() function an got no problem to build and run QT libraries ever since.

                ...
                # MIPS DSP instruction set extensions
                $(is-flagq -mno-dsp   && echo -no-mips_dsp)
                $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)

+               $(tc-cpp-is-true "defined(__SSE2__)" ${CFLAGS} ${CXXFLAGS} || echo -no-feature-sse2)

                # use pkg-config to detect include and library paths
                -pkg-config
                ...
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-08 15:31:55 UTC
Looks good to me.
Comment 4 Ionen Wolkens gentoo-dev 2024-01-08 21:23:43 UTC
(In reply to vanilkovy.puding from comment #2)
> +               $(tc-cpp-is-true "defined(__SSE2__)" ${CFLAGS} ${CXXFLAGS}
> || echo -no-feature-sse2)
fwiw already doing something similar (testing with cpp) in qtbase and qt6-build for other reasons, so I wouldn't see a problem with this

USE works too if preferred though, in Qt6 USE would've been more involved/messy and then still need to match with what users have in their cxxflags either way.
Comment 5 vanilkovy.puding 2024-04-12 10:30:50 UTC
(In reply to Sam James from comment #3)
> Looks good to me.

So can this be merged then?