From a4574f3cfd55c014d0e09956fe413835debe1b87 Mon Sep 17 00:00:00 2001 From: Changqing Li Date: Tue, 7 Dec 2021 04:55:48 +0000 Subject: [PATCH] Correct library search path for OpenEmbedded Host For OpenEmbedded Host, the gcc install path is /usr/lib/x86_64-[distroname]-linux/[gcc-version]. So the library search path is not found with default triple 'x86_64-linux-gnu' for x86_64. Causing following error: [snip] compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang -target x86_64-linux -isystem/path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/include -O2 -pipe /path/to/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/share/cmake-3.21/Modules/CMakeCCompilerABI.c` | /build/tmp-glibc/hosttools/ld: cannot find -lgcc | /build/tmp-glibc/hosttools/ld: cannot find -lgcc | clang-13: error: linker command failed with exit code 1 (use -v to see invocation) [snip] before this patch: b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin 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 after this patch: b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin 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 Upstream-Status: Inappropriate [oe specific] Signed-off-by: Changqing Li Signed-off-by: Khem Raj --- clang/include/clang/Driver/Distro.h | 2 ++ clang/lib/Driver/Distro.cpp | 1 + clang/lib/Driver/ToolChains/Linux.cpp | 1 + 3 files changed, 4 insertions(+) diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h index 1aaf93ddb7c4..31f03e327b78 100644 --- a/clang/include/clang/Driver/Distro.h +++ b/clang/include/clang/Driver/Distro.h @@ -45,6 +45,7 @@ public: RHEL7, Fedora, Gentoo, + //CLANG_EXTRA_OE_DISTRO_NAME OpenSUSE, UbuntuHardy, UbuntuIntrepid, @@ -135,6 +136,7 @@ public: bool IsGentoo() const { return DistroVal == Gentoo; } + //CLANG_EXTRA_OE_DISTRO_CHECK /// @} }; diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp index 87a0c5a58511..b607a3f18d1e 100644 --- a/clang/lib/Driver/Distro.cpp +++ b/clang/lib/Driver/Distro.cpp @@ -44,6 +44,7 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) { .Case("sles", Distro::OpenSUSE) .Case("opensuse", Distro::OpenSUSE) .Case("exherbo", Distro::Exherbo) + //CLANG_EXTRA_OE_DISTRO_CASE .Default(Distro::UnknownDistro); return Version; } diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index 20c7c7a745be..f5d9b3187cf5 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -78,6 +78,7 @@ std::string Linux::getMultiarchTriple(const Driver &D, return "x86_64-linux-android"; if (TargetEnvironment == llvm::Triple::GNUX32) return "x86_64-linux-gnux32"; + //CLANG_EXTRA_OE_DISTRO_TRIPLE return "x86_64-linux-gnu"; case llvm::Triple::aarch64: if (IsAndroid)