Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 650876 - sys-devel/libtool does not link -lpthread into shared CXX libraries when -pthread is used
Summary: sys-devel/libtool does not link -lpthread into shared CXX libraries when -pth...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: https://debbugs.gnu.org/cgi/bugreport...
Whiteboard:
Keywords: PATCH
: 651630 (view as bug list)
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2018-03-19 13:48 UTC by Craig Andrews
Modified: 2023-12-28 01:23 UTC (History)
8 users (show)

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


Attachments
build.log (media-libs:openexr-2.2.0-r2:20180319-134010.log,589.88 KB, text/x-log)
2018-03-19 13:48 UTC, Craig Andrews
Details
libtool-2.4.6-pthread.patch (libtool-2.4.6-pthread.patch,1.46 KB, patch)
2018-03-24 12:19 UTC, Sergei Trofimovich (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Andrews gentoo-dev 2018-03-19 13:48:15 UTC
Created attachment 524392 [details]
build.log

/bin/sh ../libtool  --tag=CXX   --mode=link x86_64-pc-linux-gnu-g++  -O2 -march=native -pipe -fomit-frame-pointer -flto -fuse-linker-plugin -pthread  -Wl,-O1 -Wl,--as-needed -flto -o exrheader main.o -lImath -lHalf -lIex -lIexMath -lIlmThread -pthread ../IlmImf/libIlmImf.la -lz -pthread
libtool: link: x86_64-pc-linux-gnu-g++ -O2 -march=native -pipe -fomit-frame-pointer -flto -fuse-linker-plugin -pthread -Wl,-O1 -flto -o .libs/exrheader main.o -pthread -pthread  -Wl,--as-needed -L/usr/lib64 ../IlmImf/.libs/libIlmImf.so /usr/lib64/libImath.so /usr/lib64/libHalf.so /usr/lib64/libIexMath.so /usr/lib64/libIlmThread.so /usr/lib64/libIex.so -lz -pthread
/usr/lib64/libIlmThread.so: undefined reference to `pthread_create'
/usr/lib64/libIlmThread.so: undefined reference to `sem_wait'
/usr/lib64/libIlmThread.so: undefined reference to `sem_init'
/usr/lib64/libIlmThread.so: undefined reference to `sem_destroy'
/usr/lib64/libIlmThread.so: undefined reference to `sem_getvalue'
/usr/lib64/libIlmThread.so: undefined reference to `sem_post'
/usr/lib64/libIlmThread.so: undefined reference to `sem_trywait'
/usr/lib64/libIlmThread.so: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:414: exrheader] Error 1
make[1]: Leaving directory '/var/tmp/portage/media-libs/openexr-2.2.0-r2/work/openexr-2.2.0-abi_x86_64.amd64/exrheader'

# emerge --info
Portage 2.3.24 (python 3.5.4-final-0, default/linux/amd64/17.1/systemd, gcc-7.3.0, glibc-2.26-r6, 4.16.0-rc5 x86_64)
=================================================================
System uname: Linux-4.16.0-rc5-x86_64-Intel-R-_Core-TM-_i5-6500_CPU_@_3.20GHz-with-gentoo-2.4.1
KiB Mem:    16021848 total,   1530636 free
KiB Swap:   12337144 total,  11967992 free
Timestamp of repository gentoo: Mon, 19 Mar 2018 13:00:02 +0000
Head commit of repository gentoo: 1170a57f0a741ea9a0ccefc4e6ff1a83997a2763
sh bash 4.4_p19
ld GNU ld (Gentoo 2.30 p1) 2.30.0
ccache version 3.3.4 [disabled]
app-shells/bash:          4.4_p19::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.26.1-r2::gentoo
dev-lang/python:          2.7.14-r1::gentoo, 3.4.6-r1::gentoo, 3.5.4-r1::gentoo
dev-util/ccache:          3.3.4-r1::gentoo
dev-util/cmake:           3.10.3::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1-r2::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r3::gentoo, 1.16.1-r1::gentoo
sys-devel/binutils:       2.30::gentoo
sys-devel/gcc:            7.3.0-r1::gentoo
sys-devel/gcc-config:     1.9.1::gentoo
sys-devel/libtool:        2.4.6-r4::gentoo
sys-devel/make:           4.2.1-r3::gentoo
sys-kernel/linux-headers: 4.15::gentoo (virtual/os-headers)
sys-libs/glibc:           2.26-r6::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-extra-opts: 
    sync-rsync-verify-metamanifest: no

x-portage
    location: /usr/local/portage
    masters: gentoo
    priority: 0

mv
    location: /var/lib/layman/mv
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/user/mv.git
    masters: gentoo
    priority: 50

rust
    location: /var/lib/layman/rust
    sync-type: laymansync
    sync-uri: git://github.com/gentoo/gentoo-rust.git
    masters: gentoo
    priority: 50

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

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA Intel-SDP Oracle-BCLA-JavaSE Oracle-EADLA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=native -pipe -fomit-frame-pointer -flto -fuse-linker-plugin"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.3/conf"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.2/ext-active/ /etc/php/cgi-php7.2/ext-active/ /etc/php/cli-php7.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=native -pipe -fomit-frame-pointer -flto -fuse-linker-plugin"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=4 --load-average=4.5"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs candy cgroup clean-logs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install preserve-libs protect-owned sandbox sfperms splitdebug strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -flto"
LINGUAS="en"
MAKEOPTS="-j5"
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 aacs acl acpi aiglx alac alsa amd64 amr amrnb amrwb animation apache2 apng argon2 artworkextra asf aspnet2 asyncns authdaemond avahi avi bash-completion bcmath berkdb bitmap-fonts bluetooth bluray bmp bonjour brotli btrfs bzip2 cairo caps cdda cddb cdparanoia cdr celt chm clang cli crypt cryptsetup css cups curl cxx daap dbus device-mapper dga dhclient dirac divx4linux dlloader dns dnssec dovecot-sasl dpms dri dri3 dts dv dvb dvd dvdr dvdread egl enca encode exif ext4 faac fam fame fat fbcondecor fbsplash ffmpeg fftw firefox flac fontconfig foomaticdb fortran freetype ftp fuse gaim gd gdbm geoip gif gimpprint glamor gles gles1 gles2 glib glibc-omitfp glitz glut gost gphoto2 gsm gstreamer gstreamer10 gtk gtk2 gudev hardenedphp hbci howl howl-compat http2 https hwdb iconv icu idn imagemagick imap imlib innodb ipv6 java java5 javafx jbig jce joystick jpeg jpeg2k junit kdbus kdehiddenvisibility kvm lapack lcms libfame libkms libnotify librtmp libusb lirc live llvm lm_sensors lvm lz4 lzma lzo mad maildir mdadm mdnsresponder-compat metalink mjpeg mmap mms mng modules motif mozilla mozsvg mp3 mpeg mpeg2 mplayer mpx multilib musepack mysql mythtv natspec ncurses nemesi network networkmanager nls nptl nptlonly ntfs ocl-icd offensive ofx ogg oggvorbis openal opencl openexr opengl openmp openvg opus pam pango pcre pcre16 pcre32 pdf pdflib perl pgo phonon pic pie png pnp policykit ppd ppds pulseaudio python qt qt3 qt3support qt4 quicktime quvi rar readline resolvconf rtc rtmp schroedinger screensaver sctp sdl seccomp session sftp sharedmem shout smp sna sni sox speex spell sqlite ssh ssl steamruntime suspend2 svg systemd theora threads tiff tls transcode truetype truetype-fonts type-fonts udev udisks unicode unzip upnp ups usb user-session uxa v4l2 vaapi vcd vdpau videos virgl vorbis vpx vulkan wayland webdav webp webservices wifi win32codecs wmf wv x264 x265 xanim xattr xcb xcomposite xdg xinerama xml xml2 xpm xprint xrandr xv xvfb xvid xvmc zeroconf zip zlib" ABI_X86="64" ALSA_CARDS="hda-intel" APACHE2_MODULES="actions alias auth_basic authn_core authz_core cache_disk authn_alias authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex brotli cache dav dav_fs dav_lock dconf deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias auth_digest proxy proxy_ajp proxy_connect proxy_http proxy_fcgi reqtimeout cgi cgid unixd socache_shmcb proxy_html xml2enc" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="openssl" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64 pc" INPUT_DEVICES="evdev joystick keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LIRC_DEVICES="userspace" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-1" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_5" QEMU_SOFTMMU_TARGETS="arm i386 x86_64" QEMU_USER_TARGETS="arm i386 x86_64" RUBY_TARGETS="ruby25" USERLAND="GNU" VIDEO_CARDS="intel i965 amdgpu 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, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Tim Harder gentoo-dev 2018-03-24 01:17:18 UTC
This is another failure due to -flto being enabled.
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2018-03-24 10:45:06 UTC
> /usr/lib64/libIlmThread.so: undefined reference to `pthread_create'

I think this but is really underlinking against pthread in media-libs/ilmbase (/usr/lib64/libIlmThread.so) and should be worked around there.

Note there is no libpthread in NEEDED depends:

$ lddtree /usr/lib64/libIlmThread.so
libIlmThread.so => /usr/lib64/libIlmThread.so (interpreter => none)
    libIex-2_2.so.12 => /usr/lib64/libIex-2_2.so.12
    libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/libstdc++.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
    libm.so.6 => /lib64/libm.so.6
    libc.so.6 => /lib64/libc.so.6
    libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/libgcc_s.so.1


Slightly simpler reproducer on ilmbase:

$ LDFLAGS="$(portageq envvar LDFLAGS) -Wl,--no-undefined" emerge -v1 media-libs/ilmbase

/bin/sh ../libtool --tag=CXX   --mode=link x86_64-pc-linux-gnu-g++ -pipe -O2 -pipe -flto -pthread -version-info 12:0:0 -no-undefined -release 2_2 -Wl,-O1 -Wl,--as-needed -O2 -pipe -flto -Wl,--hash-style=gnu -Wl,--no-undefined -o libIlmThread.la -rpath /usr/lib64 IlmThreadPool.lo IlmThread.lo IlmThreadSemaphore.lo IlmThreadMutex.lo IlmThreadPosix.lo IlmThreadSemaphorePosix.lo IlmThreadSemaphorePosixCompat.lo IlmThreadMutexPosix.lo ../Iex/libIex.la -pthread
...
/dev/shm/portage/media-libs/ilmbase-2.2.0-r1/temp/ccHtIfsh.ltrans0.ltrans.o: In function `IlmThread_2_2::Thread::start()':
<artificial>:(.text+0x747): undefined reference to `pthread_create'
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2018-03-24 10:52:10 UTC
> Slightly simpler reproducer on ilmbase:
> 
> $ LDFLAGS="$(portageq envvar LDFLAGS) -Wl,--no-undefined" emerge -v1
> media-libs/ilmbase

This fails for me even on non-lto systems.
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2018-03-24 11:33:20 UTC
Vague consensus it's a libtool bug of mis-handling -pthread (-lpthread would work) for c++ libraries:
    https://bugzilla.redhat.com/show_bug.cgi?id=661333
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2018-03-24 11:47:53 UTC
Upstream bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15646

Gentoo might want to apply the patch:
   http://permalink.gmane.org/gmane.comp.gnu.libtool.patches/11704
It's a hack but non-invasive one.
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2018-03-24 12:19:41 UTC
Created attachment 525216 [details, diff]
libtool-2.4.6-pthread.patch

Used this to apply/test the patch:

--- a/sys-devel/libtool/libtool-2.4.6-r4.ebuild
+++ b/sys-devel/libtool/libtool-2.4.6-r4.ebuild
@@ -60,2 +60,3 @@ src_prepare() {
        epatch "${FILESDIR}"/${PN}-2.4.6-darwin-use-linux-version.patch
+       epatch "${FILESDIR}"/${PN}-2.4.6-pthread.patch
        if use prefix ; then
@@ -81,3 +82,3 @@ src_prepare() {
                touch doc/*.1
-               export HELP2MAN=false
+               export HELP2MAN=true
        fi

I guess it will need to be applied to as well https://gitweb.gentoo.org/proj/elt-patches.git/
Comment 7 Larry the Git Cow gentoo-dev 2018-03-26 08:40:09 UTC
The bug has been referenced in the following commit(s):

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

commit 5690e822e589b92b4225c8c8b671ff8db5faf605
Author:     Lars Wendler <polynomial-c@gentoo.org>
AuthorDate: 2018-03-26 08:37:26 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2018-03-26 08:38:31 +0000

    sys-devel/libtool: Revbump to add pthread patch.
    
    Bug: https://bugs.gentoo.org/650876
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 .../files/libtool-2.4.6-libtoolize-slow.patch      |   6 +-
 .../libtool/files/libtool-2.4.6-pthread.patch      |  43 +++++++
 .../files/libtool-2.4.6-pthread_bootstrapped.patch |  21 ++++
 sys-devel/libtool/libtool-2.4.6-r5.ebuild          | 124 +++++++++++++++++++++
 sys-devel/libtool/libtool-9999.ebuild              |   5 +
 5 files changed, 196 insertions(+), 3 deletions(-)}
Comment 8 Larry the Git Cow gentoo-dev 2018-03-26 13:51:27 UTC
The bug has been closed via the following commit(s):

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

commit 61fedd15b0dbf3df6a37eae73cd1e931b17b9220
Author:     Craig Andrews <candrews@gentoo.org>
AuthorDate: 2018-03-24 01:23:08 +0000
Commit:     Craig Andrews <candrews@gentoo.org>
CommitDate: 2018-03-26 13:51:17 +0000

    media-libs/openexr: Strip lto flag
    
    Closes: https://bugs.gentoo.org/650876
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 media-libs/openexr/openexr-2.2.0-r2.ebuild | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Comment 9 Craig Andrews gentoo-dev 2018-03-27 14:15:18 UTC
*** Bug 651630 has been marked as a duplicate of this bug. ***
Comment 10 Larry the Git Cow gentoo-dev 2023-12-28 01:04:24 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/elt-patches.git/commit/?id=62add71b9ab7a444189d80e00a8eaca179cd1c85

commit 62add71b9ab7a444189d80e00a8eaca179cd1c85
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-12-28 00:54:17 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-12-28 00:56:42 +0000

    patches: add cxx-pthread
    
    Bug: https://bugs.gentoo.org/650876
    Bug: https://debbugs.gnu.org/15646
    Signed-off-by: Sam James <sam@gentoo.org>

 eltpatch.in               |  2 +-
 patches/cxx-pthread/2.4.6 | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
Comment 11 Larry the Git Cow gentoo-dev 2023-12-28 01:22:28 UTC
The bug has been closed via the following commit(s):

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

commit 0da3af137bae14fe5bec63eda205819e6cbcdf43
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-12-28 01:21:33 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-12-28 01:21:56 +0000

    app-portage/elt-patches: add 20231228
    
    Closes: https://bugs.gentoo.org/650876
    Signed-off-by: Sam James <sam@gentoo.org>

 app-portage/elt-patches/Manifest                   |  1 +
 .../elt-patches/elt-patches-20231228.ebuild        | 25 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)