Gold linker is deprecated

I think this is pretty new. When I run cargo build --release --target x86_64-unknown-linux-musl the binary gets built but I get

 WARN rustc_codegen_ssa::back::link Linker does not support -static-pie command line option. Retrying with -static instead.
warning: the gold linker is deprecated and has known bugs with Rust
  |
  = help: consider using LLD or ld from GNU binutils instead

What do I have to do here?

Hm, playing around. Using Aurora Linux I have installed brew install lld

Finally created ./.cargo/config.toml with

[target.x86_64-unknown-linux-musl]
linker = "ld.lld"

Now the warning is gone.

unsure if relevant, but similar issue on the bazel build ruyst rules repo

On Linux, rules_cc defaults to LLD, then gold, then the default ld (ld.bfd). If LLD is not installed globally, then it'll use gold, but gold is deprecated and not appropriate for Rust.

I have put the config.toml file into ~/.cargo/ directory. Now the setting is available globally for my user.

Nevertheless, I wasn't satisfied and tried to understand better. Here is what I found.

Building with --target x86_64-unknown-linux-musl on Fedora/Aurora produces:

WARN rustc_codegen_ssa::back::link Linker does not support -static-pie command line option. Retrying with -static instead.
warning: the gold linker is deprecated and has known bugs with Rust

The warning doesn't appear in an Arch based distrobox

Running ld --version I get

Fedora/Aurora base system: GNU gold (version 2.45.1-4.fc43) 1.16
Arch based distrobox:  GNU ld (GNU Binutils) 2.46

So my guess is that this is the root cause.