| Issue |
240798
|
| Summary |
[Clang][Driver][MIPS] Incorrect musl dynamic linker path for soft-float, n32 and R6 targets
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
peppergrayxyz
|
Clang's Linux driver selects an incorrect dynamic linker for several MIPS musl configurations.
|Target/options | Actual interpreter | Expected interpreter
|-|-|-|
|mips-linux-musl -msoft-float | ld-musl-mips.so.1 | ld-musl-mips-sf.so.1
|mips64el-linux-musl -mabi=n32 | ld-musl-mips64el.so.1 | ld-musl-mipsn32el.so.1
|mipsisa32r6el-linux-musl | ld-musl-mipsisa32r6el.so.1 | ld-musl-mipsr6el.so.1
|mips-linux-musl -march=mips32r6 | ld-musl-mips.so.1 |ld-musl-mipsr6.so.1
### Steps to reproduce
```bash
echo 'int main(void) { return 0; }' > t.c
clang --target=mips-unknown-linux-musl -msoft-float -### t.c 2>&1 | grep dynamic-linker
```
**Actual:**
```
"-dynamic-linker" "/lib/ld-musl-mips.so.1"
```
**Expected:**
```
"-dynamic-linker" "/lib/ld-musl-mips-sf.so.1"
```
### Root cause
In `clang/lib/Driver/ToolChains/Linux.cpp`, `Linux::getDynamicLinker()` currently derives the musl interpreter name from the target triple's architecture name. However, musl's MIPS dynamic linker naming convention also depends on the effective ABI, ISA revision, endianness and floating-point ABI. Musl constructs the interpreter name using LDSO_ARCH in `arch/mips*/reloc.h`, following:
`/lib/ld-musl-<mips|mips64|mipsn32>[r6][el][-sf].so.1`
As a result, Clang selects the wrong interpreter for soft-float, n32 and MIPS Release 6 configurations, including those selected through command-line options rather than the target triple.
See also:
- Related issue: https://github.com/llvm/llvm-project/issues/102259
- RISC-V precedent: https://github.com/llvm/llvm-project/pull/202513
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs