How to change the default linker

I'm on aarch64 Linux, and I'm finding that ld.gold is giving a cryptic error message whereas regular ld at least gave a better-worded, understandable message.

FWIW that message from ld.gold is:

internal error in format_file_lineno, at ../../gold/dwarf_reader.cc:2278

How can I change the default linker?

1 Like

The problem you're seeing is that Swift is emitting DWARF 5 data, which the older version of ld.gold that you're running doesn't understand.

I don't think it's possible to change the default, sadly, without rebuilding the driver. You should be able to add -Xswiftc -use-ld=<other linker> to the SwiftPM command line (or -use-ld=<other linker> to swiftc itself) though.

Alternatively, installing a newer build of ld.gold that has DWARF 5 support should resolve this problem.

1 Like