0027-Fix-lib-paths-for-OpenEmbedded-Host.patch 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From b8dd608a9ca83b9c321dce3ca0d18e8aeea987af Mon Sep 17 00:00:00 2001
  2. From: Changqing Li <changqing.li@windriver.com>
  3. Date: Tue, 7 Dec 2021 04:08:22 +0000
  4. Subject: [PATCH] Fix lib paths for OpenEmbedded Host
  5. Under OpenEmbedded Host, while building with clang-native, it cannot find
  6. the GCCInstallPath, which causing following error:
  7. [snip]
  8. compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
  9. -target x86_64-linux
  10. -isystem/path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/include
  11. -O2 -pipe
  12. /path/to/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/share/cmake-3.21/Modules/CMakeCCompilerABI.c`
  13. hosttools/ld: cannot find crtbeginS.o: No such file or directory
  14. [snip]
  15. Before this patch:
  16. compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
  17. clang version 13.0.1 (https://github.com/llvm/llvm-project 08e3a5ccd952edee36b3c002e3a29c6b1b5153de)
  18. Target: x86_64-unknown-linux-gnu
  19. Thread model: posix
  20. InstalledDir: /build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
  21. Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.2.0
  22. After this patch:
  23. compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
  24. clang version 13.0.1 (https://github.com/llvm/llvm-project 08e3a5ccd952edee36b3c002e3a29c6b1b5153de)
  25. Thread model: posix
  26. InstalledDir: /build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
  27. Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.2.0
  28. Found candidate GCC installation: /usr/lib/x86_64-wrs-linux/10.2.0
  29. Selected GCC installation: /usr/lib/x86_64-wrs-linux/10.2.0
  30. Candidate multilib: .;@m64
  31. Selected multilib: .;@m64
  32. Summary:
  33. For OpenEmbedded Host, sysroots are of the form<sysroot>/usr/lib/<triple>/x.y.z.
  34. Take x86-64 as example, the default triple is x86_64-unknown-linux-gnu.
  35. For clang-native, the target vendor is '-unknown', need to test current distro
  36. to follow above form.
  37. Upstream-Status: Inappropriate [oe specific]
  38. Signed-off-by: Changqing Li <changqing.li@windriver.com>
  39. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  40. ---
  41. clang/lib/Driver/ToolChains/Gnu.cpp | 5 ++++-
  42. 1 file changed, 4 insertions(+), 1 deletion(-)
  43. diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
  44. index 77f5c3f58a8b..0ec2dadafc05 100644
  45. --- a/clang/lib/Driver/ToolChains/Gnu.cpp
  46. +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
  47. @@ -18,6 +18,7 @@
  48. #include "Linux.h"
  49. #include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
  50. #include "clang/Driver/Compilation.h"
  51. +#include "clang/Driver/Distro.h"
  52. #include "clang/Driver/Driver.h"
  53. #include "clang/Driver/DriverDiagnostic.h"
  54. #include "clang/Driver/Options.h"
  55. @@ -2682,6 +2683,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
  56. const llvm::Triple &TargetTriple, const ArgList &Args,
  57. const std::string &LibDir, StringRef CandidateTriple,
  58. bool NeedsBiarchSuffix, bool GCCDirExists, bool GCCCrossDirExists) {
  59. + Distro Distro(D.getVFS(), TargetTriple);
  60. // Locations relative to the system lib directory where GCC's triple-specific
  61. // directories might reside.
  62. struct GCCLibSuffix {
  63. @@ -2699,7 +2701,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
  64. // files in that location, not just GCC installation data.
  65. {CandidateTriple.str(), "..",
  66. TargetTriple.getVendor() == llvm::Triple::Freescale ||
  67. - TargetTriple.getVendor() == llvm::Triple::OpenEmbedded},
  68. + TargetTriple.getVendor() == llvm::Triple::OpenEmbedded ||
  69. + Distro.IsOpenEmbedded()},
  70. // This is the normal place.
  71. {"gcc/" + CandidateTriple.str(), "../..", GCCDirExists},