/etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf is being mis-ordered (eselection-insensitive) when installing multiple gcc slots -- I have x86_64-pc-linux-gnu-11 selected, but the conf file is set up with the slots in reverse version order: /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 /usr/lib/gcc/x86_64-pc-linux-gnu/11 /usr/lib/gcc/x86_64-pc-linux-gnu/11/32 /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0 /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/32 /usr/lib/gcc/x86_64-pc-linux-gnu/6.5.0 /usr/lib/gcc/x86_64-pc-linux-gnu/6.5.0/32 This causes the system to runtime-link in libstdc++.so and friends from the deselected gcc. Although this seems like a nontrivial issue in terms of the-right-thing-to-do, ultimately it doesn't work to have deselected gcc artifacts linked in by system default. In particular, it leads to a situation where deselected+experimental gcc libs are linked into system daemons, and (lesser concern) upgrade of that experimental gcc forces system daemon restarts to clear mappings of deleted libraries. I'm working around the problem locally by editing the conf file to put the selected gcc slot first. Possibly related, I'm seeing that when emerge --update --rebuild-if-new-ver @world pulls in sys-devel/gcc:13, several packages get marked for rebuild that apparently shouldn't be. --rebuild-if-new-rev brings in even more, including system glibc, even though the system glibc was built+installed with 05gcc-x86_64-pc-linux-gnu.conf listing the gcc:11 libs first. I don't know how to get emerge to show the dependency tree to explain what triggered each rebuild -- is there a way? Example of the behavior: # eselect gcc show x86_64-pc-linux-gnu-11 # emerge --ask --oneshot --keep-going=y --update --rebuild-if-new-rev --rebuild-if-new-ver --autounmask-keep-masks --verbose --verbose-conflicts --backtrack=10 @world These are the packages that would be merged, in order: Calculating dependencies... done! Dependency resolution took 37.49 s. [ebuild U *] sys-devel/gcc-13.0.1_pre20230205-r1:13::gentoo [13.0.1_pre20230205:13::gentoo] USE="(cxx) doc fortran graphite (multilib) nls nptl openmp pgo (pie) sanitize ssp -ada (-cet) (-custom-cflags) -d -debug -default-stack-clash-protection -default-znow (-fixed-point) -go -hardened (-ieee-long-double) -jit (-libssp) -lto -objc -objc++ -objc-gc -pch -rust -systemtap -test -valgrind -vanilla -vtv -zstd" 0 KiB [ebuild rR ~] sys-libs/glibc-2.36-r7:2.2::gentoo USE="gd multiarch (multilib) profile ssp stack-realign (static-libs) -audit -caps (-cet) -compile-locales -crypt (-custom-cflags) -doc -hash-sysv-compat -headers-only -multilib-bootstrap -nscd -perl (-selinux) -suid -systemd -systemtap -test (-vanilla)" 0 KiB [ebuild rR ~] app-crypt/libb2-0.98.1-r3::gentoo USE="openmp -native-cflags -static-libs" ABI_X86="(64) -32 (-x32)" 0 KiB [ebuild U *] cross-riscv32-unknown-linux-gnu/gcc-13.0.1_pre20230205-r1:13::crossdev [13.0.1_pre20230205:13::crossdev] USE="cxx nls nptl pch pie ssp -ada -cet -custom-cflags -d -debug -default-stack-clash-protection -default-znow -doc -fixed-point -fortran -go -graphite -hardened -ieee-long-double -jit -libssp -lto (-multilib) -objc -objc++ -objc-gc -openmp -pgo -rust -sanitize -systemtap -test -valgrind -vanilla -vtv -zstd" 0 KiB [ebuild U *] cross-riscv64-unknown-linux-gnu/gcc-13.0.1_pre20230205-r1:13::crossdev [13.0.1_pre20230205:13::crossdev] USE="cxx nls nptl pch pie ssp -ada -cet -custom-cflags -d -debug -default-stack-clash-protection -default-znow -doc -fixed-point -fortran -go -graphite -hardened -ieee-long-double -jit -libssp -lto (-multilib) -objc -objc++ -objc-gc -openmp -pgo -rust -sanitize -systemtap -test -valgrind -vanilla -vtv -zstd" 0 KiB [ebuild rR ~] sci-libs/hdf5-1.12.2-r5:0/1.12.2::gentoo USE="examples fortran hl unsupported zlib -cxx -debug -mpi -szip -threads" 0 KiB [ebuild rR ] sci-libs/amd-2.4.6-r1::gentoo USE="fortran -doc" 0 KiB [ebuild rR ] sci-libs/fftw-3.3.10:3.0/3::gentoo USE="fortran openmp threads -doc -mpi -test (-zbus)" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="avx avx2 fma3 sse sse2 -fma4" 0 KiB [ebuild rR ~] cross-riscv32-unknown-linux-gnu/glibc-2.36-r7:2.2::crossdev USE="crypt multiarch ssp static-libs -audit -caps -cet -compile-locales -custom-cflags -doc -gd -hash-sysv-compat -headers-only (-multilib) -multilib-bootstrap -nscd -perl -profile (-selinux) -stack-realign -suid -systemd -systemtap -test -vanilla" 0 KiB [ebuild rR ~] cross-riscv64-unknown-linux-gnu/glibc-2.36-r7:2.2::crossdev USE="crypt multiarch ssp static-libs -audit -caps -cet -compile-locales -custom-cflags -doc -gd -hash-sysv-compat -headers-only (-multilib) -multilib-bootstrap -nscd -perl -profile (-selinux) -stack-realign -suid -systemd -systemtap -test -vanilla" 0 KiB [ebuild rR ~] net-libs/nodejs-18.14.0:0/18::gentoo USE="icu inspector npm snapshot ssl system-icu system-ssl -debug -doc -lto -pax-kernel -systemtap -test" CPU_FLAGS_X86="sse2" 0 KiB [ebuild rR ] x11-misc/xautolock-2.2_p7::gentoo 0 KiB [ebuild rR ] sys-cluster/openmpi-4.1.4::gentoo USE="fortran ipv6 -cma -cuda -cxx -java -libompitrace -peruse -romio" ABI_X86="(64) -32 (-x32)" OPENMPI_FABRICS="-knem -ofed" OPENMPI_OFED_FEATURES="-control-hdr-padding -dynamic-sl -rdmacm -udcm" OPENMPI_RM="-pbs (-slurm)" 0 KiB [ebuild rR ] media-gfx/transfig-3.2.5e-r1::gentoo 0 KiB [ebuild rR ~] sci-libs/cfitsio-4.2.0:0/10::gentoo USE="bzip2 curl -threads -tools" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse2 ssse3" 0 KiB [ebuild rR ~] sci-libs/lapack-3.11::gentoo USE="-deprecated -doc -eselect-ldso -lapacke -test" 0 KiB [ebuild U ~] dev-python/numpy-1.24.2::gentoo [1.24.0::gentoo] USE="lapack -test" PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ] sci-libs/arpack-3.8.0::gentoo USE="-doc -examples -mpi" 0 KiB [ebuild rR ] sci-libs/qrupdate-1.1.2-r2::gentoo 0 KiB [ebuild rR ~] dev-python/bottleneck-1.3.6::gentoo USE="-test" PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ] dev-python/numexpr-2.8.4::gentoo PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ~] dev-python/h5py-3.8.0::gentoo USE="-doc -examples -test" PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ~] dev-python/mpi4py-3.1.4::gentoo USE="-doc -examples -test" PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ] media-libs/vigra-1.11.1-r8::gentoo USE="fftw hdf5 jpeg openexr png python tiff zlib -doc -mpi -test -valgrind" PYTHON_TARGETS="python3_9 python3_10" 0 KiB [ebuild rR ] dev-python/scipy-1.10.0::gentoo USE="fortran (test-rust) -doc -test" PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ~] dev-python/pandas-1.5.3::gentoo USE="X (-doc) -full-support -minimal -test" PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ~] dev-lang/R-4.2.2::gentoo USE="X cairo doc icu jpeg lapack nls openmp perl png readline tiff tk -java -lto -minimal (-prefix) -profile -test" 0 KiB [ebuild rR ~] dev-python/matplotlib-3.6.3::gentoo USE="cairo gtk3 (-doc) -examples -excel -latex -qt5 -test -tk -webagg -wxwidgets" PYTHON_TARGETS="python3_9 python3_10 -python3_11" 0 KiB [ebuild rR ~] net-libs/webkit-gtk-2.38.4-r410:4.1/0::gentoo USE="X egl gnome-keyring gstreamer introspection jpeg2k jumbo-build lcms pdf (seccomp) spell (-aqua) -avif -examples -gamepad -gles2-only -systemd -test -wayland" 0 KiB [ebuild rR ~] net-libs/webkit-gtk-2.38.4-r500:5/0::gentoo USE="X egl gnome-keyring gstreamer introspection jpeg2k jumbo-build lcms pdf (seccomp) spell (-aqua) -avif -examples -gamepad -gles2-only -systemd -test -wayland" 0 KiB [ebuild rR ~] dev-lang/rust-1.67.0:stable/1.67::gentoo USE="clippy doc rustfmt system-bootstrap system-llvm verify-sig -debug -dist (-llvm-libunwind) (-miri) -nightly (-parallel-compiler) -profiler -rust-analyzer -rust-src -test -wasm" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse2" LLVM_TARGETS="(X86) -AArch64 -AMDGPU -ARM -AVR -BPF -Hexagon -Lanai -MSP430 -Mips -NVPTX -PowerPC -RISCV -Sparc -SystemZ -WebAssembly -XCore" 0 KiB [ebuild rR ] sci-mathematics/octave-7.3.0-r2:0/7.3.0::gentoo USE="X curl fftw glpk gnuplot gui hdf5 imagemagick opengl postscript qhull qrupdate readline sndfile sparse ssl zlib -doc -fltk -java -json -portaudio -sundials" 0 KiB Total: 32 packages (4 upgrades, 28 reinstalls), Size of downloads: 0 KiB
The ld.so.conf.d ordering is intentional -- we discussed it recently in #gentoo-toolchain and I don't think it's plausible to change it. See bug 297685 too. It's tricky because yes, there's this frustrating interaction with libstdc++ where you can't downgrade the compiler anyway, but also, the risk of breakage of anything using e.g. libgcc isn't great either. I personally noticed this after having 13 installed on one system & finding libubsan was coming from 13 despite not having selected it. Please file a new bug for the emerge issue for us to discuss that, as they're separate.
Thanks for the background. The nontriviality is approximately what I feared, and I think we're stuck with this status quo. Wide deployment of -rpath would clearly be worse as it would lead to a neverending hurricane of package rebuilds around compiler upgrades. So what we're counting on going forward is that the .so's bundled with the compiler are ABI-compatible with the .so's from older compilers. I think the gcc people know we're all depending on that. If the only practical fallout is that system daemons need to be restarted to get them onto the updated .so's, that's not a big deal.