0030-clang-exclude-openembedded-distributions-from-settin.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From b34b67256aa36ceb6bce1b6f657ad129ecf90313 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Fri, 11 Feb 2022 12:29:14 -0800
  4. Subject: [PATCH] clang: exclude openembedded distributions from setting rpath
  5. on openmp executables
  6. OpenEmbedded based SDKs stage toolchains outsides the target rootfs and
  7. libomp.so is part of the target rootfs and not part of compiler
  8. toolchain install or relative to it. It finds the libraries via
  9. --sysroot during compile. This ensures that -rpath is not added for such
  10. systems, since it is adding cross-compile paths to rpath which is not
  11. correct when the binaries are run on real targets.
  12. Upstream-Status: Submitted [https://reviews.llvm.org/D119590]
  13. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  14. ---
  15. clang/lib/Driver/ToolChains/CommonArgs.cpp | 5 +++++
  16. 1 file changed, 5 insertions(+)
  17. diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
  18. index dfab4075e03e..14c6f0a3b21d 100644
  19. --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
  20. +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
  21. @@ -794,6 +794,11 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
  22. void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
  23. const ArgList &Args,
  24. ArgStringList &CmdArgs) {
  25. + // OpenEmbedded/Yocto installs libomp.so into <sysroot>/usr/lib
  26. + // therefore using -rpath is not needed, on the contrary it adds
  27. + // paths from cross compiler install location which is not correct
  28. + if (TC.getTriple().getVendor() == llvm::Triple::OpenEmbedded)
  29. + return;
  30. if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
  31. options::OPT_fno_openmp_implicit_rpath, true)) {