This is an archive of the discontinued LLVM Phabricator instance.

exclude openembedded distributions from setting rpath on openmp executables
Needs ReviewPublic

Authored by raj.khem on Feb 11 2022, 1:31 PM.

Details

Summary

OpenEmbedded based SDKs stage toolchains outsides the target rootfs and
libomp.so is part of the target rootfs and not part of compiler
toolchain install or relative to it. It finds the libraries via
--sysroot during compile. This ensures that -rpath is not added for such
systems, since it is adding cross-compile paths to rpath which is not
correct when the binaries are run on real targets.

Diff Detail

Event Timeline

raj.khem created this revision.Feb 11 2022, 1:31 PM
raj.khem requested review of this revision.Feb 11 2022, 1:31 PM
Herald added a project: Restricted Project. · View Herald Transcript

Cross compilers are a hazard here. I'd expect there to be a fairly long list of magic flags you need to pass to clang to get it to find the right libraries. Can you add fno-openmp-implicit-rpath to that list instead?

A better solution might be a cmake flag to specify where to use for the implicit rpath directory instead of deriving it from sys::path::parent_path. That would let your target set up a cross compiling toolchain that creates binaries that are able to find libomp et al in whatever directory they're located, without assuming a whole llvm toolchain installed onto the target.

Cross compilers are a hazard here. I'd expect there to be a fairly long list of magic flags you need to pass to clang to get it to find the right libraries. Can you add fno-openmp-implicit-rpath to that list instead?

hmmm, I would say the original patch made assumption about native compile is the only option, clang claims to be inherently cross compiler. Anyway adding -fno-openmp-implicit-rpath would mean that all SDKs generated by OpenEmbedded/Yocto project will have to somehow specify this option by default as well. it might work for system builds by specifying in global CFLAGS or adding to CC var itself.

A better solution might be a cmake flag to specify where to use for the implicit rpath directory instead of deriving it from sys::path::parent_path. That would let your target set up a cross compiling toolchain that creates binaries that are able to find libomp et al in whatever directory they're located, without assuming a whole llvm toolchain installed onto the target.

right. Cmake flag route seems a good one. I will explore it.

Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2022, 7:22 AM