From b34b67256aa36ceb6bce1b6f657ad129ecf90313 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 11 Feb 2022 12:29:14 -0800 Subject: [PATCH] clang: exclude openembedded distributions from setting rpath on openmp executables 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. Upstream-Status: Submitted [https://reviews.llvm.org/D119590] Signed-off-by: Khem Raj --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index dfab4075e03e..14c6f0a3b21d 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -794,6 +794,11 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args, void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { + // OpenEmbedded/Yocto installs libomp.so into /usr/lib + // therefore using -rpath is not needed, on the contrary it adds + // paths from cross compiler install location which is not correct + if (TC.getTriple().getVendor() == llvm::Triple::OpenEmbedded) + return; if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath, options::OPT_fno_openmp_implicit_rpath, true)) {