Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 497714 - media-libs/x264-0.0.20130912 - src_configure(): endian test failed with LTO
Summary: media-libs/x264-0.0.20130912 - src_configure(): endian test failed with LTO
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords: PATCH
: 695846 (view as bug list)
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2014-01-10 16:42 UTC by David Kredba
Modified: 2023-01-06 01:58 UTC (History)
13 users (show)

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


Attachments
x264-lto.patch (x264-lto.patch,1.12 KB, patch)
2014-07-02 08:50 UTC, Krzysztof Nowicki
Details | Diff
x264-0.0.20151011-lto.patch (file_497714.txt,1.08 KB, patch)
2015-10-13 09:56 UTC, Sietze Post
Details | Diff
x264-0.0.20170701-lto.patch (x264-0.0.20170701-lto.patch,630 bytes, patch)
2018-03-14 16:19 UTC, Alexander Miller
Details | Diff
Newer patch to fix LTO configure bug (x264-0.0.20190903-r1-lto.patch,678 bytes, patch)
2020-06-14 15:28 UTC, Iade Gesso
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kredba 2014-01-10 16:42:50 UTC
Emerging (4 of 50) media-libs/x264-0.0.20130912
 * x264-snapshot-20130912-2245.tar.bz2 SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                                             [ ok ]
>>> Unpacking source...
>>> Unpacking x264-snapshot-20130912-2245.tar.bz2 to /var/tmp/portage/media-libs/x264-0.0.20130912/work
>>> Source unpacked in /var/tmp/portage/media-libs/x264-0.0.20130912/work
>>> Preparing source in /var/tmp/portage/media-libs/x264-0.0.20130912/work/x264-snapshot-20130912-2245 ...
 * Applying x264-cflags.patch ...                                                                                                                                       [ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/media-libs/x264-0.0.20130912/work/x264-snapshot-20130912-2245 ...
 * amd64: running multilib-minimal_abi_src_configure
endian test failed
 * ERROR: media-libs/x264-0.0.20130912::gentoo failed (configure phase):
 *   (no error message)


Reproducible: Always




Portage 2.2.8 (default/linux/amd64/13.0/no-multilib, gcc-4.9.0-alpha20140110, glibc-2.17, 3.12.6-gentoo x86_64)
=================================================================
System uname: Linux-3.12.6-gentoo-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q9550_@_2.83GHz-with-gentoo-2.2
KiB Mem:     8170356 total,   1211048 free
KiB Swap:    8396796 total,   8358624 free
Timestamp of tree: Fri, 10 Jan 2014 15:30:01 +0000
ld GNU ld (GNU Binutils) 2.24.51.20140109
app-shells/bash:          4.2_p45-r1
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.6, 3.2.5-r3, 3.3.3
dev-util/cmake:           2.8.12.1-r2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.14.1
sys-devel/binutils:       2.24.51
sys-devel/gcc:            4.8.2, 4.9.0_alpha20140110
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           4.0-r1
sys-kernel/linux-headers: 3.12 (virtual/os-headers)
sys-libs/glibc:           2.17
Repositories: gentoo
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"                                                                                                                                                             
CBUILD="x86_64-pc-linux-gnu"                                                                                                                                                   
CFLAGS="-O2 -ggdb -pipe -march=native -mtune=native -flto=4 -fuse-linker-plugin"                                                                                               
CHOST="x86_64-pc-linux-gnu"                                                                                                                                                    
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/bind /var/lib/hsqldb"                                                                               
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -ggdb -pipe -march=native -mtune=native -flto=4 -fuse-linker-plugin"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--quiet-build=n"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch usersandbox usersync xattr"
FFLAGS="-O2 -ggdb -pipe -march=native -mtune=native -flto=4 -fuse-linker-plugin"
GENTOO_MIRRORS="ftp://gentoo.mirror.web4u.cz/"
LANG="cs_CZ.UTF-8"
LDFLAGS="-Wl,--as-needed -Wl,-O2 -Wl,-flto=4 -flto=4 -fuse-linker-plugin -O2 -ggdb -pipe -march=native -mtune=native"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_COMPRESS="echo"
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"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
USE="X a52 aac acl alsa amd64 berkdb blas bluetooth branding bzip2 cairo caps cdda cddb cdparanoia cdr cli cracklib crypt cvs cxx dbus djvu dri dts dv dvb dvd dvdr encode exif fam ffmpeg fftw flac fontconfig fortran ftp gd gdbm geoip gif gmp gnuplot gps graphviz gsl gsm gstreamer gtk hdf5 iconv icu idn ieee1394 imagemagick imlib ipv6 ithreads javascript jbig jpeg jpeg2k kde ladspa lame lapack lcms ldap libass libsamplerate lzma lzo mad matroska mms mmx mmxext mng modplug modules mp3 mp4 mpeg mplayer msn mtp mudflap musepack musicbrainz ncurses netcdf nls nptl ocaml ocamlopt odbc ogg openexr opengl openmp pam pcre pdf perl plotutils png policykit postscript pulseaudio python qt4 quicktime rdesktop readline ruby samba scanner semantic-desktop session slang smp sndfile sox speex spell sse sse2 ssl ssse3 svg szip tcpd theora threads tidy tiff truetype udev unicode usb v4l vcd vdpau vnc vorbis wavpack wmf wxwidgets x264 xattr xcb xft xine xinerama xml xosd xpm xscreensaver xv xvid xvmc zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci 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="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2 adc65 agfa_cl20 aox ax203 barbie canon casio_qv clicksmart310 digigr8 digita dimagev dimera3500 directory enigma13 fuji gsmart300 hp215 iclick jamcam jd11 jl2005a jl2005c kodak_dc120 kodak_dc210 kodak_dc240 kodak_dc3200 kodak_ez200 konica konica_qm150 largan lg_gsm mars mustek panasonic_coolshot panasonic_dc1000 panasonic_dc1580 panasonic_l859 pccam300 pccam600 pentax polaroid_pdc320 polaroid_pdc640 polaroid_pdc700 ricoh ricoh_g3 samsung sierra sipix_blink2 sipix_web2 smal sonix sony_dscf1 sony_dscf55 soundvision spca50x sq905 st2205 stv0674 stv0680 sx330z topfield toshiba_pdrm11 tp6801" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" FFTOOLS="aviocat cws2fws ffescape ffeval fourcc2pixfmt graph2dot ismindex pktdumper qt-faststart trasher ffhash" GPSD_PROTOCOLS="aivdm ashtech earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 navcom nmea ntrip oceanserver oncore rtcm104v2 rtcm104v3 sirf superstar2 tnt tripmate tsip ubx fury geostar nmea2000" GRUB_PLATFORMS="pc" INPUT_DEVICES="evdev keyboard mouse joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer scripting-beanshell scripting-javascript nlpsolver" LINGUAS="cs en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2 python3_3" QEMU_SOFTMMU_TARGETS="x86_64 arm i386" QEMU_USER_TARGETS="arm i386 x86_64" RUBY_TARGETS="ruby19 ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="nouveau" 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"
USE_PYTHON="2.7 3.2 3.3"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-01-10 17:08:34 UTC
Please attach your config.log to this bug report.
Comment 2 David Kredba 2014-01-10 17:11:10 UTC
Here it is:

checking whether __ILP32__ is true... no
--------------------------------------------------
conftest.c:2:2: error: #error
 #error
  ^
--------------------------------------------------
Failed program was:
--------------------------------------------------
#if !(__ILP32__)
#error
#endif
--------------------------------------------------
x264 configure script
Command line options: "--prefix=/usr" "--libdir=/usr/lib64" "--disable-cli" "--disable-avs" "--disable-lavf" "--disable-swscale" "--disable-ffms" "--disable-gpac" "--enable-pi

checking whether x86_64-pc-linux-gnu-gcc works... yes
checking whether x86_64-pc-linux-gnu-gcc supports for( int i = 0; i < 9; i++ ); with -std=gnu99... yes
checking whether yasm supports vpmovzxwd ymm0, xmm0... yes
checking whether x86_64-pc-linux-gnu-gcc supports __asm__("pabsw %xmm0, %xmm0");... yes
checking for -mpreferred-stack-boundary=5... yes
DIED: endian test failed
Comment 3 Sean McGovern 2014-01-10 17:44:15 UTC
This is most likely caused by the x32 patch in the ebuild.
Comment 4 Sean McGovern 2014-01-10 17:45:14 UTC
...or the CFLAGS patch.
Comment 5 David Kredba 2014-01-10 19:47:29 UTC
After I deleted lib32/pkgconfig & co folders owned by not yet re-emerged packages (to -multilib) it rebuilt correctly.
Comment 6 David Kredba 2014-01-10 19:58:28 UTC
I am sorry, it did not rebuilt correctly. It fails the same way as before.
I mixed it with before failing libjpegturbo (which I found is -flto problem).
Comment 7 David Kredba 2014-01-10 20:12:59 UTC
When the patch is removed the only difference is that config.log not begins with
#if !(__ILP32__)
#error
#endif

The rest is the same.

When I ran this by hand it not writes anything to output and .o file is created.

echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c

gcc -O2 -ggdb -pipe -march=native -mtune=native -flto=4 -fuse-linker-plugin conftest.c -c -o conftest.o

/root/conftest.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
0000000000000001 C __gnu_lto_slim
0000000000000001 C __gnu_lto_v1

Without -flto:
/root/conftest.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
0000000000000000 D f
0000000000000010 D i


And my final sorry, without -flto -fuse-linker-plugin it compiles fine.
Next time I will try to do deeper research before opening a case here.

Until authors will count with LTO this have to be built without LTO.

Would you like to submit filtering cflags or have I to close this as invalid?
Comment 8 Krzysztof Nowicki 2014-07-02 08:50:10 UTC
Created attachment 380064 [details, diff]
x264-lto.patch

Looks like the problem is the assumption that the object file generated by 'gcc -c' will contain the binary representation of the code. This will be true for non-LTO builds or for LTO with -ffat-lto-objects. Since fat objects are disabled starting with GCC 4.9 the grep command is unable to find the expected binary data in the object file, which contains only GIMPLE.

There could be several ways to fix this. The attached patch modifies the test to produce a shared object instead of a plain object. This will invoke the linker and is guaranteed to produce a binary object regardless of the used CFLAGS.
Comment 9 Karol Herbst 2015-02-24 16:51:48 UTC
yeah, I have the same error with gcc-4.9 and lto
Comment 10 Sietze Post 2015-10-13 09:56:28 UTC
Created attachment 414492 [details, diff]
x264-0.0.20151011-lto.patch

Compiling without LTO or patching is still needed for x264-0.0-20151010
Comment 11 Pacho Ramos gentoo-dev 2016-12-05 20:09:51 UTC
is this still valid with x264-0.0.20160712?
Comment 12 Petross404(Petros S) 2017-04-20 13:17:48 UTC
(In reply to Pacho Ramos from comment #11)
> is this still valid with x264-0.0.20160712?

That is what I get as an error:
[ebuild   R    ] media-libs/x264-0.0.20160712:0/148::gentoo  USE="interlaced threads -10bit -opencl -pic -static-libs" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) media-libs/x264-0.0.20160712::gentoo
 * x264-snapshot-20160712-2245.tar.bz2 SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                                                                                                                 [ ok ]
>>> Unpacking source...
>>> Unpacking x264-snapshot-20160712-2245.tar.bz2 to /tmp/portage/media-libs/x264-0.0.20160712/work
>>> Source unpacked in /tmp/portage/media-libs/x264-0.0.20160712/work
>>> Preparing source in /tmp/portage/media-libs/x264-0.0.20160712/work/x264-snapshot-20160712-2245 ...
>>> Source prepared.
>>> Configuring source in /tmp/portage/media-libs/x264-0.0.20160712/work/x264-snapshot-20160712-2245 ...
 * abi_x86_64.amd64: running multilib-minimal_abi_src_configure
endian test failed
 * ERROR: media-libs/x264-0.0.20160712::gentoo failed (configure phase):
 *   (no error message)
 * 
 * Call stack:
 *     ebuild.sh, line  115:  Called src_configure
 *   environment, line 2951:  Called multilib-minimal_src_configure
 *   environment, line 2128:  Called multilib_foreach_abi 'multilib-minimal_abi_src_configure'
 *   environment, line 2342:  Called multibuild_foreach_variant '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 2058:  Called _multibuild_run '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 2056:  Called _multilib_multibuild_wrapper 'multilib-minimal_abi_src_configure'
 *   environment, line  449:  Called multilib-minimal_abi_src_configure
 *   environment, line 2122:  Called multilib_src_configure
 *   environment, line 2561:  Called die
 * The specific snippet of code:
 *       "${S}/configure" --prefix="${EPREFIX}"/usr --libdir="${EPREFIX}"/usr/$(get_libdir) --disable-cli --disable-avs --disable-lavf --disable-swscale --disable-ffms --disable-gpac --enable-pic --enable-shared --host="${CHOST}" $(usex 10bit "--bit-depth=10" "") $(usex interlaced "" "--disable-interlaced") $(usex opencl "" "--disable-opencl") $(usex static-libs "--enable-static" "") $(usex threads "" "--disable-thread") ${asm_conf} || die
 * 
 * If you need support, post the output of `emerge --info '=media-libs/x264-0.0.20160712::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=media-libs/x264-0.0.20160712::gentoo'`.
 * The complete build log is located at '/var/log/portage/media-libs:x264-0.0.20160712:20170420-131231.log'.
 * For convenience, a symlink to the build log is located at '/tmp/portage/media-libs/x264-0.0.20160712/temp/build.log'.
 * The ebuild environment file is located at '/tmp/portage/media-libs/x264-0.0.20160712/temp/environment'.
 * Working directory: '/tmp/portage/media-libs/x264-0.0.20160712/work/x264-snapshot-20160712-2245-abi_x86_64.amd64'
 * S: '/tmp/portage/media-libs/x264-0.0.20160712/work/x264-snapshot-20160712-2245'

>>> Failed to emerge media-libs/x264-0.0.20160712, Log file:


I downloaded the x264-0.0.20151011-lto.patch inside /etc/portage/patches/media-libs/x264, but no luck. I don't even see that the patch is applied.
Comment 13 Petross404(Petros S) 2017-04-20 13:42:12 UTC
@Pacho Ramos 

Ok, I followed what is written in the [1]comments and now it applies the x264-0.0.20151011-lto.patch 

[1]http://dilfridge.blogspot.gr/2012/04/neat-trick-for-testing-patches-in.html

post_src_unpack() {
    if type epatch_user >& /dev/null; then
        cd "${S}"
        epatch_user
    fi
}
....

>>> media-libs/x264-0.0.20160712 merged.

So, it still works for x264. Should this patch be moved in to portage tree?
Comment 14 David Kredba 2017-07-03 17:20:20 UTC
=media-libs/x264-0.0.20170701 has --enable-lto in its options. I will test it again shortly.
And it seems that it is prepared to detect it, for "$debug" = "no":

if [ "$lto" = "auto" ] && [ $compiler = GNU ] && cc_check "" "-flto" ; then
        lto="yes"
        CFLAGS="$CFLAGS -flto"
        LDFLAGS="$LDFLAGS -O3 -flto"
    fi
Comment 15 David Heidelberg (okias) 2017-10-18 14:24:52 UTC
Issue with -flto . Should be set in USE flags?

But using --enable-lto with -flto produce same error. It relies on configure to setup lto.

Needs to be fixed in x264 code.

This bug should be CONFIRMED.
Comment 16 Alexander Miller 2018-03-14 16:19:33 UTC
Created attachment 523910 [details, diff]
x264-0.0.20170701-lto.patch

I've successfully used an even simpler patch for media-libs/x264-0.0.20170701. It adds just a "-fno-lto" to the problematic configure test.
Comment 17 David Carlos Manuelda 2018-08-01 23:09:42 UTC
Still applies for x264-0.0.20170701, and last patch made it working with clang and LTO.
Comment 18 Bernardo Meurer 2019-02-16 00:07:36 UTC
I had not run into this before, but with the latest patch this problem now happens to me as well
Comment 19 Fabio Coatti 2019-02-16 10:22:17 UTC
problem happens again with media-libs/x264-0.0.20190214; same patch as 0.0.20170701 allows test to pass.
Comment 20 Forza 2019-05-07 18:10:40 UTC
Can confirm that putting the patch in /etc/portage/patches/media-libs/x264 works on AMD64 with GCC 9.1.0 and x264-20190214.
Comment 21 David Heidelberg (okias) 2019-05-10 11:56:21 UTC
(In reply to Alexander Miller from comment #16)
> Created attachment 523910 [details, diff] [details, diff]
> x264-0.0.20170701-lto.patch
> 
> I've successfully used an even simpler patch for
> media-libs/x264-0.0.20170701. It adds just a "-fno-lto" to the problematic
> configure test.

Can you also meanwhile send it to upstream and reference your pull-request or sent patch here? :)
Comment 22 Fabio Coatti 2019-09-06 10:57:53 UTC
Same issue happens with media-libs/x264-0.0.20190903
Same patch published here fixes it :)
Comment 23 Steve Arnold archtester gentoo-dev 2019-09-15 17:40:50 UTC
Still happens with latest x264 version and toolchain on arm; can we get the workaround in the tree and poke upstream?
Comment 24 Iade Gesso 2020-06-14 15:28:28 UTC
Created attachment 644640 [details, diff]
Newer patch to fix LTO configure bug

The buggy code in the configure file has been moved some row below.
Comment 25 Iade Gesso 2020-06-14 15:29:05 UTC
The LTO problem is still present in x264-0.0.20190903-r1... and the old patch it's not working anymore, due to a change in configure file.

I created a newer version of the patch :) x264-0.0.20190903-r1-lto.patch


Iade Gesso, PhD (in Computer Science)
Comment 26 Davide Palma 2020-06-15 11:32:18 UTC
The change in the configure file is caused by Sergei's Strings patch, that you can find here https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4531c7dc10670235bb6ff4658eb05f6081d4e205 
It also broke gentooLTO's patch. This poses a patch ordering issue. We will probably copy Iade's fix :P
Comment 27 Alexis Ballier gentoo-dev 2020-09-07 13:01:54 UTC
*** Bug 695846 has been marked as a duplicate of this bug. ***
Comment 29 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-06 01:58:50 UTC
This should be fixed in x264-0.0.20220222.