[cfe-dev] [RFC] Recognize -fuse-ld={bfd, gold, lld} but don't prepend "ld." or "ld64." for other values

Fangrui Song via cfe-dev cfe-dev at lists.llvm.org
Wed May 20 12:10:27 PDT 2020

In https://reviews.llvm.org/D80225 I intended to update the semantics of -fuse-ld=
Some context (from my archaeology) about the option

* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55470 added support for -fuse-ld=bfd to mean ld.bfd and -fuse-ld=gold to mean ld.gold
* rL194328 ported the feature and made -fuse-ld= available for other values (with the ld. prefix)
* D78290 changed the prefix to ld64. on Darwin.
* GCC added support for -fuse-ld=lld. No other value than bfd,gold,lld is allowed (so our
   behavior change here will not be incompatible with GCC).

Our existing behavior is cumbersome:

* Inconsistency between an absolute
   path (which does not get a ld.  prefix) and a relative path (which gets
   a ld. prefix) For a relative path, -fuse-ld=dir/foo currently tries to
   access x86_64-unknown-linux-gnu-ld.dir/foo (if
   LLVM_DEFAULT_TARGET_TRIPLE is x86_64-unknown-linux-gnu).
* lld's new Mach-O port needs to pick an executable name. It would be
   nice if -fuse-ld= simply accepts a program name, not necessarily prefixed by `ld64.`

I suggest we just hard code the currently used values which intend to get
a prefix: bfd, gold, lld. For all other values, don't add a prefix.
(PS4 seems to use -fuse-ld=ps4 but it overrides ToolChain::GetLinkerPath, thus unaffected)


More information about the cfe-dev mailing list