llvm / llvm/llvm-project

configuration file: `$-fuse-ld=lld` is ignored (LLVM 21 regression)

Open
#170,847 2 comments 0 reactions 0 assignees View on GitHub
clang:driver
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

It appears that `-fuse-ld=lld` with the `$` prefix introduced in LLVM 20 (see https://github.com/llvm/llvm-project/pull/117573) is ignored starting with LLVM 21.

Here is my clang.txt config file:

```
--target=thumbv6m-none-eabi
-nostdlib
$-fuse-ld=lld
```

And a minimal test.c file:

```c
void _start(void) {}
```

With Clang 20, it works correctly. It calls `ld.lld` to link:

```
$ clang-20 --config=./clang.txt -o test test.c -v
Ubuntu clang version 20.1.8 (++20250804090239+87f0227cb601-1~exp1~20250804210352.139)
Target: thumbv6m-unknown-none-eabi
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
Configuration file: /home/ayke/./clang.txt
"/usr/lib/llvm-20/bin/clang" -cc1 -triple thumbv6m-unknown-none-eabi -emit-obj -dumpdir test- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m0 -target-feature +soft-float -target-feature +soft-float-abi -target-feature -vfp2 -target-feature -vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature -fp64 -target-feature -d32 -target-feature -neon -target-feature -sha2 -target-feature -aes -target-feature -dotprod -target-feature -fp16fml -target-feature -bf16 -target-feature -mve -target-feature -mve.fp -target-feature -fpregs -target-feature +strict-align -target-abi aapcs -msoft-float -mfloat-abi soft -Wunaligned-access -debugger-tuning=gdb -fdebug-compilation-dir=/home/ayke -v -fcoverage-compilation-dir=/home/ayke -resource-dir /usr/lib/llvm-20/lib/clang/20 -internal-isystem /usr/lib/llvm-20/lib/clang/20/include -internal-isystem /usr/lib/llvm-20/bin/../lib/clang-runtimes/thumbv6m-none-eabi/include -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -o /tmp/test-f6e7ce.o -x c test.c
clang -cc1 version 20.1.8 based upon LLVM 20.1.8 default target aarch64-unknown-linux-gnu
ignoring nonexistent directory "/usr/lib/llvm-20/bin/../lib/clang-runtimes/thumbv6m-none-eabi/include"
ignoring duplicate directory "/usr/lib/llvm-20/lib/clang/20/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/llvm-20/lib/clang/20/include
End of search list.
"/usr/lib/llvm-20/bin/ld.lld" /tmp/test-f6e7ce.o -Bstatic -EL -L/usr/lib/llvm-20/bin/../lib/clang-runtimes/thumbv6m-none-eabi/lib -L/usr/lib/llvm-20/lib/clang/20/lib/thumbv6m-unknown-none-eabi -L/usr/lib/llvm-20/bin/../lib/clang-runtimes/thumbv6m-none-eabi/lib --target2=rel -o test
```

But with Clang 21, it calls the system linker instead:

```
$ clang-21 --config=./clang.txt -o test test.c -v
Ubuntu clang version 21.1.8 (++20251202083326+f68f64eb8130-1~exp1~20251202083450.66)
Target: thumbv6m-unknown-none-eabi
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
Configuration file: /home/ayke/./clang.txt
"/usr/lib/llvm-21/bin/clang" -cc1 -triple thumbv6m-unknown-none-eabi -emit-obj -dumpdir test- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m0 -target-feature +soft-float -target-feature +soft-float-abi -target-feature -vfp2 -target-feature -vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature -fp64 -target-feature -d32 -target-feature -neon -target-feature -sha2 -target-feature -aes -target-feature -dotprod -target-feature -fp16fml -target-feature -bf16 -target-feature -mve -target-feature -mve.fp -target-feature -fpregs -target-feature +strict-align -target-abi aapcs -msoft-float -mfloat-abi soft -Wunaligned-access -debugger-tuning=gdb -fdebug-compilation-dir=/home/ayke -v -fcoverage-compilation-dir=/home/ayke -resource-dir /usr/lib/llvm-21/lib/clang/21 -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/lib/llvm-21/bin/../lib/clang-runtimes/thumbv6m-none-eabi/include -ferror-limit 19 -fmessage-length=98 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -o /tmp/test-da6f79.o -x c test.c
clang -cc1 version 21.1.8 based upon LLVM 21.1.8 default target aarch64-unknown-linux-gnu
ignoring nonexistent directory "/usr/lib/llvm-21/bin/../lib/clang-runtimes/thumbv6m-none-eabi/include"
ignoring duplicate directory "/usr/lib/llvm-21/lib/clang/21/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/llvm-21/lib/clang/21/include
End of search list.
"/usr/bin/ld" -Bstatic -m armelf -EL -L/usr/lib/llvm-21/bin/../lib/clang-runtimes/thumbv6m-none-eabi/lib -L/usr/lib/llvm-21/lib/clang/21/lib/thumbv6m-unknown-none-eabi -L/usr/lib/llvm-21/bin/../lib/clang-runtimes/thumbv6m-none-eabi/lib /tmp/test-da6f79.o --target2=rel -o test
```

It happens to link in this case, but it's using the wrong linker.
Replacing `$-fuse-ld=lld` with `-fuse-ld=lld` (removing the `$` prefix) works around the problem.

I ran these tests in a Ubuntu 24.04 distrobox, with LLVM 20 and LLVM 21 installed from apt.llvm.org.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.