Skip to content

Commit 8cf4207

Browse files
hongxu-jiakraj
authored andcommitted
llvm/clang: Insert anchor for adding OE distro vendor names
This helps in making right detection for OE built gcc toolchains The //CLANG_EXTRA_OE_VENDORS_CASES string is replaced with list of additional Ceses based on CLANG_EXTRA_OE_VENDORS variable in recipes-devtools/clang/llvm-project-source.inc:add_distro_vendor() * For x86_64, set Yocto based GCC install search path Under Yocto host, while using clang-native to build, it searches install host gcc failed which causing the include file not found [snip] |clang++ -target x86_64-linux -MMD -MF src/base/files/file_path_constants.o.d -I../../../tools/gn/src -I. \ -isystem/tmp-glibc/work/x86_64-linux/gn-native/87.0.4280.141-r0/recipe-sysroot-native/usr/include -O2 -pipe \ -std=c++17 -c ../../../tools/gn/src/base/files/file_path_constants.cc -o src/base/files/file_path_constants.o |../../../tools/gn/src/base/files/file_path_constants.cc:7:10: fatal error: 'iterator' file not found |#include <iterator> | ^~~~~~~~ [snip] * Set three Yocto based GCC triple: poky, oe-core and wind river Before aplly the patch [snip] $ ../recipe-sysroot-native/usr/bin/clang++ -v clang version 11.0.1 (https://github.com/llvm/llvm-project 43ff75f) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir:tmp-glibc/work/x86_64-linux/gn-native/87.0.4280.141-r0/chromium-87.0.4280.141/../recipe-sysroot-native/usr/bin [snip] After this patch: [snip] $ ../recipe-sysroot-native/usr/bin/clang++ -v clang version 11.0.1 (https://github.com/llvm/llvm-project 22c3241ff9a6224261df48d0258957fd8acc3d64) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir:tmp-glibc/work/x86_64-linux/gn-native/87.0.4280.141-r0/chromium-87.0.4280.141/../recipe-sysroot-native/usr/bin Found candidate GCC installation: /usr/lib//x86_64-wrs-linux/10.1.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.1.0 Selected GCC installation: /usr/lib//x86_64-wrs-linux/10.1.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 [snip] BTW, it is hardly to insert a triple by the replacement of TARGET_SYS (=${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}), since TARGET_VENDOR is different between clang and clang-native * The //CLANG_EXTRA_OE_VENDORS_TRIPLES string is replaced with list of additional triples based on CLANG_EXTRA_OE_VENDORS variable in recipes-devtools/clang/llvm-project-source.inc:add_distro_vendor() * 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: Martin Jansa <martin.jansa@gmail.com> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Changqing Li <changqing.li@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 parent c3f0762 commit 8cf4207

File tree

5 files changed

+6
-1
lines changed

5 files changed

+6
-1
lines changed

clang/include/clang/Driver/Distro.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Distro {
4747
RHEL7,
4848
Fedora,
4949
Gentoo,
50+
//CLANG_EXTRA_OE_DISTRO_NAME
5051
OpenSUSE,
5152
UbuntuHardy,
5253
UbuntuIntrepid,
@@ -142,6 +143,7 @@ class Distro {
142143

143144
bool IsGentoo() const { return DistroVal == Gentoo; }
144145

146+
//CLANG_EXTRA_OE_DISTRO_CHECK
145147
/// @}
146148
};
147149

clang/lib/Driver/Distro.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
4343
.Case("sles", Distro::OpenSUSE)
4444
.Case("opensuse", Distro::OpenSUSE)
4545
.Case("exherbo", Distro::Exherbo)
46+
//CLANG_EXTRA_OE_DISTRO_CASE
4647
.Default(Distro::UnknownDistro);
4748
return Version;
4849
}

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
24542454
"x86_64-pc-linux-gnu", "x86_64-redhat-linux6E",
24552455
"x86_64-redhat-linux", "x86_64-suse-linux",
24562456
"x86_64-manbo-linux-gnu", "x86_64-slackware-linux",
2457+
"x86_64-oe-linux",//CLANG_EXTRA_OE_VENDORS_TRIPLES
24572458
"x86_64-unknown-linux", "x86_64-amazon-linux"};
24582459
static const char *const X32Triples[] = {"x86_64-linux-gnux32",
24592460
"x86_64-pc-linux-gnux32"};

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ std::string Linux::getMultiarchTriple(const Driver &D,
8282
return "x86_64-linux-android";
8383
if (TargetEnvironment == llvm::Triple::GNUX32)
8484
return "x86_64-linux-gnux32";
85+
//CLANG_EXTRA_OE_DISTRO_TRIPLE
8586
return "x86_64-linux-gnu";
8687
case llvm::Triple::aarch64:
8788
if (IsAndroid)

llvm/lib/TargetParser/Triple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
667667
.Case("mesa", Triple::Mesa)
668668
.Case("suse", Triple::SUSE)
669669
.Case("oe", Triple::OpenEmbedded)
670-
.Case("intel", Triple::Intel)
670+
.Case("intel", Triple::Intel) //CLANG_EXTRA_OE_VENDORS_CASES
671671
.Default(Triple::UnknownVendor);
672672
}
673673

0 commit comments

Comments
 (0)