0016-clang-Fix-resource-dir-location-for-cross-toolchains.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 3b58bf71bf2908d1c7361e420b13330366402ea6 Mon Sep 17 00:00:00 2001
  2. From: Jim Broadus <jbroadus@xevo.com>
  3. Date: Thu, 26 Mar 2020 16:05:53 -0700
  4. Subject: [PATCH] clang: Fix resource dir location for cross toolchains
  5. When clang looks for the resources directory, it does so based on the binary
  6. location and assumes that the containing directory is a sibling to lib. The
  7. Yocto cross.bbclass defines the default bindir as
  8. ${exec_prefix}/bin/${CROSS_TARGET_SYS_DIR}. ex: /usr/bin/aarch64-poky-linux/.
  9. This causes clang to form a path that looks like /usr/bin/lib/clang/...
  10. As a fix for this, check the parent directory name. If that is "bin", then
  11. use that directory's parent.
  12. Upstream-Status: Pending
  13. Signed-off-by: Jim Broadus <jbroadus@xevo.com>
  14. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  15. ---
  16. clang/lib/Driver/Driver.cpp | 8 +++++++-
  17. 1 file changed, 7 insertions(+), 1 deletion(-)
  18. diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
  19. index a268f2fa8fc5..ab813044dc8c 100644
  20. --- a/clang/lib/Driver/Driver.cpp
  21. +++ b/clang/lib/Driver/Driver.cpp
  22. @@ -181,7 +181,13 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
  23. // With a static-library build of libclang, LibClangPath will contain the
  24. // path of the embedding binary, which for LLVM binaries will be in bin/.
  25. // ../lib gets us to lib/ in both cases.
  26. - P = llvm::sys::path::parent_path(Dir);
  27. + Dir = std::string(llvm::sys::path::parent_path(Dir));
  28. +
  29. + // OE cross toolchains are installed, by default, in a subdir of bin.
  30. + if (llvm::sys::path::filename(Dir) == "bin") {
  31. + Dir = std::string(llvm::sys::path::parent_path(Dir));
  32. + }
  33. + P = Dir;
  34. llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
  35. CLANG_VERSION_MAJOR_STRING);
  36. }