0028-Correct-library-search-path-for-OpenEmbedded-Host.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From a4574f3cfd55c014d0e09956fe413835debe1b87 Mon Sep 17 00:00:00 2001
  2. From: Changqing Li <changqing.li@windriver.com>
  3. Date: Tue, 7 Dec 2021 04:55:48 +0000
  4. Subject: [PATCH] Correct library search path for OpenEmbedded Host
  5. For OpenEmbedded Host, the gcc install path is
  6. /usr/lib/x86_64-[distroname]-linux/[gcc-version].
  7. So the library search path is not found with default triple
  8. 'x86_64-linux-gnu' for x86_64. Causing following error:
  9. [snip]
  10. compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
  11. -target x86_64-linux
  12. -isystem/path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/include
  13. -O2 -pipe
  14. /path/to/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/share/cmake-3.21/Modules/CMakeCCompilerABI.c`
  15. | /build/tmp-glibc/hosttools/ld: cannot find -lgcc
  16. | /build/tmp-glibc/hosttools/ld: cannot find -lgcc
  17. | clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
  18. [snip]
  19. before this patch:
  20. b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs
  21. programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
  22. libraries: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/lib/clang/13.0.1:/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/../lib://lib://usr/lib
  23. after this patch:
  24. b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs
  25. programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
  26. libraries: =/build/tmp-glibc/work/x84_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/lib/clang/13.0.1:/usr/lib/x86_64-wrs-linux/10.2.0://lib/x86_64-wrs-linux://usr/lib/x86_64-wrs-linux:/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/../lib://lib://usr/lib
  27. Upstream-Status: Inappropriate [oe specific]
  28. Signed-off-by: Changqing Li <changqing.li@windriver.com>
  29. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  30. ---
  31. clang/include/clang/Driver/Distro.h | 2 ++
  32. clang/lib/Driver/Distro.cpp | 1 +
  33. clang/lib/Driver/ToolChains/Linux.cpp | 1 +
  34. 3 files changed, 4 insertions(+)
  35. diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h
  36. index 1aaf93ddb7c4..31f03e327b78 100644
  37. --- a/clang/include/clang/Driver/Distro.h
  38. +++ b/clang/include/clang/Driver/Distro.h
  39. @@ -45,6 +45,7 @@ public:
  40. RHEL7,
  41. Fedora,
  42. Gentoo,
  43. + //CLANG_EXTRA_OE_DISTRO_NAME
  44. OpenSUSE,
  45. UbuntuHardy,
  46. UbuntuIntrepid,
  47. @@ -135,6 +136,7 @@ public:
  48. bool IsGentoo() const { return DistroVal == Gentoo; }
  49. + //CLANG_EXTRA_OE_DISTRO_CHECK
  50. /// @}
  51. };
  52. diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
  53. index 87a0c5a58511..b607a3f18d1e 100644
  54. --- a/clang/lib/Driver/Distro.cpp
  55. +++ b/clang/lib/Driver/Distro.cpp
  56. @@ -44,6 +44,7 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
  57. .Case("sles", Distro::OpenSUSE)
  58. .Case("opensuse", Distro::OpenSUSE)
  59. .Case("exherbo", Distro::Exherbo)
  60. + //CLANG_EXTRA_OE_DISTRO_CASE
  61. .Default(Distro::UnknownDistro);
  62. return Version;
  63. }
  64. diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
  65. index 20c7c7a745be..f5d9b3187cf5 100644
  66. --- a/clang/lib/Driver/ToolChains/Linux.cpp
  67. +++ b/clang/lib/Driver/ToolChains/Linux.cpp
  68. @@ -78,6 +78,7 @@ std::string Linux::getMultiarchTriple(const Driver &D,
  69. return "x86_64-linux-android";
  70. if (TargetEnvironment == llvm::Triple::GNUX32)
  71. return "x86_64-linux-gnux32";
  72. + //CLANG_EXTRA_OE_DISTRO_TRIPLE
  73. return "x86_64-linux-gnu";
  74. case llvm::Triple::aarch64:
  75. if (IsAndroid)