Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 585166 - sys-devel/llvm-9999 fails, /usr/lib/libffi.so: error adding symbols: File in wrong format
Summary: sys-devel/llvm-9999 fails, /usr/lib/libffi.so: error adding symbols: File in ...
Status: RESOLVED DUPLICATE of bug 338492
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords: NeedPatch
Depends on:
Blocks:
 
Reported: 2016-06-06 11:51 UTC by Machredsch
Modified: 2016-06-11 07:12 UTC (History)
5 users (show)

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


Attachments
build.log (sys-devel:llvm-9999:20160605-164111.log.tar.gz,44.53 KB, application/gzip)
2016-06-06 11:53 UTC, Machredsch
Details
CMake 3.5 patch (0001-cmake-3.5-Search-lib32-on-more-platforms.patch,22.56 KB, patch)
2016-06-10 21:08 UTC, Daniel Scharrer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Machredsch 2016-06-06 11:51:19 UTC
sys-devel/llvm-9999 always fails to emerge: 
/usr/lib/libffi.so: error adding symbols: File in wrong format
Tried it with and without ccache enabled.

emerge --info:

Portage 2.3.0_rc1 (python 3.4.3-final-0, default/linux/amd64/13.0/desktop, gcc-5.3.0, glibc-2.22-r4, 4.6.0-gentoo x86_64)
=================================================================
System uname: Linux-4.6.0-gentoo-x86_64-Intel-R-_Core-TM-_i5-2400_CPU_@_3.10GHz-with-gentoo-2.2
KiB Mem:     8144996 total,   3279228 free
KiB Swap:    2097148 total,   2097148 free
Timestamp of repository gentoo: Mon, 06 Jun 2016 08:15:01 +0000
sh bash 4.3_p42-r1
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
ccache version 3.2.4 [enabled]
app-shells/bash:          4.3_p42-r1::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.10-r1::gentoo, 3.4.3-r1::gentoo
dev-util/ccache:          3.2.4::gentoo
dev-util/cmake:           3.4.3::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.19.1::gentoo
sys-apps/sandbox:         2.10-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.12.6::gentoo, 1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            5.3.0::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.6::gentoo (virtual/os-headers)
sys-libs/glibc:           2.22-r4::gentoo
Repositories:

gentoo
    location: /usr/portage/ebuilds/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.de.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-extra-opts: --human-readable --exclude-from=/etc/portage/rsync_excludes

machredsch
    location: /usr/portage/ebuilds/machredsch
    masters: gentoo
    priority: 0

steam-overlay
    location: /usr/portage/ebuilds/layman/steam-overlay
    sync-type: laymansync
    sync-uri: git://github.com/anyc/steam-overlay.git
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
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/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=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs 5 --load-average 4.4 --with-bdeps y --quiet-build y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs ccache clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://ftp.uni-erlangen.de/pub/mirrors/gentoo http://mirror.eu.oneandone.net/linux/distributions/gentoo/gentoo/ http://mirror.netcologne.de/gentoo/"
LANG="de_DE.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j4 -l3.8"
PKGDIR="/usr/portage/distfiles/binpkg"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--human-readable --exclude-from=/etc/portage/rsync_excludes"
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/portage/tmpfs"
USE="X a52 aac aalib acl acpi alsa amd64 apm bash-completion bcmath bluetooth bzip2 cairo cdda cddb cdr cleartype cli consolekit cracklib crypt ctype cups curl cxx dbus dga djvu dri dts dvd dvdr encode exif fat fbcon ffmpeg flac fontconfig fortran ftp fuse gallium gdbm geoip gif glamor gles gles2 glut gnutls gpm gtk gtk3 haptic iconv idn imagemagick imap imlib innodb joystick jpeg lame lcms libkms libnotify llvm lm_sensors mad matroska mbox mime mmap mms mmx mmxext mng modules mp3 mp4 mpeg multilib musepack ncurses nls nptl ntfs ogg opencl opengl openmp opus pam pcre pdf pie png policykit posix ppds readline rss sasl sdl seccomp session smp sockets spell sse sse2 ssl startup-notification svg tcpd theora threads tiff truetype udev udisks unicode upower usb vaapi vcd vdpau vhosts vorbis wavpack wxwidgets x264 x265 xattr xcb xcomposite xml xmp xpm xv xvid zip 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="access_compat actions alias asis auth_basic auth_digest authn_core authn_file authz_core authz_groupfile authz_host authz_owner authz_user autoindex cache cache_disk cgid charset_lite dbd dir dumpio env expires ext_filter file_cache filter headers imagemap info log_config logio mime mime_magic negotiation reqtimeout rewrite setenvif socache_shmcb speling status substitute unixd usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="canon" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="gnutls" 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" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer pdfimport" LINGUAS="de" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21" SANE_BACKENDS="pixma" USERLAND="GNU" VIDEO_CARDS="fbdev radeon radeonsi" 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, USE_PYTHON

Reproducible: Always

Steps to Reproduce:
1.emerge llvm
2.
3.


Expected Results:  
emerge succeded
Comment 1 Machredsch 2016-06-06 11:53:11 UTC
Created attachment 436624 [details]
build.log
Comment 2 Machredsch 2016-06-06 12:13:35 UTC
emerge -pqv '=sys-devel/llvm-9999::gentoo'

[ebuild  r  U ] sys-devel/llvm-9999 [3.8.0-r2] USE="clang libffi ncurses static-analyzer xml -debug -doc -gold -libedit -lldb -multitarget -ocaml -python {-test}" ABI_X86="32 (64) (-x32)" PYTHON_TARGETS="python2_7" VIDEO_CARDS="radeon" 
[ebuild     U ] sys-devel/clang-9999-r100 [3.8.0-r100] USE="static-analyzer -debug -multitarget -python" ABI_X86="32 (64) (-x32)" 
[blocks b     ] <=sys-devel/clang-9999-r99 ("<=sys-devel/clang-9999-r99" is blocking sys-devel/llvm-9999)
[ebuild  rR   ] media-libs/mesa-9999  USE="classic d3d9 dri3 egl gallium gbm gles2 llvm nptl opencl osmesa udev vdpau xa xvmc -bindist -debug -gles1 -openmax -pax_kernel -pic (-selinux) -vaapi -valgrind -wayland" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="radeonsi (-freedreno) -i915 -i965 -ilo -intel -nouveau -r100 -r200 -r300 -r600 -radeon (-vc4) -vmware" 

The following packages are causing rebuilds:

  (sys-devel/clang-9999-r100:0/9999::gentoo, ebuild scheduled for merge) causes rebuilds for:
    (media-libs/mesa-9999:0/0::gentoo, ebuild scheduled for merge)
  (sys-devel/llvm-9999:0/9999::gentoo, ebuild scheduled for merge) causes rebuilds for:
    (media-libs/mesa-9999:0/0::gentoo, ebuild scheduled for merge)
Comment 3 EoD 2016-06-10 09:57:18 UTC
I can confirm this issue.

It uses "/usr/lib/libffi.so" even though it's building for abi_x86_32.

[1286/3055] /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Target/BPF -I/var/tmp/portage/sys-devel/llvm-9999/work/llvm-9999/lib/Target/BPF -Iinclude -I/var/tm
FAILED: : && /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -fPIC -march=native -O2 -pipe  -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-ma
/usr/lib/libffi.so: error adding symbols: File in wrong format
Comment 4 EoD 2016-06-10 11:13:52 UTC
The issue lies somewhere in the detection of the FFI_LIBRARY_PATH (not _DIR). As you can see below, the "FFI_LIBRARY_DIR:PATH=/usr/lib32" looks fine, but the resulting "FFI_LIBRARY_PATH:FILEPATH=/usr/lib/libffi.so" is broken.

The appropriate cmake lines are in "llvm-9999/cmake/config-ix.cmake":

  find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR})
  if( NOT FFI_LIBRARY_PATH )
    message(FATAL_ERROR "libffi is not found.")
  endif()


Grepping for FFI_LIB after the unsuccessful build 
# grep -Ir FFI_LIBRARY_ .
./llvm-9999-abi_x86_64.amd64/CMakeCache.txt:FFI_LIBRARY_DIR:PATH=/usr/lib64
./llvm-9999-abi_x86_64.amd64/CMakeCache.txt:FFI_LIBRARY_PATH:FILEPATH=/usr/lib64/libffi.so
./llvm-9999-abi_x86_x32.x32/CMakeCache.txt:FFI_LIBRARY_DIR:PATH=/usr/libx32
./llvm-9999-abi_x86_x32.x32/CMakeCache.txt:FFI_LIBRARY_PATH:FILEPATH=/usr/lib/libffi.so
./llvm-9999-abi_x86_32.x86/CMakeCache.txt:FFI_LIBRARY_DIR:PATH=/usr/lib32
./llvm-9999-abi_x86_32.x86/CMakeCache.txt:FFI_LIBRARY_PATH:FILEPATH=/usr/lib/libffi.so
./llvm-9999/CMakeLists.txt:set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so")
./llvm-9999/lib/ExecutionEngine/Interpreter/CMakeLists.txt:  target_link_libraries( LLVMInterpreter PRIVATE ${FFI_LIBRARY_PATH} )
./llvm-9999/docs/CMake.rst:  FFI_LIBRARY_DIR to the directories where ffi.h and libffi.so can be found,
./llvm-9999/cmake/config-ix.cmake:  find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR})
./llvm-9999/cmake/config-ix.cmake:  if( NOT FFI_LIBRARY_PATH )
./llvm-9999/cmake/config-ix.cmake:  list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
./llvm-9999/cmake/config-ix.cmake:  list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})


Is this related to the recent requirement-bump of cmake to 3.4.3?
Comment 5 Daniel Scharrer 2016-06-10 14:16:37 UTC
This is caused by bug #338492.

Patching cmake to search lib32 in addition lib allows llvm to compile for ABI_X86="32 64". I imagine ABI_X86="x32" will need a similar fix.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-06-10 14:21:25 UTC
Unless you are able to provide a good patch, I don't know if I'll be able to look at it before it hits a release. And if it does, I don't know how long it's gonna delay it ;-).
Comment 7 Daniel Scharrer 2016-06-10 14:38:57 UTC
I sent the patch to the CMake list (has trivial merge conflicts for 3.5):
http://public.kitware.com/pipermail/cmake-developers/2016-June/028621.html

However, similar patches have been available for older CMake versions in bug #338492 (and upstream bug linked there) but have been rejected as they (and my patch) still hard-code lib32.
Comment 8 EoD 2016-06-10 19:23:02 UTC
(In reply to Daniel Scharrer from comment #7)
> I sent the patch to the CMake list (has trivial merge conflicts for 3.5):
> http://public.kitware.com/pipermail/cmake-developers/2016-June/028621.html
> 
> However, similar patches have been available for older CMake versions in bug
> #338492 (and upstream bug linked there) but have been rejected as they (and
> my patch) still hard-code lib32.

Nice work, your patch seems to be upstreamed: https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=896ad251

Can you easily extend it for x32? I am personally interested in getting cmake finally working on x32.

Can you provide cmake patches which could be used on the gentoo version? Or do you intend to backport it to 3.4 / 3.5 on upstream?
Comment 9 Daniel Scharrer 2016-06-10 21:08:23 UTC
Created attachment 437088 [details, diff]
CMake 3.5 patch

Sorry, I don't plan to spend more time on this right now - and I don't have any x32 installs to test on anyway.

I have attached the 3.5 patch and there is a patch for 2.8 in the cmake bug report. No idea if either of these apply for 3.4.
Comment 10 EoD 2016-06-10 22:54:13 UTC
(In reply to Daniel Scharrer from comment #9)
> Created attachment 437088 [details, diff] [details, diff]
> CMake 3.5 patch
> 
> Sorry, I don't plan to spend more time on this right now - and I don't have
> any x32 installs to test on anyway.
> 
> I have attached the 3.5 patch and there is a patch for 2.8 in the cmake bug
> report. No idea if either of these apply for 3.4.

I applied the patch on top of cmake 3.4.3 without problems. With this new patched version of cmake, I get an improvement over the result before:

/llvm-9999-abi_x86_64.amd64/CMakeCache.txt:FFI_LIBRARY_DIR:PATH=/usr/lib64
/llvm-9999-abi_x86_64.amd64/CMakeCache.txt:FFI_LIBRARY_PATH:FILEPATH=/usr/lib64/libffi.so
/llvm-9999-abi_x86_x32.x32/CMakeCache.txt:FFI_LIBRARY_DIR:PATH=/usr/libx32
/llvm-9999-abi_x86_x32.x32/CMakeCache.txt:FFI_LIBRARY_PATH:FILEPATH=/usr/lib32/libffi.so
/llvm-9999-abi_x86_32.x86/CMakeCache.txt:FFI_LIBRARY_DIR:PATH=/usr/lib32
/llvm-9999-abi_x86_32.x86/CMakeCache.txt:FFI_LIBRARY_PATH:FILEPATH=/usr/lib32/libffi.so


Now we "only" need to write a similar patch for x32...
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-06-11 07:12:56 UTC
Thanks a lot for your effort. I'm going to move the relevant bits to the original bug.

*** This bug has been marked as a duplicate of bug 338492 ***