Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 761220 - sys-devel/gcc: with >=dev-util/ccache-4.0: x86_64-pc-linux-gnu-g++: /var/tmp/portage/sys-devel/gcc-8.4.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by x86_64-pc-linux-gnu-g++)
Summary: sys-devel/gcc: with >=dev-util/ccache-4.0: x86_64-pc-linux-gnu-g++: /var/tmp/...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
: 766707 785280 792138 792612 798792 803020 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-12-22 06:52 UTC by Mihai Moldovan
Modified: 2023-04-20 22:51 UTC (History)
11 users (show)

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


Attachments
emerge --info (emerge-info,20.19 KB, text/plain)
2020-12-22 06:52 UTC, Mihai Moldovan
Details
gcc-build-logs.tar.bz2 (gcc-build-logs.tar.bz2,725.87 KB, application/x-bzip)
2020-12-22 06:54 UTC, Mihai Moldovan
Details
emerge --info (emerge.info,8.25 KB, text/plain)
2021-05-25 14:01 UTC, Fabio Coatti
Details
build.log (build.log.gz,133.40 KB, application/gzip)
2021-05-25 14:02 UTC, Fabio Coatti
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mihai Moldovan 2020-12-22 06:52:33 UTC
Created attachment 679173 [details]
emerge --info

Since dev-util/ccache 4.0, building older versions of sys-devel/gcc than the one dev-util/ccache was built with fails.

Example: dev-util/ccache built with sys-devei/gcc:9.3.0: building sys-devel/gcc:8.4.0 fails.

Build logs and emerge --info output attached.

The takeaway is that:

  - dev-util/ccache >= 4.0 now links against libstdc++
  - sys-devel/gcc seems to compile a few files during src_install
  - it thinks it's in stage3 and using the newly built compiler binary, but instead uses the system compiler
  - preloads the just-built (older) libstdc++ library
  - crashes while executing ccache, which uses newer symbols/features.

Thanks to Sergei Trofimovich for pointing all that out.

Now, one way to work around that issue is to disable ccache, obviously. Another way is to rebuild ccache so that it links a static libstdc++ version.

The proper way to fix that, however, is to
  - either stop gcc to rebuild the packages in src_install (why would this be necessary in the first place?)
  - or, failing that, make that src_install building use the newly bootstrapped compiler instead of the (possible ccache-wrapped) system compiler, for which the preloaded libstdc++ would be fitting.
Comment 1 Mihai Moldovan 2020-12-22 06:54:50 UTC
Created attachment 679176 [details]
gcc-build-logs.tar.bz2

Builds logs, tar'd and compressed by portage.
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2020-12-22 07:49:25 UTC
libtool usually relinks binaries against new RPATH when tools get installed. 

LD_LIBRARY_PATH injection breaks not only ccache but also linkers with c++ plugins injected as seen in bug #644772. I think it has to be solved upstream (if possible at all).
Comment 3 Mihai Moldovan 2020-12-22 08:16:45 UTC
Right.

I created a new report because the failure and cause is (slight) different from the the one in #644772.

Crucially, THIS can be fixed by fixing the gcc build system to NOT rebuild stuff at "make install" time, which sounds like a bug to begin with.

The binaries being created there should already be around, but something must detect they are outdated and hence trying to rebuild them. This shouldn't be the case.

Fixing that might also fix the other issues mentioned in the other bug report, but I'm not sure about this. Highly depends on where it fails there. If it's within src_compile, making src_install not compile stuff, like it should, won't help there.
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2020-12-22 19:43:34 UTC
You can try to write a patch, but I'll repeat my suspiction:

libtool usually relinks binaries against new RPATH when tools get installed.
Comment 5 Moshy 2021-01-17 09:48:42 UTC
I think 742281 is a DUP of this
Comment 6 Moshy 2021-01-17 09:53:34 UTC
gcc prior to 8 appears to be EOL upstream (as of 2011-01-17) so that approach seems infeasible
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-17 12:45:12 UTC
(In reply to Moshy from comment #5)
> I think 742281 is a DUP of this

Most likely not.

(In reply to Moshy from comment #6)
> gcc prior to 8 appears to be EOL upstream (as of 2011-01-17) so that
> approach seems infeasible

Are you sure you are posting update to the correct bug?
Comment 8 Moshy 2021-01-19 21:41:14 UTC
In reply to comment 7:

I probably misread which package you were referring to by "upstream".

As for bug #742281, in the absence of build.log, the same result was encountered, except instead of gcc 8.4.0 failing to build, it was gcc 6.5.0, but with the same link error of GLIBCXX_3.4.26 not found, so the cause is likely same.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-20 14:08:13 UTC
(In reply to Moshy from comment #8)
> In reply to comment 7:
> 
> I probably misread which package you were referring to by "upstream".

gcc.

> As for bug #742281, in the absence of build.log, the same result was
> encountered, except instead of gcc 8.4.0 failing to build, it was gcc 6.5.0,
> but with the same link error of GLIBCXX_3.4.26 not found, so the cause is
> likely same.

Maybe, or maybe not. It's hard to say without build.log or emerge --info.
Comment 10 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-23 19:25:21 UTC
*** Bug 766707 has been marked as a duplicate of this bug. ***
Comment 11 Sergei Trofimovich (RETIRED) gentoo-dev 2021-04-24 12:08:04 UTC
*** Bug 785280 has been marked as a duplicate of this bug. ***
Comment 12 Fabio Coatti 2021-05-25 14:00:55 UTC
I have the same situation, attaching build.log and emerge.info
Comment 13 Fabio Coatti 2021-05-25 14:01:43 UTC
Created attachment 711141 [details]
emerge --info
Comment 14 Fabio Coatti 2021-05-25 14:02:24 UTC
Created attachment 711144 [details]
build.log
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2021-05-26 21:24:20 UTC
*** Bug 792138 has been marked as a duplicate of this bug. ***
Comment 16 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-05-28 11:19:49 UTC
*** Bug 792612 has been marked as a duplicate of this bug. ***
Comment 17 Larry the Git Cow gentoo-dev 2021-06-11 22:51:39 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e2e19839d429095acc15c6591d680498e1ae3597

commit e2e19839d429095acc15c6591d680498e1ae3597
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2021-06-11 22:51:28 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2021-06-11 22:51:37 +0000

    dev-util/ccache: add USE=static-c++ which embeds libstdc++
    
    To ease building gcc with ccache we need to handle the case of
    LD_PRELOAD=./inplace/libstdc++.so injected by gcc's build system.
    
    USE=static-c++ uses -static-libstdc++ for it.
    
    Reported-by: Mihai Moldovan
    Bug: https://bugs.gentoo.org/761220
    Package-Manager: Portage-3.0.19, Repoman-3.0.3
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 dev-util/ccache/ccache-4.3-r1.ebuild | 89 ++++++++++++++++++++++++++++++++++++
 dev-util/ccache/metadata.xml         |  3 ++
 2 files changed, 92 insertions(+)
Comment 18 Sergei Trofimovich (RETIRED) gentoo-dev 2021-06-11 22:52:32 UTC
Try USE=static-c++ for ~arch ccache. That should ease gcc and ccache integration warts.
Comment 19 Fabio Coatti 2021-06-18 07:11:36 UTC
Just for the record, this issue happens on my system that has no ccache installed.
Should I open a different bug for that or do you have something that I can try and test?
I attached build log previously.
Comment 20 Sergei Trofimovich (RETIRED) gentoo-dev 2021-06-18 07:47:44 UTC
(In reply to Fabio Coatti from comment #19)
> Just for the record, this issue happens on my system that has no ccache
> installed.
> Should I open a different bug for that or do you have something that I can
> try and test?
> I attached build log previously.

Given that you use gold
> ld GNU gold (Gentoo 2.36.1 p3 2.36.1) 1.16
your bug is probably a form of bug #644772
Comment 21 Sergei Trofimovich (RETIRED) gentoo-dev 2021-06-26 22:34:10 UTC
*** Bug 798792 has been marked as a duplicate of this bug. ***
Comment 22 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-20 18:18:09 UTC
*** Bug 803020 has been marked as a duplicate of this bug. ***
Comment 23 Larry the Git Cow gentoo-dev 2021-07-22 18:56:16 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b266b0aaf1f079fb9324aa0f50a8a15ca4d2c450

commit b266b0aaf1f079fb9324aa0f50a8a15ca4d2c450
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2021-07-22 18:56:04 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2021-07-22 18:56:13 +0000

    dev-util/ccache: enable USE=static-c++ by default.
    
    People keep reporting ccache failures when building older gcc releases.
    Let's enable USE=static-c++ by default for FEATURES=ccache Just Work.
    
    Bug: https://bugs.gentoo.org/761220
    Package-Manager: Portage-3.0.20, Repoman-3.0.3
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 dev-util/ccache/ccache-4.3-r3.ebuild | 91 ++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)