From edca114de1c04bdce4fe6b71ab42f4b0aa2e88e7 Mon Sep 17 00:00:00 2001 From: Changqing Li Date: Tue, 7 Dec 2021 05:04:15 +0000 Subject: clang: for x86_64, correct GCC install search path for OpenEmbedded Host Build on OpenEmbedded Host, compiler-rt-native do_configure failed with following error: 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 crtbeginS.o: No such file or directory | /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) Since OpenEmbedded Host's gcc install path is different with clang's default search form, patch for OpenEmbedded Host's gcc library install path. Signed-off-by: Changqing Li --- recipes-devtools/clang/llvm-project-source.inc | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'recipes-devtools/clang/llvm-project-source.inc') diff --git a/recipes-devtools/clang/llvm-project-source.inc b/recipes-devtools/clang/llvm-project-source.inc index de7ba8a..a840030 100644 --- a/recipes-devtools/clang/llvm-project-source.inc +++ b/recipes-devtools/clang/llvm-project-source.inc @@ -22,6 +22,10 @@ PACKAGES = "" # space separated list of additional distro vendor values we want to support e.g. # "yoe webos" or "-yoe -webos" '-' is optional CLANG_EXTRA_OE_VENDORS ?= "${TARGET_VENDOR} ${SDK_VENDOR}" +# Extra OE DISTRO that want to support as build host. space separated list of additional distro. +# ":" separated the ID in "/etc/os-release" and the triple for finding gcc on this OE DISTRO. +# eg: "poky:poky wrlinux:wrs" +CLANG_EXTRA_OE_DISTRO ?= "poky:poky" python add_distro_vendor() { import subprocess @@ -51,6 +55,33 @@ python add_distro_vendor() { subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_VENDORS_CASES#%s#g' -i ${S}/llvm/lib/Support/Triple.cpp" % (case)) subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + + + case = "" + triple = "" + name = "" + check = "" + oe_names = "" + distros = d.getVar('CLANG_EXTRA_OE_DISTRO') + for distro in distros.split(): + distro_id = distro.split(":")[0].replace('-','_') + distro_triple = distro.split(":")[1] + case += '\\n .Case("' + distro_id + '", Distro::' + distro_id.upper() + ')' + triple += '\\n if (Distro.Is' + distro_id.upper() + '())\\n return "x86_64-' + distro_triple + '-linux",' + name += '\\n '+ distro_id.upper() + ',' + check += '\\nbool Is' + distro_id.upper() + '() const { return DistroVal == ' + distro_id.upper() + '; }' + oe_names += distro_id.upper() + ' ||' + + check += '\\nbool IsOpenEmbedded() const { return DistroVal == ' + oe_names[0:-3] + '; }' + + cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_NAME#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (name)) + subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CHECK#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (check)) + subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_TRIPLES#%s#g' ${S}/clang/lib/Driver/ToolChains/Linux.cpp" % (triple)) + subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CASES#%s#g' -i ${S}/clang/lib/Driver/Distro.cpp" % (case)) + subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) } do_patch[postfuncs] += "add_distro_vendor" -- cgit v1.2.3-54-g00ecf