[PATCH] D65880: [Driver] Move LIBRARY_PATH before user inputs
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 09:02:24 PDT 2020
MaskRay added a comment.
In D65880#2294871 <https://reviews.llvm.org/D65880#2294871>, @protze.joachim wrote:
> I still see some clang-specific and system link directories listed in the linker line before the directories from `LIBRARY_PATH`:
>
> $ LIBRARY_PATH=test1 /usr/local/clang/bin/clang -Ltest2 -v hello.c
> "/usr/bin/ld" .../crtbegin.o -Ltest2 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../.. -L/usr/local/clang/bin/../lib -L/lib -L/usr/lib -Ltest1
>
> I think they are inserted by `ToolChain.AddFilePathLibArgs` in Gnu.cpp. Is this the intended ordering? My expectation would be
>
> $ LIBRARY_PATH=test1 /usr/local/clang/bin/clang -Ltest2 -v hello.c
> "/usr/bin/ld" .../crtbegin.o -Ltest2 -Ltest1 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../.. -L/usr/local/clang/bin/../lib -L/lib -L/usr/lib
>
> @hfinkel any opinion?
In GCC, some system directories precede LIBRARY_PATH. I don't know the exact rule yet (but this patch made the behavior more similar)
% mkdir test1
% LIBRARY_PATH=test1 gcc-10 -Ltest2 -v a.c
...
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/l
ib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:test1/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65880/new/
https://reviews.llvm.org/D65880
More information about the llvm-commits
mailing list