Hello, I'm noticing some issues with libstdc++ after building GCC from
sources and installing into /opt/gcc-14.1.0. Specifically:

$ objdump -x /opt/gcc-14.1.0/lib/libstdc++.so.6 | grep RUNPATH

$ ldd /opt/gcc-14.1.0/lib/libstdc++.so.6
/opt/gcc-14.1.0/lib/libstdc++.so.6:
        libm.so.5 => /lib/libm.so.5 (0x5486f1dc8000)
        libc.so.7 => /lib/libc.so.7 (0x5486f07e5000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x5486f1ff0000)

As you can see libstdc++ depends on libgcc_s but libstdc++ is missing
RUNPATH, so it picks up whatever is found in /lib rather than in target
install directory /opt/gcc-14.1.0

Contrast this with:

$ objdump -x /opt/gcc-14.1.0/lib/libcc1.so.0 | grep RUNPATH
  RUNPATH      /opt/gcc-14.1.0/lib

$ ldd /opt/gcc-14.1.0/lib/libcc1.so.0 
/opt/gcc-14.1.0/lib/libcc1.so.0:
        libstdc++.so.6 => /opt/gcc-14.1.0/lib/libstdc++.so.6 (0x59c328800000)
        libm.so.5 => /lib/libm.so.5 (0x59c325081000)
        libc.so.7 => /lib/libc.so.7 (0x59c3245c4000)
        libgcc_s.so.1 => /opt/gcc-14.1.0/lib/libgcc_s.so.1 (0x59c326ac0000)

Is it intentional or is it a bug? What is the best way to add RUNPATH
to libstd++? Do I modify CFLAGS_FOR_TARGET or LDFLAGS_FOR_TARGET?

PS. GCC was configured with these options:

$ /opt/gcc-14.1.0/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/opt/gcc-14.1.0/bin/gcc
COLLECT_LTO_WRAPPER=/opt/gcc-14.1.0/libexec/gcc/aarch64-unknown-freebsd14.0/14.1.0/lto-wrapper
Target: aarch64-unknown-freebsd14.0
Configured with: ../../src/gcc-14.1.0/configure --prefix=/opt/gcc-14.1.0 
--build=aarch64-unknown-freebsd14.0 --host=aarch64-unknown-freebsd14.0 
--target=aarch64-unknown-freebsd14.0 --enable-languages=c,c++,ada 
--enable-shared --enable-threads=posix --enable-bootstrap --disable-multilib 
--disable-nls --with-as=/opt/gcc-14.1.0/bin/as --with-ld=/opt/gcc-14.1.0/bin/ld
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.1.0 (GCC) 

Reply via email to