-
Notifications
You must be signed in to change notification settings - Fork 5.1k
build: use GNU ld instead of gold for GCC build #41187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I still need to figure out why the matrix test is failing, but I was able to build successfully on Ubuntu 25.04, which ships with binutils 2.44 and no gold linker (though a separate binutils-gold package is still available). Here are the steps I used for a manual build: Start the build container:
Inside the container:
|
gcc is also failing - not sure if same reason - in that case it fails the configure step - annoyingly it swallows the actual failure the matrix test is basically a test of a minimal build environment - to ensure what defaults are picked - and that the bazelrc/etc doesnt break anything in those cases error is
which is strange as its there i think - and ultimately points to the correct binary afaict |
this is the likely cuplrit
removing the gold fuse-ld from the toolchain config makes it default to using lld (or trying to) not sure if it should be doing that but i would say the safer thing in that case is to explicitly set it to bfd |
a69bb36
to
2b7167b
Compare
I had to reintroduce the explicit linker configuration to the However, the build still fails elsewhere with:
see failure log. This may be coming from Bazel's |
is it not this line:
|
fwiw we did just update rules_cc - so it could be your local is using a different version to ci |
Ah I somehow missed the flag in bazel/rbe/toolchains/configs/linux/gcc/cc/cc_toolchain_config.bzl 😳 Surely it is that. |
2b7167b
to
342e898
Compare
i think it gets used locally also afaict at least |
564bd43
to
84f8960
Compare
i think this is close to the finish line - current error collect2: fatal error: ld terminated with signal 9 [Killed] which is an OOM in an RBE worker - weve hit similar in the past - not sure if just upping the machine for the failing test will resolve but probably worth a try try adding: rbe_pool = "6gig", to |
84f8960
to
c1a30ca
Compare
hmm - unfortunately it now looks like a game of whack-a-mole also if there are more than one or 2 of these tests that only require more memory for gcc linking then we would need to add selects so the (many more) llvm tests arent also using bigger machines (perhaps unreliably) chatgpt suggests there are ways to optimize mem for the bfd linker - that might be an option |
the other option that im wondering about ... just stick with gold until we cant, in the hope that some better option magically appears cc @jwendell as maintainer on project that builds with gcc |
I can still try optimization like I guess yet another option could be to try |
@tsaarni I'm trying to build your branch locally, but it's failing:
the params file: https://gist.github.com/jwendell/43533d974bfc379cd85afe963564d3ce |
Since GNU ld does not support |
|
@tsaarni I figured it out, feel free to incorporate my changes in this PR: jwendell@5301a3d |
c1a30ca
to
686c415
Compare
Gold is deprecated beginning from GNU binutils 2.44. It is no longer included in standard binutils release and it is scheduled for complete removal. Signed-off-by: Tero Saarni <tero.saarni@est.tech>
686c415
to
50ca392
Compare
Thanks @jwendell! I was aware of that toolchain configuration option, but I didn’t realize it could also be set in I’ve also tried adding |
hmm, yeah - i think thats going to be a blocker tbh been thinking about this a bit the last few days the plan is to move to use hermetic toolchains for both llvm and gcc - at that point i think it would be feasible to use lld for the gcc build - as it woudnt rely on the host install - or potentially some other linker that can give us comparable performance/resource usage |
Commit Message: build: use GNU ld instead of gold for GCC build
Additional Description:
When building with GCC using
--config=gcc
the build system now uses GNU ld. Gold is deprecated beginning from GNU binutils 2.44. It is no longer included in standard binutils release and it is scheduled for complete removal. See https://lwn.net/Articles/1007541/.Risk Level: Low
Testing:
Docs Changes:
Release Notes: GCC builds now use GNU ld. The gold linker was deprecated in binutils 2.44.
Platform Specific Features:
Fixes #41171