Issue 129688
Summary [Flang] position of `-L$LLVM_DIR/lib`
Labels flang:driver
Assignees
Reporter kawashima-fj
    The Flang driver puts `-L$LLVM_DIR/lib -lflang_rt.runtime` after OS library directory `-L` options when linking.

```console
$ flang -### test.f90 |& tail -1 | tr ' ' '\n' | grep '^"-[Ll]'
"-L/home/foo/llvm/bin/../lib/aarch64-unknown-linux-gnu"
"-L/usr/lib/gcc/aarch64-linux-gnu/13"
"-L/lib/aarch64-linux-gnu"
"-L/usr/lib/aarch64-linux-gnu"
"-L/lib"
"-L/usr/lib"
"-L/home/foo/llvm/lib"
"-lflang_rt.runtime"
"-lm"
"-lgcc"
"-lgcc_s"
"-lc"
"-lgcc"
"-lgcc_s"
```

If you install Flang (and Flang-RT) manually on an environment where the OS-provided Flang package is already installed, this has a problem.

When user-installed Flang is invoked, `libflang_rt.runtime` in the user-installed directory should be linked. However, OS-provided `libflang_rt.runtime` in `/lib` (or `/lib/TRIPLE` or `/lib64`, depending on OS) is linked instead.

https://github.com/llvm/llvm-project/issues/100403 and https://github.com/open-mpi/ompi/issues/13116 suffer from this problem.

Should we prioritize `-L$LLVM_DIR/lib` over `-L/lib`?

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to