<div dir="ltr"><div>Hi,<br></div><div><br></div><div>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.<br></div><div><br></div><div>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.<br></div><div><br></div><div></div><div>Is this intended behavior for some reason?  Shouldn't clang prefer its own libraries before system libraries?</div><br><div>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:<br></div><div style="margin-left:40px"><br></div><div><div style="margin-left:40px">if (StringRef(D.Dir).startswith(SysRoot))<br>  addPathIfExists(D, D.Dir + "/../lib", Paths);<br></div><br></div><div>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:<br></div><div><br></div><div><div style="margin-left:40px">lib/clang/7.0.0/x86_64-unknown-linux-gnu/lib<br>lib/clang/7.0.0/lib/linux/x86_64<br></div></div><br><div>Thanks.<br></div><div><br></div><div>Joel<br></div></div>