#718814 binutils: please provide a way to set system default linker to gold

Package:
binutils
Source:
binutils
Description:
GNU assembler, linker and binary utilities
Submitter:
Adam Borowski
Date:
2025-08-29 05:33:05 UTC
Severity:
wishlist
#718814#5
Date:
2013-08-05 19:55:33 UTC
From:
To:
Hi!
In squeeze and wheezy, if you had both bfd and gold installed, the latter
was the default.  This made sense, as gold is a lot faster and uses far less
memory.  Since version 2.23.52.20130722-1, the default reverted to bfd.
I'm afraid this causes a massive regression in some cases: what woken me up
was a test build suddenly taking 40 minutes instead of a couple tens of
seconds (obviously, bfd's profligate use of memory made the machine hit the
swap).  And even on smaller builds on big machines, going from 1.5 seconds
to 6 doesn't sound like much, but as linking tends to take 10-20% of build
time (depending on the linker used :p), it really adds up.

Obviously, the two packages + divert hack was awful, and deserved to go.

However, if you want bfd to become the default, please allow a clean
method of making gold the default on a given system.  Manually adding
-fuse-ld=gold to LDFLAGS works for a single project but is tedious,
especially considering that you need to autodetect whether that option
is supported or not.  For someone who compiles lots of distinct projects,
each with a different build system with its own idiosyncratic quirks,
modifying every single build system is pretty much out of question.
Having gold as a system's default has been proven to work (by squeeze
and wheezy), with only a handful of packages failing to build with one
or the other -- and for the most part they have been already modified
to call the linker they need.

Per gcc's docs:
       -fuse-ld=bfd
           Use the bfd linker instead of the default linker.
       -fuse-ld=gold
           Use the gold linker instead of the default linker.
so there is no assumption about what's the default.

I'm not sure what interface would be the best.
* a low-priority debconf question, altering the symlink in postinst?
  Probably the nicest.
* just not overwriting the symlink on upgrades, forcing the admin
  to handle it by hand?
* [diversions suck]
* ???

#718814#10
Date:
2013-09-20 12:31:37 UTC
From:
To:
Have you tried this?

$ export PATH=/usr/lib/gold-ld:$PATH

Berto

#718814#15
Date:
2014-03-20 17:53:24 UTC
From:
To:
Hi,


I also think the package should provide a painless way to set the
default linker (/usr/bin/ld) to gold.

I'm manually doing it with update-alternatives. Please consider shipping
this configuration in the package itself.

sudo update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold 20
sudo update-alternatives --install /usr/bin/ld ld /usr/bin/ld.bfd 20
sudo update-alternatives --config ld


Thanks

#718814#20
Date:
2014-03-22 14:10:48 UTC
From:
To:
Unfortunately this gets overwritten when the package binutils is
upgraded because it overwrites the /usr/bin/ld symlink


So, meanwhile the maintainer don't enables update-alternatives on the
package itself, setting the PATH as berto suggest is probably the best
option

#718814#25
Date:
2014-10-05 12:00:46 UTC
From:
To:
It would seem reasonable for binutils to add an alternative for ld, as Fedora does.
#718814#30
Date:
2017-02-13 00:23:51 UTC
From:
To:
Dear Customer,



Your item has arrived at February 11, but our courier was not able to deliver the parcel.



Please check the attachment for complete details!



Warm regards,

Angel Craig,

UPS Senior Station Manager.

#718814#35
Date:
2017-02-27 21:46:45 UTC
From:
To:
Dear Customer,



Your item has arrived at February 24, but our courier was not able to deliver the parcel.



Download postal receipt attached to e-mail!



With many thanks,

Clarence Moyer,

UPS Delivery Agent.

#718814#40
Date:
2017-10-29 15:46:44 UTC
From:
To:
This is still desired, via update-alternatives. Is there any hope that this will be addressed?