[clang] [clang][Driver] Obey -fuse-ld=... for -print-prog-name=ld output (PR #66698)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 18 14:50:00 PDT 2023


MaskRay wrote:

> > I think the 2013 GCC feature adding -fuse-ld= made this change, which is, frankly, strange. I wish that we don't this...
> 
> It's too late now. Build system code in the wild uses `$CC -print-prog-name=ld` and then expects to be able to invoke that program to get the linker that `$CC` usually uses. When `CC=gcc -fuse-ld=foo` that works, but when `CC=clang` it doesn't, whether there's a `-fuse-ld=...` in there or just the default in the toolchain configuration is something other than `ld`, such as when `ld.lld` is the default.

Can you comment on what projects need this? Can't we fix the projects instead? And what do they do with the linker path? Why don't they invoke the clang driver to run a link action?

There are quite a few distributions using lld by default and I haven't heard about any issue about `-print-prog-name=ld`.

> > lld has several names. For windows-msvc target triples it is `lld-link`, and for wasm triples it is wasm-ld.
> 
> ISTM that GetLinkerPath ought to produce the right name regardless and if it doesn't we can fix it to do so.

It is, but the current test will fail.

https://github.com/llvm/llvm-project/pull/66698


More information about the cfe-commits mailing list