[Openmp-commits] [PATCH] D55725: [OpenMP] Add libs to clang-dedicated directories
Joel E. Denny via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jan 25 13:15:19 PST 2019
jdenny added a comment.
In D55725#1371349 <https://reviews.llvm.org/D55725#1371349>, @jdenny wrote:
> In D55725#1370622 <https://reviews.llvm.org/D55725#1370622>, @hfinkel wrote:
>
> > > lib/clang/9.0.0/lib/linux/x86_64 is what this patch currently chooses as it's another place Clang looks. But is that any better or worse than the next option?
> >
> > So Clang always searches this directory
>
>
> `ToolChain::ToolChain` in `lib/Driver/ToolChain.cpp` always looks for it (it's the last of three directories), so I think that means yes.
>
> > but we never put anything there?
>
> Not that I've found in the configurations I've tried.
>
> > I vaguely recall that this is where the compiler-rt libs used to be.
>
> I don't know.
Suddenly, some of the story here came back to me. I apologize for forgetting this earlier.
Clang's `-frtlib-add-rpath` checks for `lib/clang/9.0.0/lib/linux/x86_64` and then sets `-rpath` to it so that you don't have to set `LD_LIBRARY_PATH` for your executable. It doesn't check for the other Clang-dedicated directories. That was my original motivation to install libraries there rather than in `lib/clang/9.0.0/x86_64-unknown-linux-gnu/lib`.
In `clang/lib/Driver/ToolChains/CommonArgs.cpp`, `tools::addArchSpecificRPath` is what performs that check, and it's called by `tools::addOpenMPRuntime` and `addSanitizerRuntime`. However, none of my configurations ever install any library (including a sanitizer or openmp library) in that directory.
I just checked my notes from a #llvm conversation, and I looked at D30015 <https://reviews.llvm.org/D30015>, D30700 <https://reviews.llvm.org/D30700>, and D45145 <https://reviews.llvm.org/D45145>, where this functionality was added. I was told all this might have been created for an android toolchain, so maybe most people don't see its benefit.
Should I change this patch back to using that directory so that `-frtlib-add-rpath` is useful for openmp (outside of android toolchains)? I don't know. I've noticed it does indeed locate the correct `libomp.so`, but offloading to my GPU doesn't happen (based on watching `nvidia-smi` to see what runs on it). Based on some googling I did back when I was writing this patch, it seems it might be something that's changed in the behavior of `-rpath` for transitive or indirect dependencies. Indeed, if I use `-Wl,-rpath=lib -Wl,--disable-new-dtags` to get the old `-rpath` behavior, offloading works fine. But old behavior is obviously not the path forward.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55725/new/
https://reviews.llvm.org/D55725
More information about the Openmp-commits
mailing list