[cfe-dev] [Driver][OpenMP] -L for build/install dir is after system dirs
Joel E. Denny via cfe-dev
cfe-dev at lists.llvm.org
Thu Aug 2 09:10:11 PDT 2018
Hi,
I'm trying to understand clang's ordering of -L flags, which, on my system,
leads to linking against a system libomp rather than the clang/LLVM libomp.
Specifically, on my system, running with -v shows that it specifies
-L/usr/lib/x86_64-linux-gnu before the -L for my llvm/clang build/install
directory. The effect is that it finds the system libomp.so.5 as libomp.
When the executable loads, it then looks for libomp.so.5 instead of the
libomp.so built for llvm, so even LD_LIBRARY_PATH doesn't help it find the
latter.
Is this intended behavior for some reason? Shouldn't clang prefer its own
libraries before system libraries?
A fix for my use case is to, in lib/Driver/ToolChains/Linux.cpp, move the
following lines from near the end of the Linux constructor to earlier,
right after the declaration of the Paths variable:
if (StringRef(D.Dir).startswith(SysRoot))
addPathIfExists(D, D.Dir + "/../lib", Paths);
By the way, in case it helps, the ToolChain constructor also tries to
insert the following subdirectories of the build/install directory, but
they don't exist on my system:
lib/clang/7.0.0/x86_64-unknown-linux-gnu/lib
lib/clang/7.0.0/lib/linux/x86_64
Thanks.
Joel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180802/a5b74d76/attachment.html>
More information about the cfe-dev
mailing list