Issue 101661
Summary lld/ELF does not look in <sysroot>/usr/local/lib by default, while BFD ld does
Labels lld
Assignees
Reporter nico
    Prep: Put a library in /usr/local/lib:

```
debian@debian:~$ touch empty.c
debian@debian:~$ clang -c empty.c
debian@debian:~$ ar rcs libempty.a empty.o
debian@debian:~$ sudo cp libempty.a /usr/local/lib/
```

BFD LD finds it:

```
debian@debian:~$ clang main.c -lempty 
```

LLD doesn't:

```
debian@debian:~$ clang main.c -lempty -fuse-ld=lld
ld.lld: error: unable to find library -lempty
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

BFD LD gets it from the built-in linker script:

```
debian@debian:~$ clang main.c -Wl,--verbose | grep local
SEARCH_DIR("=/usr/local/lib/aarch64-linux-gnu"); SEARCH_DIR("=/lib/aarch64-linux-gnu"); SEARCH_DIR("=/usr/lib/aarch64-linux-gnu"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("=/usr/aarch64-linux-gnu/lib");
  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to