This is a spin-off from an investigation of https://bugs.gentoo.org/937739. With https://bugs.gentoo.org/761220 ccache started to link statically against libstdc++ by default, in order to isolate itself against mismatched versions when building e.g. older gcc. Some time after that, the ccache ebuild slowly started to unbundle more dependencies. This lead to the reappearance of dynamically linked transitive libstdc++ dependencies, which essentially reintroduced the original problem. Despite the fact that his "seemingly" works in practice - especially as long as the libstdc++ version is consistent between static and dynamic linking - it is not something we should rely on due to not-well-defined initialisation of global state and other implementation details, which can change at any time. The fix is simple: use bundled versions of dependencies that need libstdc++. As of ccache-4.10.2 there are two dependencies using C++: cpp-httplib and libfmt. With those two bundled, the dynamic dependency on libstdc++ is gone. Executable size increased by a mere ~40k. We also have two fewer ebuild dependencies - always good for toolchain parts (see cmake vs. json-cpp requiring each other). Reproducible: Always Steps to Reproduce: 1. build ccache-4.10.2 with USE="static-c++" (enabled by default) 2. transitive dependencies still pull in libstdc++ dynamically
Created attachment 900249 [details, diff] Patch to use bundled C++ dependencies, depending on USE=static-c++ This patch will build ccache with bundled C++ dependencies if USE=static-c++ is enabled, and use the unbundled libs (cpp-httplib, libfmt) otherwise.
IMO the fix here should be in GCC (and whatever else downgrades libstdc++) rather than hacking more and more things to link statically but I wouldn't oppose a hack either as I don't have time to investigate/implement a fix right now
See this commit as well: commit 8c0219269e6b82a67f56227d223e5194c105f357 Author: Maciej Barć <xgqt@gentoo.org> Date: Thu Sep 12 16:15:05 2024 +0200 dev-cpp/cpp-httplib: change SLOT from 0.17 to 0.17.3 a version update from 0.17.2 -> 0.17.3 that broke ABI forced us to recheck the version of installed libs, from now the file httplib.h and var CPPHTTPLIB_VERSION should be checked to determine the SUB-SLOT of this package See also: https://forums.gentoo.org/viewtopic-t-1170811.html Signed-off-by: Maciej Barć <xgqt@gentoo.org> So yes, we should do it (but optionally via default-on USE, as we do now).
Depending on opinions wrt. #939561 I can add that bit to the PR.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7980312ce393014eba98f803e5505624485738db commit 7980312ce393014eba98f803e5505624485738db Author: Holger Hoffstätte <holger@applied-asynchrony.com> AuthorDate: 2024-09-13 07:52:38 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-10-07 15:55:09 +0000 dev-util/ccache: prefer using bundled C++ deps by default This prevents potential problems with libstdc++ especially during toolchain builds. Closes: https://bugs.gentoo.org/938011 Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com> Closes: https://github.com/gentoo/gentoo/pull/38590 Signed-off-by: Sam James <sam@gentoo.org> dev-util/ccache/ccache-4.10.2-r1.ebuild | 147 ++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+)