libomp linking issue

Hi all,
Today I hit an issue and took me quite a while to find out what the problem was.
Even though now I understand the problem, I don’t know which piece should be fixed.

My workstation has ubuntu 18.04 and libomp from package manager is installed on the machine.
Thus I got and under /usr/lib/x86_64-linux-gnu/.
I need the dev llvm and thus build my own llvm with libomp and libomptarget enabled.

When I compile and link a simple main.
clang++ -fopenmp main.cpp # using my clang build.

ldd a.out => /usr/lib/x86_64-linux-gnu/ (0x00007fdf0701f000)
The OS version gets picked up.

Even I put my clang lib on the LD_LIBRARY_PATH. doesn’t get picked up due to “.5” expected by a.out.

Q1. why clang doesn’t put -L lib_of_my_clang_build by default?
Now I compile with offload flag

clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda main.cpp # using my clang build.
I got segfault when my build libomptarget tries to talk to libomp from the OS.
Q2, is there no check of consistency between libomp and libomptarget?

I can put -L lib_of_my_clang_build as a workaround but this is ugly.
Need more experienced people to find a clean solution.



Hi Ye,

I previously worked on a patch for this issue, and Hal was one of the reviewers:

I waited on some related patches to be upstreamed (I believe D59168 and D62469, and there may have been followup patches I missed), and then I never got back to it.

Would you like to take over this work?