Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 595526

Summary: media-libs/libwebp-0.5.1 - error: inlining failed in call to always_inline ‘_mm_cvtepu8_epi16’: target specific option mismatch
Product: Gentoo Linux Reporter: Andrey <xor29a>
Component: Current packagesAssignee: Gentoo Graphics Project <graphics+disabled>
Status: RESOLVED FIXED    
Severity: normal CC: chromium, jan_braun, laurent
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 598208    
Attachments: build log
Allow to disable see2 and sse4.1 auto-detection.

Description Andrey 2016-09-29 13:27:01 UTC
Can't build media-libs/libwebp-0.5.1, because of error:

In file included from /var/tmp/portage/media-libs/libwebp-0.5.1/work/libwebp-0.5.1/src/dsp/enc_sse41.c:17:0:
/var/tmp/portage/media-libs/libwebp-0.5.1/work/libwebp-0.5.1/src/dsp/enc_sse41.c: In function ‘TTransform’:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/smmintrin.h:550:1: error: inlining failed in call to always_inl
ine ‘_mm_cvtepu8_epi16’: target specific option mismatch
 _mm_cvtepu8_epi16 (__m128i __X)
 ^

Reproducible: Always

Steps to Reproduce:
1. Try to build media-libs/libwebp-0.5.1
Actual Results:  
build error

Expected Results:  
success build

# emerge --info
Portage 2.3.1 (python 2.7.12-final-0, default/linux/amd64/13.0/desktop, gcc-5.4.0, glibc-2.23-r2, 3.14-1-amd64 x86_64)
=================================================================
System uname: Linux-3.14-1-amd64-x86_64-Intel-R-_Xeon-R-_CPU_E3-1230_V2_@_3.30GHz-with-gentoo-2.3
KiB Mem:    16441872 total,    190180 free
KiB Swap:   31248380 total,  31139412 free
Timestamp of repository gentoo: Thu, 29 Sep 2016 05:00:01 +0000
sh bash 4.4
ld GNU ld (Gentoo 2.26.1 p1.0) 2.26.1
app-shells/bash:          4.4::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.0-r1::gentoo
dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo
dev-util/cmake:           3.6.2::gentoo
dev-util/pkgconfig:       0.29.1::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.22::gentoo
sys-apps/sandbox:         2.10-r2::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r2::gentoo
sys-devel/automake:       1.11.6-r2::gentoo, 1.13.4-r1::gentoo, 1.14.1-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.26.1::gentoo
sys-devel/gcc:            5.4.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r2::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.7::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

xorik-link
    location: /usr/local/portage/xorik-link
    masters: gentoo
    priority: 0

xorik
    location: /usr/local/portage/xorik
    masters: gentoo
    priority: 1

dev-zero
    location: /usr/local/portage/dev-zero
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/dev/dev-zero
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=core2 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=core2 -fstack-protector-strong"
CHOST="x86_64-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/php/apache2-php5.6/ext-active/ /etc/php/cgi-php5.6/ext-active/ /etc/php/cli-php5.6/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=core2 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=core2 -fstack-protector-strong"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --fail-clean=y --quiet-build=y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fail-clean fixlafiles merge-sync metadata-transfer news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles "
LANG="ru_RU.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j10"
PKGDIR="/usr/portage/packages"
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="X a52 aac acl acpi alsa amd64 berkdb branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx dbus dri dts dvd dvdr emboss encode exif fam firefox flac fortran gdbm gif glamor gnome gpm gtk iconv icu idn ipv6 jpeg laptop lcms libav libnotify mad mmx mmxext mng modules mp3 mp4 mpeg multilib natspec ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds qt3support readline sdl seccomp session spell sse sse2 sse3 ssl startup-notification svg tcpd threads tiff truetype udev udisks unicode upower usb userlocales vorbis wifi wxwidgets x264 xattr xcb xinerama xml xorg xv xvid zlib" ABI_X86="64" ALSA_CARDS="hda-intel" 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="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="mouse keyboard synaptics evdev joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="ru ru_RU" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby23" USERLAND="GNU" VIDEO_CARDS="intel i810 i915 i965" 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, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Andrey 2016-09-29 13:46:06 UTC
Created attachment 448418 [details]
build log
Comment 2 Jan-Matthias Braun 2016-11-02 16:36:23 UTC
Created attachment 452184 [details, diff]
Allow to disable see2 and sse4.1 auto-detection.

I am seeing the problem on a machine that has sse4.1 but is building for a machine which does not. The configure script then enables sse4.1 but this fails to compile with the CFLAGS for the destination cpu.

The attached patch uses the CPU_FLAGS_X86 variable to disable see2 and sse4.1 auto-detection.

As far as I understand it, it does not what one would expect ,i.e., enable sse conditioned on the variable, but instead it disables sse when the variable is not set.

Nonetheless, this patch allows to disable and thus compile in the above scenario.
Comment 3 Andrey 2016-11-02 17:49:51 UTC
Yes, you're right. I trying to build on modern PC but use CFLAGS for not so modern. Sorry, I forgot to mention that.

I will try to check the patch today and let you know, if it helps. Thank you
Comment 4 Andrey 2016-11-03 08:40:57 UTC
Yes, the patch helps, thank you!
Comment 5 Mike Gilbert gentoo-dev 2017-01-15 00:58:35 UTC
The problem here is triggered by your CFLAGS. They cause the compiler to be called like this:

gcc ... -msse4.1 ... -mno-sse4.1 ...

So the build system enables sse4.1, but then your CFLAGS disable it.

The code calls the CPUID instruction to determine what flags are enabled at runtime; there's no real need to disable the instructions at build time.
Comment 6 Mike Gilbert gentoo-dev 2017-01-15 01:16:01 UTC
*** Bug 605500 has been marked as a duplicate of this bug. ***
Comment 7 Mike Gilbert gentoo-dev 2017-01-15 01:19:03 UTC
(In reply to Jan-Matthias Braun from comment #2)

Thanks, I pushed a similar patch. Disabling the build time detection is strictly unnecessary, but it's probably the easiest way to resolve this.

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

commit b804ac8b176f70a0b71ac8dad768f7bb28bd2eda
Author: Mike Gilbert <floppym@gentoo.org>
Date:   Sat Jan 14 20:11:46 2017 -0500

    media-libs/libwebp: add USE flags for avx2, sse2, sse4.1, and neon
    
    Bug: https://bugs.gentoo.org/595526
    Package-Manager: Portage-2.3.3_p32, Repoman-2.3.1_p25

 media-libs/libwebp/libwebp-0.5.2.ebuild | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Comment 8 Jan-Matthias Braun 2017-01-15 13:39:12 UTC
Thanks for pushing a fix.

Actually, I do think it is necessary to disable build time CPU detection. In my case, I am compiling for a weaker CPU on a different machine. A process, which is in general quite painless with Gentoo.
In my experience, you have to disable CPU features which are unavailable on the target machine to get code which executes.

So, thanks for supporting this use case!
Comment 9 SpanKY gentoo-dev 2017-01-17 23:37:10 UTC
(In reply to Jan-Matthias Braun from comment #8)

yep, this is how we're supposed to be writing ebuilds
Comment 10 Mike Gilbert gentoo-dev 2017-01-18 02:20:38 UTC
I am pretty sure runtime CPU detection would have worked just as well here.
Comment 11 Mike Gilbert gentoo-dev 2017-01-18 02:24:43 UTC
To clarify: the build-time check only verifies that the compiler supports flags like -msse2. It does not look at the CPU installed in the build machine at all.

The compiler checks fail due to the -mno-sse2 CFLAGS that you have defined.
Comment 12 SpanKY gentoo-dev 2017-01-18 04:41:46 UTC
(In reply to Mike Gilbert from comment #11)

thanks for the info.  agreed, runtime detection would not be an issue.  i'm not sure if we have a USE flag to control support for this though.  we've just gone with the CPU_FLAGS route and not worried about it.