Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 938011 - dev-util/ccache: reconsider using bundled dependencies to isolate against potential libstdc++ version conflicts
Summary: dev-util/ccache: reconsider using bundled dependencies to isolate against pot...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords: PATCH, PullRequest
Depends on:
Blocks: 937739
  Show dependency tree
 
Reported: 2024-08-16 13:00 UTC by Holger Hoffstätte
Modified: 2024-10-08 08:23 UTC (History)
2 users (show)

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


Attachments
Patch to use bundled C++ dependencies, depending on USE=static-c++ (ccache-4.10.2-no-shared-libstdc++.patch,787 bytes, patch)
2024-08-16 13:23 UTC, Holger Hoffstätte
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Hoffstätte 2024-08-16 13:00:42 UTC
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
Comment 1 Holger Hoffstätte 2024-08-16 13:23:06 UTC
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.
Comment 2 Arsen Arsenović gentoo-dev 2024-08-16 17:41:59 UTC
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
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-12 20:50:23 UTC
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).
Comment 4 Holger Hoffstätte 2024-09-13 08:13:42 UTC
Depending on opinions wrt. #939561 I can add that bit to the PR.
Comment 5 Larry the Git Cow gentoo-dev 2024-10-07 15:55:59 UTC
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(+)