0010-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. From d7480a67f7ee5ed3fdb8c5c847ffb5ed33efea80 Mon Sep 17 00:00:00 2001
  2. From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  3. Date: Tue, 9 Nov 2021 10:13:08 +0800
  4. Subject: [PATCH 10/34] clang: Look inside the target sysroot for compiler
  5. runtime
  6. In OE compiler-rt and libc++ are built and staged into target
  7. sysroot and not into resourcedir which is relative to clang
  8. driver installation where the libraries are not instlled
  9. Specific to cross compiling the way yocto/OE works
  10. Rebased to LLVM 14.0.0 by Jun Yuan Tan
  11. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  12. Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  13. ---
  14. clang/lib/Driver/ToolChain.cpp | 6 +++++-
  15. 1 file changed, 5 insertions(+), 1 deletion(-)
  16. diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
  17. index 7272cc29cc7c..bbc50233e01b 100644
  18. --- a/clang/lib/Driver/ToolChain.cpp
  19. +++ b/clang/lib/Driver/ToolChain.cpp
  20. @@ -13,6 +13,7 @@
  21. #include "ToolChains/Flang.h"
  22. #include "clang/Basic/ObjCRuntime.h"
  23. #include "clang/Basic/Sanitizers.h"
  24. +#include "clang/Basic/Version.h"
  25. #include "clang/Config/config.h"
  26. #include "clang/Driver/Action.h"
  27. #include "clang/Driver/Driver.h"
  28. @@ -410,7 +411,10 @@ StringRef ToolChain::getOSLibName() const {
  29. }
  30. std::string ToolChain::getCompilerRTPath() const {
  31. - SmallString<128> Path(getDriver().ResourceDir);
  32. + SmallString<128> Path(getDriver().SysRoot);
  33. + StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
  34. + llvm::sys::path::append(Path, "/usr/", Twine("lib") + ClangLibdirSuffix, "clang",
  35. + CLANG_VERSION_STRING);
  36. if (Triple.isOSUnknown()) {
  37. llvm::sys::path::append(Path, "lib");
  38. } else {
  39. --
  40. 2.33.1