Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 919878 - app-emulation/qemu-8.1.3 (+ a few others) : compile error : warning: libstdc++.so.6 not found
Summary: app-emulation/qemu-8.1.3 (+ a few others) : compile error : warning: libstdc+...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Virtualization Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-14 13:37 UTC by Janpieter Sollie
Modified: 2024-01-18 10:56 UTC (History)
8 users (show)

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


Attachments
qemu build log (qemu_build.log.xz,124.29 KB, application/x-xz)
2023-12-14 19:33 UTC, Janpieter Sollie
Details
samba build log (samba_build.log.xz,82.95 KB, application/x-xz)
2023-12-14 19:34 UTC, Janpieter Sollie
Details
qemu build log after recompiling spice (qemu_build.log.xz,128.27 KB, application/x-xz)
2023-12-16 13:20 UTC, Janpieter Sollie
Details
emerge --info sys-devel/gcc (file_919878.txt,9.19 KB, text/plain)
2023-12-16 13:22 UTC, Janpieter Sollie
Details
qlist gcc:12 (file_919878.txt,119.79 KB, text/plain)
2023-12-16 13:23 UTC, Janpieter Sollie
Details
qlist sys-devel/gcc:13 (file_919878.txt,121.95 KB, text/plain)
2023-12-16 13:24 UTC, Janpieter Sollie
Details
compiling bcachefs-tools from scratch + ldd following (file_919878.txt,46.43 KB, text/plain)
2023-12-16 21:01 UTC, Janpieter Sollie
Details
ldd output of libspice-server.so (file_919878.txt,1.00 KB, text/plain)
2023-12-16 21:04 UTC, Janpieter Sollie
Details
LD_DEBUG=all make of bcachefs-tools (ldoutput.txt.xz,703.32 KB, application/x-xz)
2023-12-17 05:51 UTC, Janpieter Sollie
Details
failing compile log (view job 3948/4558, first one showing the linker failure) (linuxserver_failed.log.xz,121.87 KB, application/x-xz)
2024-01-16 08:40 UTC, Janpieter Sollie
Details
build log succeeding (2725/4560 is the job succeeding here) (linuxcompiler_succeeded.log.xz,143.47 KB, application/x-xz)
2024-01-16 09:30 UTC, Janpieter Sollie
Details
linkerdump diff (file_919878.txt,16.85 KB, text/plain)
2024-01-16 14:31 UTC, Janpieter Sollie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Janpieter Sollie 2023-12-14 13:37:07 UTC
When compiling packages, with portage, I sometimes get the warning at the final stage of compilation:
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libstdc++.so.6, needed by /usr/lib64/libspice-server.so, not found (try using -rpath or -rpath-link)
I also see this when compiling icu-depending packages, and with gcc 13.
In attachment, I'll add the build log of samba (using icu) and qemu, both have the same issue.
As a result, the linking process fails.
find -name "libstdc++.so.6" shows the library is present, though not included for some reason

Reproducible: Always

Steps to Reproduce:
1.emerge package which needs libstdc++
2.
3.
Actual Results:  
linking fails

Expected Results:  
package gets compiled

Portage 3.0.56 (python 3.11.7-final-0, default/linux/amd64/17.1, gcc-13, glibc-2.38-r7, 6.7.0-rc5experimental+ x86_64)
=================================================================
System uname: Linux-6.7.0-rc5experimental+-x86_64-AMD_100-000000011-11-with-glibc2.38
KiB Mem:   131789280 total, 107706240 free
KiB Swap:  207393772 total, 207393772 free
Timestamp of repository gentoo: Tue, 05 Dec 2023 23:15:01 +0000
Head commit of repository gentoo: 011241c147a6af7baeae8dbf6e68a6d25787933b
Timestamp of repository eras-overlay: Fri, 08 Dec 2023 17:18:08 +0000
Head commit of repository eras-overlay: c1c4ad55c91f89260c14e7df5ef87e4b8f7dcd68

Timestamp of repository guru: Sat, 09 Dec 2023 18:32:02 +0000
Head commit of repository guru: 5f75502fa106adefa50da9738bca72f6cf60db3d

sh bash 5.2_p21-r1
ld GNU ld (Gentoo 2.41 p2) 2.41.0
distcc 3.4 x86_64-pc-linux-gnu [disabled]
ccache version 4.8.3 [disabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p21-r1::gentoo
dev-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2::gentoo
dev-lang/python:           3.10.13::gentoo, 3.11.7::gentoo
dev-lang/rust:             1.73.0::gentoo
dev-util/ccache:           4.8.3::gentoo
dev-util/cmake:            3.27.9::gentoo
dev-util/meson:            1.3.0-r1::gentoo
sys-apps/baselayout:       2.14-r1::gentoo
sys-apps/openrc:           0.52.1::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/autoconf:        2.71-r7::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils:        2.41-r2::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           16.0.6::gentoo, 17.0.6::gentoo
sys-devel/gcc:             12.3.1_p20230825::gentoo, 13.2.1_p20231014::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             17.0.6::gentoo
sys-devel/llvm:            16.0.6::gentoo, 17.0.6::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.6::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://localhost/gentoo-portage/
    priority: -1000
    volatile: False
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1

eras-overlay
    location: /var/db/repos/eras-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/eras-overlay.git
    masters: gentoo
    volatile: False

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo
    volatile: False

x-jp
    location: /var/db/repos/jp
    masters: gentoo
    priority: 10
    volatile: False

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=znver1 -mtune=znver2 -O3 -pipe "
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/stunnel/stunnel.conf /usr/share/gnupg/qualified.txt /var/bind"
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="-march=znver1 -mtune=znver2 -O3 -pipe "
DISTDIR="/data/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE 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 XDG_STATE_HOME"
FCFLAGS="-march=znver1 -mtune=znver2 -O3 -pipe "
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=znver1 -mtune=znver2 -O3 -pipe "
GENTOO_MIRRORS="http://ftp.belnet.be/pub/rsync.gentoo.org/gentoo/ rsync://ftp.belnet.be/gentoo/gentoo/ ftp://ftp.free.fr/mirrors/ftp.gentoo.org/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
MAKEOPTS="-j64"
PKGDIR="/data/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"
SHELL="/bin/bash"
USE="acl amd64 berkdb bind bzip2 caps cli crypt dbus dri elogind fortran gdbm gnutls iconv ipv6 libtirpc lto lzma mesa multilib ncurses nfs nftables nptl opencl openmp openssl pam pcre python readline samba seccomp sha3 split-usr ssl test-rust udev unicode urandom usb xattr xinetd zlib" ABI_X86="64" ADA_TARGET="gnat_2021" 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="aes sha sse sse2 sse3 avx avx2 bmi1 bmi2 sse4_1 sse4_2 ssse3 pni mmx mmxext fma3 f16c rdrand pclmul" 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" LLVM_TARGETS="AMDGPU X86" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_11 python3_10" QEMU_SOFTMMU_TARGETS="x86_64 i386 aarch64 arm riscv64 ppc64 sparc64 s390x" QEMU_USER_TARGETS="x86_64 i386 aarch64 arm riscv64 ppc64 ppc64le sparc64 s390x" RUBY_TARGETS="ruby31" SANE_BACKENDS="xerox_mfp hp" VIDEO_CARDS="amdgpu radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Janpieter Sollie 2023-12-14 19:33:46 UTC
Created attachment 879443 [details]
qemu build log
Comment 2 Janpieter Sollie 2023-12-14 19:34:15 UTC
Created attachment 879444 [details]
samba build log
Comment 3 Kostadin Shishmanov 2023-12-15 14:18:54 UTC
Why are you using gcc 12? If you want to downgrade from 13, you are gonna have to rebuild a lot of stuff.

https://wiki.gentoo.org/wiki/Upgrading_GCC#Downgrading_GCC
Comment 4 Janpieter Sollie 2023-12-15 14:48:36 UTC
As some form of illustration that it happend when compiling with both gcc 12 and 13 (and as such is not a compiler bug). The build log of samba is using gcc 13
Also, because it impacts multiple packages, it may be a portage issue
Comment 5 Alfred Wingate 2023-12-16 08:55:46 UTC
Outputs from `emerge --info gcc`, `qlist gcc:12` and `qlist gcc:13` could be interesting.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-12-16 08:59:51 UTC
Please give a log of this happening with GCC 13 after rebuilding /usr/lib64/libspice-server.so.
Comment 7 Janpieter Sollie 2023-12-16 13:20:40 UTC
Created attachment 879591 [details]
qemu build log after recompiling spice
Comment 8 Janpieter Sollie 2023-12-16 13:20:52 UTC
(In reply to Sam James from comment #6)
> Please give a log of this happening with GCC 13 after rebuilding
> /usr/lib64/libspice-server.so.

posted
Comment 9 Janpieter Sollie 2023-12-16 13:22:18 UTC
Created attachment 879592 [details]
emerge --info sys-devel/gcc
Comment 10 Janpieter Sollie 2023-12-16 13:23:35 UTC
Created attachment 879593 [details]
qlist gcc:12
Comment 11 Janpieter Sollie 2023-12-16 13:24:34 UTC
Created attachment 879594 [details]
qlist sys-devel/gcc:13
Comment 12 Janpieter Sollie 2023-12-16 13:26:25 UTC
(In reply to Alfred Wingate from comment #5)
> Outputs from `emerge --info gcc`, `qlist gcc:12` and `qlist gcc:13` could be
> interesting.

posted.  please note I substituted gcc with sys-devel/gcc as the cross-compilers cross-(tuple)/gcc make commands impossible without adding sys-devel/
Comment 13 Janpieter Sollie 2023-12-16 21:00:39 UTC
the error seems almost certainly a binutils error and not related to gcc or portage:
when compiling bcachefs-tools from scratch, the error appears when linking rust libraries against c code.
there seems to be some difference between LD_LIBRARY_PATH and LD_RUN_PATH (I assume), but how can I figure out what's happening?
Comment 14 Janpieter Sollie 2023-12-16 21:01:46 UTC
Created attachment 879653 [details]
compiling bcachefs-tools from scratch + ldd following
Comment 15 Janpieter Sollie 2023-12-16 21:04:10 UTC
Created attachment 879654 [details]
ldd output of libspice-server.so
Comment 16 Janpieter Sollie 2023-12-17 05:51:53 UTC
Created attachment 879674 [details]
LD_DEBUG=all make of bcachefs-tools

hopefully someone understands why this happens when looking at this log:
when I run 'make' of bcachefs-tools, the error appears, so I restarted make using LD_DEBUG=all.  The output is pretty large, but at line 157262 the output "not found" appears, whereas libstdc++ is called a lot of times before.
Any suggestions?  I tried using another binutils version, but that didn't help either
Comment 17 Alexander Tsoy 2023-12-22 15:33:50 UTC
For some reason linking commands from your logs are missing -lstdc++. Since linker is invoked via gcc and not g++, I think -lstdc++ is necessary.
Comment 18 Alexander Tsoy 2023-12-22 16:05:38 UTC
Ignore my previous comment. Just built qemu-8.1.3. There is no -lstdc++ in the logs compared to qemu-8.0.4, but it builds fine on my system.
Comment 19 Janpieter Sollie 2023-12-23 07:52:49 UTC
(In reply to Alexander Tsoy from comment #18)
> Ignore my previous comment. Just built qemu-8.1.3. There is no -lstdc++ in
> the logs compared to qemu-8.0.4, but it builds fine on my system.

Yes, that's the strange thing: on other devices with the same BINHOST, the process works just fine.  I created a tar archive of the etc directory, and scanned it this way:
> find -type f | while read r; do 
> [[ -f "/tmp/etc/$r" && "$(xxhsum $r | cut -f 1 -d' ')" != "$(xxhsum /tmp/etc/$r | cut -f 1 -d' ')" ]] && 
> echo "$r is missing something" && 
> diff -u "$r" "/tmp/etc/$r"; done > /tmp/diffsum.txt
... and analyzed the file, but I could not find anything.
might it be something related to the many cross-compilers installed?
Comment 20 Janpieter Sollie 2023-12-29 06:40:25 UTC
I beg to doffer Mike,
This is not a virtualisation bug,
It must be a linker issue
Comment 21 Mike Gilbert gentoo-dev 2023-12-29 19:22:27 UTC
(In reply to Janpieter Sollie from comment #20)

The bug was assigned based on the bug summary.

The toolchain team is CCed. If it is indeed a linker issue, they can address it.
Comment 22 Janpieter Sollie 2024-01-10 13:34:28 UTC
I _MAY_ have found something after googling tons of sites:
the bug could appear when a C program is linked, but C++ libraries are used...
Anyone who knows how to investigate whether this is the case? and why it breaks the build on this PC but not on others?
Comment 23 Arsen Arsenović gentoo-dev 2024-01-11 11:10:32 UTC
could you post logs from a working machine too?  for building qemu
Comment 24 Arsen Arsenović gentoo-dev 2024-01-11 11:15:05 UTC
ah, wait, never mind, I just spotted:
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libstdc++.so.6, needed by /usr/lib64/libspice-server.so, not found (try using -rpath or -rpath-link)

could you post /etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf and the output of gcc -v{,,,} -x c - <<<'int main(){}' -o foo
Comment 25 Janpieter Sollie 2024-01-11 11:40:15 UTC
(In reply to Arsen Arsenović from comment #24)
> ah, wait, never mind, I just spotted:
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld:
> warning: libstdc++.so.6, needed by /usr/lib64/libspice-server.so, not found
> (try using -rpath or -rpath-link)
> 
> could you post /etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf and the
> output of gcc -v{,,,} -x c - <<<'int main(){}' -o foo

> janpieter@linuxserver ~ $ cat /etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf                                                                          > /usr/lib/gcc/x86_64-pc-linux-gnu/13                                         
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/32                                      
> /usr/lib/gcc/x86_64-pc-linux-gnu/12                                         
> /usr/lib/gcc/x86_64-pc-linux-gnu/12/32                                      
> janpieter@linuxserver ~ $ gcc -v{,,,} -x c - <<<'int main(){}' -o foo       Using built-in specs.                                                       
> COLLECT_GCC=gcc                                                             
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/13/lto-wrapper     
> Target: x86_64-pc-linux-gnu                                                 
> Configured with: /var/tmp/portage/sys-devel/gcc-13.2.1_p20231216/work/gcc-13-20231216/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/13 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13 --disable-silent-rules --disable-dependency-tracking --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/13/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 13.2.1_p20231216 p11' --with-gcc-major-version-only --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-cet --disable-systemtap --enable-valgrind-annotations --disable-vtable-verify --disable-libvtv --with-zstd --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp --with-build-config='bootstrap-O3 bootstrap-lto'                                            > Thread model: posix                                                         
> Supported LTO compression algorithms: zlib zstd                             
> gcc version 13.2.1 20231216 (Gentoo 13.2.1_p20231216 p11)                   
> COLLECT_GCC_OPTIONS='-v' '-v' '-v' '-v' '-o' 'foo' '-mtune=generic' '-march=x86-64' '-dumpdir' 'foo-'                                                    /usr/libexec/gcc/x86_64-pc-linux-gnu/13/cc1 -quiet -v -v -v -v - -quiet -dumpdir foo- -dumpbase - -mtune=generic -march=x86-64 -version -o /tmp/ccXJWzGl.s                                                                         GNU C17 (Gentoo 13.2.1_p20231216 p11) version 13.2.1 20231216 (x86_64-pc-linux-gnu)
        compiled by GNU C version 13.2.1 20231216, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP


> GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/13/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/13/include-fixed
 /usr/include
End of search list.
Compiler executable checksum: a895ee85be53d7f1be70e645d6cf5d02

> COLLECT_GCC_OPTIONS='-v' '-v' '-v' '-v' '-o' 'foo' '-mtune=generic' '-march=x86-64' '-dumpdir' 'foo-'
 /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/as -v -v -v -v --64 -o /tmp/ccX1wJXZ.o /tmp/ccXJWzGl.s
GNU assembler version 2.41.0 (x86_64-pc-linux-gnu) using BFD version (Gentoo 2.41 p4) 2.41.0
COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/13/:/usr/libexec/gcc/x86_64-pc-linux-gnu/13/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/13/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/13/:/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-v' '-v' '-v' '-o' 'foo' '-mtune=generic' '-march=x86-64' '-dumpdir' 'foo.'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/13/collect2 -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/13/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/13/lto-wrapper -plugin-opt=-fresolution=/tmp/ccXFkz99.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o foo /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/13/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/13 -L/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../.. /tmp/ccX1wJXZ.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/13/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/crtn.o
COLLECT_GCC_OPTIONS='-v' '-v' '-v' '-v' '-o' 'foo' '-mtune=generic' '-march=x86-64' '-dumpdir' 'foo.'
Comment 26 Mike Gilbert gentoo-dev 2024-01-11 18:43:33 UTC
/etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf is missing this line:                                                                         

/usr/lib/gcc/x86_64-pc-linux-gnu/13
Comment 27 Janpieter Sollie 2024-01-11 20:10:41 UTC
(In reply to Mike Gilbert from comment #26)
> /etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf is missing this line:      
> 
> 
> /usr/lib/gcc/x86_64-pc-linux-gnu/13

it's not, it was a wrong C/P from my side:

> cat /etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf
> /usr/lib/gcc/x86_64-pc-linux-gnu/13
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/32
> /usr/lib/gcc/x86_64-pc-linux-gnu/12
> /usr/lib/gcc/x86_64-pc-linux-gnu/12/32
Comment 28 Janpieter Sollie 2024-01-15 07:59:33 UTC
I found this thread on the gentoo forums:
https://forums.gentoo.org/viewtopic-p-8692510.html?sid=ed2175817e4f3ddf79f6d5a9ec70bb4d
I see the machine having problems uses the 17.1 profile, while all others use 17.1/desktop/plasma.
May this be the root cause why -lstdc++ isn't applied automatically?
Comment 29 Janpieter Sollie 2024-01-16 08:37:47 UTC
I compiled qemu-8.2.0 again, on a working machine and the failing one (using the same binhost).
the logs show the command which fails on one PC but not on the other one isn't different at all, but there are some packages which differ.
I'll upload the logs, can someone please reassign this to the toolchain team?
Comment 30 Janpieter Sollie 2024-01-16 08:40:20 UTC
Created attachment 882394 [details]
failing compile log (view job 3948/4558, first one showing the linker failure)

the configure part shows some difference with the working build log
Comment 31 Janpieter Sollie 2024-01-16 09:30:09 UTC
Created attachment 882396 [details]
build log succeeding (2725/4560 is the job succeeding here)
Comment 32 Arsen Arsenović gentoo-dev 2024-01-16 13:12:34 UTC
interesting, /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6 should exist and -L/usr/lib/gcc/x86_64-pc-linux-gnu/13 is passed to the linker.

could you add '-v' to ldflags and rebuild qemu?  maybe something is preventing it from passing -L.
Comment 33 Janpieter Sollie 2024-01-16 14:31:27 UTC
Created attachment 882421 [details]
linkerdump diff

I ran both running and failing linker jobs manually, using the following command:
> $(grep '2725/4560' /var/tmp/portage/app-emulation/qemu-8.2.0/temp/build.log | sed 's/^.*\]\ \(.*\)/\1\ -v\ -Wl,--verbose/') > /tmp/linkerdump.txt
> $(grep '3948/4558' /var/tmp/portage/app-emulation/qemu-8.2.0/temp/build.log | sed 's/^.*\]\ \(.*\)/\1\ -v\ -Wl,--verbose/') > /tmp/linkerdump.txt
then I tried to show the differences between both (which are c/p'ed into the attachment):
> diff -u linkerdump.txt.working linkerdump.txt.notworking
Comment 34 Janpieter Sollie 2024-01-17 13:52:20 UTC
The issue has been solved:
after digging through the whole process with strace, I found an empty file /usr/etc/ld.so.conf existed, and its presence overrides /etc/ld.so.conf.
I never thought that could actually happen, but it did :s
Comment 35 Martin Zwicknagl 2024-01-17 16:37:35 UTC
I can confirm that deleting the file `/usr/etc/ld.so.conf` resolves the issue.

I don't know, who/which package/emerge created that file. But is was very new dated on 8/Jan/2024
Comment 36 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-17 16:40:44 UTC
(In reply to Martin Zwicknagl from comment #35)
> I can confirm that deleting the file `/usr/etc/ld.so.conf` resolves the
> issue.
> 
> I don't know, who/which package/emerge created that file. But is was very
> new dated on 8/Jan/2024

Was it empty for you too?

Could you grep /var/db/pkg (the CONTENTS files) to see if any package owned it?
Comment 37 Mike Gilbert gentoo-dev 2024-01-17 16:52:04 UTC
Recent versions of env-update will write /usr/etc/ld.so.conf if EPREFIX is set. 

https://github.com/gentoo/portage/pull/1105

I doubt that's relevant here, but it could be.
Comment 38 Martin Zwicknagl 2024-01-17 18:03:21 UTC
(In reply to Sam James from comment #36)
> (In reply to Martin Zwicknagl from comment #35)
> > I can confirm that deleting the file `/usr/etc/ld.so.conf` resolves the
> > issue.
> > 
> > I don't know, who/which package/emerge created that file. But is was very
> > new dated on 8/Jan/2024
> 
> Was it empty for you too?
> 
> Could you grep /var/db/pkg (the CONTENTS files) to see if any package owned
> it?

No, the file was not owned by any package.
Comment 39 Martin Zwicknagl 2024-01-17 18:08:01 UTC
(In reply to Mike Gilbert from comment #37)
> Recent versions of env-update will write /usr/etc/ld.so.conf if EPREFIX is
> set. 
> 
> https://github.com/gentoo/portage/pull/1105
> 
> I doubt that's relevant here, but it could be.

Maybe it is. Currently I am playing with cross-compiling packages for a Raspberry PI. The `emerge-aarch64-unknown-linux-gnu` command changes `EROOT` and `EROOT` is used by `sys-libs/glibc-2.38-r9/glibc-2.38-r9.ebuild:`

I can not reproduce the creation of that `/user/etc/ld.so.conf` now, but I will be very attentive in the future, maybe I can track the problem down.
Comment 40 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-17 18:10:15 UTC
I need to read over the PR again but another more niche possibility would be a <EAPI 7 ebuild which calls env-update for you. But in that case (and indeed yours), you would have *some* text in there (a comment).

Unless it's related to crossdev and such but not being created by env-update.
Comment 41 James Le Cuirot gentoo-dev 2024-01-17 22:57:56 UTC
It seems unlikely to be my change. As Sam says, the file would have some text in there. If you had set EPREFIX to something, then the file wouldn't be at that path. Even if it were a blank string, that is falsey under Python, so it wouldn't have taken that route.

The reason the -L flag isn't enough to make it work is because bfd ignores such flags when looking for subdependencies. We patch this behaviour out for prefix and cross toolchains because it causes issues there, but we keep it for regular toolchains.
Comment 42 Arsen Arsenović gentoo-dev 2024-01-18 10:56:58 UTC
ah, right.  the dep is not made explicit by using the G++ driver.  good point