From 539e8d85f4eb359d24b052efc6d4f7a9858fdbce Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Tue, 23 Mar 2021 09:19:06 -0700 Subject: clang: allow to set CLANG_EXTRA_OE_VENDORS to support custom TARGET_VENDOR value * instead of hardcoding only yoe, poky, wrs in the patch, add just placeholder string which gets replaced with a list based on CLANG_EXTRA_OE_VENDORS variable in llvm-project-source.inc:add_more_target_vendors Signed-off-by: Martin Jansa --- README.md | 34 ++++++++++++++++++++++ ...4-set-Yocto-based-GCC-install-search-path.patch | 7 ++++- ...-llvm-Recognize-yoe-and-poky-as-OE-distro.patch | 13 +++++---- recipes-devtools/clang/llvm-project-source.inc | 17 +++++++++++ 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1ee28ae..826b8b3 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,40 @@ if a component does not build with libc++, you can add it to `conf/nonclangable. CXX_remove_pn-_toolchain-clang = " -stdlib=libc++ " ``` +# compiler-rt failing in do_configure with custom TARGET_VENDOR + +If your DISTRO sets own value of TARGET_VENDOR, then it's need to be added in +CLANG_EXTRA_OE_VENDORS, it should be done automatically, but if compiler-rt fails +like bellow, then check the end of work-shared/llvm-project-source-12.0.0-r0/temp/log.do_patch +is should have line like: +NOTE: Adding support following TARGET_VENDOR values: foo in + /OE/build/oe-core/tmp-glibc/work-shared/llvm-project-source-12.0.0-r0/git/llvm/lib/Support/Triple.cpp and + /OE/build/oe-core/tmp-glibc/work-shared/llvm-project-source-12.0.0-r0/git/clang/lib/Driver/ToolChains/Gnu.cpp +and check these files if //CLANG_EXTRA_OE_VENDORS* strings were replaced correctly. +Read add_more_target_vendors function in recipes-devtools/clang/llvm-project-source.inc for more details. + +http://errors.yoctoproject.org/Errors/Details/574365/ +```shell +-- Found assembler: TOPDIR/tmp-glibc/work/core2-64-foo-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/x86_64-foo-linux/x86_64-foo-linux-clang +-- Detecting C compiler ABI info +-- Detecting C compiler ABI info - failed +-- Check for working C compiler: TOPDIR/tmp-glibc/work/core2-64-foo-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/x86_64-foo-linux/x86_64-foo-linux-clang +-- Check for working C compiler: TOPDIR/tmp-glibc/work/core2-64-foo-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/x86_64-foo-linux/x86_64-foo-linux-clang - broken +CMake Error at TOPDIR/tmp-glibc/work/core2-64-foo-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message): + The C compiler + + "TOPDIR/tmp-glibc/work/core2-64-foo-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/x86_64-foo-linux/x86_64-foo-linux-clang" + + is not able to compile a simple test program. + + It fails with the following output: + + Change Dir: TOPDIR/tmp-glibc/work/core2-64-foo-linux/compiler-rt/12.0.0-r0/build/CMakeFiles/CMakeTmp + + Run Build Command(s):ninja cmTC_928f4 && [1/2] Building C object CMakeFiles/cmTC_928f4.dir/testCCompiler.c.o + [2/2] Linking C executable cmTC_928f4 +``` + # Dependencies ```shell diff --git a/recipes-devtools/clang/clang/0026-For-x86_64-set-Yocto-based-GCC-install-search-path.patch b/recipes-devtools/clang/clang/0026-For-x86_64-set-Yocto-based-GCC-install-search-path.patch index 03bc290..dd4317f 100644 --- a/recipes-devtools/clang/clang/0026-For-x86_64-set-Yocto-based-GCC-install-search-path.patch +++ b/recipes-devtools/clang/clang/0026-For-x86_64-set-Yocto-based-GCC-install-search-path.patch @@ -43,8 +43,13 @@ 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_more_target_vendors() + Upstream-Status: Inappropriate [oe specific] +Signed-off-by: Martin Jansa Signed-off-by: Hongxu Jia Signed-off-by: Khem Raj --- @@ -59,7 +64,7 @@ index 05d1d3003881..e56812145e6d 100644 "x86_64-redhat-linux", "x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux", "x86_64-unknown-linux", -+ "x86_64-oe-linux", "x86_64-poky-linux", "x86_64-wrs-linux", ++ "x86_64-oe-linux", //CLANG_EXTRA_OE_VENDORS_TRIPLES "x86_64-amazon-linux", "x86_64-linux-android"}; static const char *const X32LibDirs[] = {"/libx32"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; diff --git a/recipes-devtools/clang/clang/0029-llvm-Recognize-yoe-and-poky-as-OE-distro.patch b/recipes-devtools/clang/clang/0029-llvm-Recognize-yoe-and-poky-as-OE-distro.patch index 16bc8be..5e4bc95 100644 --- a/recipes-devtools/clang/clang/0029-llvm-Recognize-yoe-and-poky-as-OE-distro.patch +++ b/recipes-devtools/clang/clang/0029-llvm-Recognize-yoe-and-poky-as-OE-distro.patch @@ -5,7 +5,12 @@ Subject: [PATCH] llvm: Recognize yoe and poky as OE distro 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_more_target_vendors() + Signed-off-by: Khem Raj +Signed-off-by: Martin Jansa Add wrs Signed-off-by: Yi Fan Yu @@ -17,13 +22,11 @@ diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 4f483c965282..abd181759786 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp -@@ -490,6 +490,9 @@ static Triple::VendorType parseVendor(StringRef VendorName) { +@@ -490,6 +490,6 @@ static Triple::VendorType parseVendor(StringRef VendorName) { .Case("mesa", Triple::Mesa) .Case("suse", Triple::SUSE) - .Case("oe", Triple::OpenEmbedded) -+ .Case("yoe", Triple::OpenEmbedded) -+ .Case("poky", Triple::OpenEmbedded) -+ .Case("wrs", Triple::OpenEmbedded) +- .Case("oe", Triple::OpenEmbedded) ++ .Case("oe", Triple::OpenEmbedded)//CLANG_EXTRA_OE_VENDORS_CASES .Default(Triple::UnknownVendor); } diff --git a/recipes-devtools/clang/llvm-project-source.inc b/recipes-devtools/clang/llvm-project-source.inc index f6c552d..c954f4e 100644 --- a/recipes-devtools/clang/llvm-project-source.inc +++ b/recipes-devtools/clang/llvm-project-source.inc @@ -18,3 +18,20 @@ STAMPCLEAN = "${STAMPS_DIR}/work-shared/llvm-project-source-${PV}-*" INHIBIT_DEFAULT_DEPS = "1" DEPENDS = "" PACKAGES = "" + +# additional TARGET_VENDOR values we want to support +CLANG_EXTRA_OE_VENDORS ?= "${TARGET_VENDOR}" + +add_more_target_vendors() { + local cases="" triples="" + for dash_vendor in ${CLANG_EXTRA_OE_VENDORS}; do + vendor=`echo $dash_vendor | sed 's/^-//g'` + cases="$cases.Case(\"$vendor\", Triple::OpenEmbedded)" + triples="$triples\"x86_64-$vendor-linux\"," + done + bbnote "Adding support following TARGET_VENDOR values: ${CLANG_EXTRA_OE_VENDORS} in ${S}/llvm/lib/Support/Triple.cpp and ${S}/clang/lib/Driver/ToolChains/Gnu.cpp" + sed "s#//CLANG_EXTRA_OE_VENDORS_CASES#$cases#g" -i ${S}/llvm/lib/Support/Triple.cpp + sed "s#//CLANG_EXTRA_OE_VENDORS_TRIPLES#$triples#g" -i ${S}/clang/lib/Driver/ToolChains/Gnu.cpp +} + +do_patch[postfuncs] += "add_more_target_vendors" -- cgit v1.2.3-54-g00ecf