[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 10:29:03 PDT 2018


Hi Jonas,

Replies are inline.

On Thu, Aug 2, 2018 at 1:00 PM, Jonas Hahnfeld <hahnjo at hahnjo.de> wrote:

> Hi Joel,
>
> I started a discussion about this on cfe-dev a while ago:
> http://lists.llvm.org/pipermail/cfe-dev/2017-January/052499.html


Thanks for the link.  I had missed that.


> The short answer is that there are / might be more libraries than just the
> OpenMP runtime (or libunwind in my case), so changing the default might
> break on some systems.
>

That's a good point.  However, there was a suggestion in that thread to
create a dedicated directory:

http://lists.llvm.org/pipermail/cfe-dev/2017-January/052510.html

That seems like the cleanest solution.  Was some problem found with that
proposal?


>
> I had a patch in https://reviews.llvm.org/D26244 that added a CMake flag
> to change the behaviour, but I lost interest after some time. Feel free to
> revive it if it's important for you.
>

I'd rather it just work without a special config.  I think a dedicated
directory would achieve that.

Thanks.

Joel


>
> Cheers,
> Jonas
>
>
> On 2018-08-02 18:10, Joel E. Denny via cfe-dev wrote:
>
>> 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
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180802/cd8063a5/attachment.html>


More information about the cfe-dev mailing list