Skip to content

[Flang] position of -L$LLVM_DIR/lib #129688

@kawashima-fj

Description

@kawashima-fj

The Flang driver puts -L$LLVM_DIR/lib -lflang_rt.runtime after OS library directory -L options when linking.

$ 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.

#100403 and open-mpi/ompi#13116 suffer from this problem.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions