summaryrefslogtreecommitdiffstats
path: root/recipes-devtools
diff options
context:
space:
mode:
authorChangqing Li <changqing.li@windriver.com>2021-12-07 05:04:15 +0000
committerKhem Raj <raj.khem@gmail.com>2021-12-09 08:54:15 -0800
commitedca114de1c04bdce4fe6b71ab42f4b0aa2e88e7 (patch)
tree2fef6bd1bc57c1557bbd8760ad4ebcc5326d5e61 /recipes-devtools
parent7294d0ec96f7a8396632b7153c8a76c58b142412 (diff)
downloadmeta-clang-edca114de1c04bdce4fe6b71ab42f4b0aa2e88e7.tar.gz
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 <changqing.li@windriver.com>
Diffstat (limited to 'recipes-devtools')
-rw-r--r--recipes-devtools/clang/clang/0037-Fix-lib-paths-for-OpenEmbedded-Host.patch81
-rw-r--r--recipes-devtools/clang/clang/0038-Correct-library-search-path-for-OpenEmbedded-Host.patch86
-rw-r--r--recipes-devtools/clang/common.inc2
-rw-r--r--recipes-devtools/clang/llvm-project-source.inc31
4 files changed, 200 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0037-Fix-lib-paths-for-OpenEmbedded-Host.patch b/recipes-devtools/clang/clang/0037-Fix-lib-paths-for-OpenEmbedded-Host.patch
new file mode 100644
index 0000000..2a2fff3
--- /dev/null
+++ b/recipes-devtools/clang/clang/0037-Fix-lib-paths-for-OpenEmbedded-Host.patch
@@ -0,0 +1,81 @@
1From 76e66abe135908b9d987e9a96aab0176391ee38a Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Tue, 7 Dec 2021 04:08:22 +0000
4Subject: [PATCH] Fix lib paths for OpenEmbedded Host
5
6Under OpenEmbedded Host, while building with clang-native, it cannot find
7the GCCInstallPath, which causing following error:
8[snip]
9compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
10-target x86_64-linux
11-isystem/path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/include
12-O2 -pipe
13/path/to/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/share/cmake-3.21/Modules/CMakeCCompilerABI.c`
14hosttools/ld: cannot find crtbeginS.o: No such file or directory
15[snip]
16
17Before this patch:
18compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
19clang version 13.0.1 (https://github.com/llvm/llvm-project 08e3a5ccd952edee36b3c002e3a29c6b1b5153de)
20Target: x86_64-unknown-linux-gnu
21Thread model: posix
22InstalledDir: /build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
23Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.2.0
24
25After this patch:
26compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
27clang version 13.0.1 (https://github.com/llvm/llvm-project 08e3a5ccd952edee36b3c002e3a29c6b1b5153de)
28Thread model: posix
29InstalledDir: /build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
30Found candidate GCC installation: /usr/lib/gcc/x86_64-wrs-linux/10.2.0
31Found candidate GCC installation: /usr/lib/x86_64-wrs-linux/10.2.0
32Selected GCC installation: /usr/lib/x86_64-wrs-linux/10.2.0
33Candidate multilib: .;@m64
34Selected multilib: .;@m64
35
36Summary:
37For OpenEmbedded Host, sysroots are of the form<sysroot>/usr/lib/<triple>/x.y.z.
38Take x86-64 as example, the default triple is x86_64-unknown-linux-gnu.
39For clang-native, the target vendor is '-unknown', need to test current distro
40to follow above form.
41
42Upstream-Status: Inappropriate [oe specific]
43
44Signed-off-by: Changqing Li <changqing.li@windriver.com>
45---
46 clang/lib/Driver/ToolChains/Gnu.cpp | 5 ++++-
47 1 file changed, 4 insertions(+), 1 deletion(-)
48
49diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
50index 3350bda709f5..c03a839d1c72 100644
51--- a/clang/lib/Driver/ToolChains/Gnu.cpp
52+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
53@@ -22,6 +22,7 @@
54 #include "clang/Driver/Options.h"
55 #include "clang/Driver/Tool.h"
56 #include "clang/Driver/ToolChain.h"
57+#include "clang/Driver/Distro.h"
58 #include "llvm/Option/ArgList.h"
59 #include "llvm/Support/CodeGen.h"
60 #include "llvm/Support/Path.h"
61@@ -2530,6 +2531,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
62 const llvm::Triple &TargetTriple, const ArgList &Args,
63 const std::string &LibDir, StringRef CandidateTriple,
64 bool NeedsBiarchSuffix, bool GCCDirExists, bool GCCCrossDirExists) {
65+ Distro Distro(D.getVFS(), TargetTriple);
66 // Locations relative to the system lib directory where GCC's triple-specific
67 // directories might reside.
68 struct GCCLibSuffix {
69@@ -2547,7 +2549,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
70 // files in that location, not just GCC installation data.
71 {CandidateTriple.str(), "..",
72 TargetTriple.getVendor() == llvm::Triple::Freescale ||
73- TargetTriple.getVendor() == llvm::Triple::OpenEmbedded},
74+ TargetTriple.getVendor() == llvm::Triple::OpenEmbedded ||
75+ Distro.IsOpenEmbedded()},
76
77 // This is the normal place.
78 {"gcc/" + CandidateTriple.str(), "../..", GCCDirExists},
79--
802.32.0
81
diff --git a/recipes-devtools/clang/clang/0038-Correct-library-search-path-for-OpenEmbedded-Host.patch b/recipes-devtools/clang/clang/0038-Correct-library-search-path-for-OpenEmbedded-Host.patch
new file mode 100644
index 0000000..b114483
--- /dev/null
+++ b/recipes-devtools/clang/clang/0038-Correct-library-search-path-for-OpenEmbedded-Host.patch
@@ -0,0 +1,86 @@
1From f790cf664e6d7ac2da4bf24caa82e7f166d592d8 Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Tue, 7 Dec 2021 04:55:48 +0000
4Subject: [PATCH] Correct library search path for OpenEmbedded Host
5
6For OpenEmbedded Host, the gcc install path is
7/usr/lib/x86_64-[distroname]-linux/[gcc-version].
8So the library search path is not found with default triple
9'x86_64-linux-gnu' for x86_64. Causing following error:
10[snip]
11compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang
12-target x86_64-linux
13-isystem/path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/include
14-O2 -pipe
15/path/to/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/share/cmake-3.21/Modules/CMakeCCompilerABI.c`
16| /build/tmp-glibc/hosttools/ld: cannot find -lgcc
17| /build/tmp-glibc/hosttools/ld: cannot find -lgcc
18| clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
19[snip]
20
21before this patch:
22b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs
23programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
24libraries: =/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
25
26after this patch:
27b59da142f2b0:$ /path/to/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin/clang --print-search-dirs
28programs: =/build/tmp-glibc/work/x86_64-linux/compiler-rt-native/13.0.1-r0/recipe-sysroot-native/usr/bin
29libraries: =/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
30
31Upstream-Status: Inappropriate [oe specific]
32
33Signed-off-by: Changqing Li <changqing.li@windriver.com>
34---
35 clang/include/clang/Driver/Distro.h | 2 ++
36 clang/lib/Driver/Distro.cpp | 1 +
37 clang/lib/Driver/ToolChains/Linux.cpp | 1 +
38 3 files changed, 4 insertions(+)
39
40diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h
41index 0d2a0939639e..5556f473899f 100644
42--- a/clang/include/clang/Driver/Distro.h
43+++ b/clang/include/clang/Driver/Distro.h
44@@ -43,6 +43,7 @@ public:
45 RHEL7,
46 Fedora,
47 Gentoo,
48+ //CLANG_EXTRA_OE_DISTRO_NAME
49 OpenSUSE,
50 UbuntuHardy,
51 UbuntuIntrepid,
52@@ -130,6 +131,7 @@ public:
53
54 bool IsGentoo() const { return DistroVal == Gentoo; }
55
56+ //CLANG_EXTRA_OE_DISTRO_CHECK
57 /// @}
58 };
59
60diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
61index c4cf4e48b5b8..2695c0ab85c2 100644
62--- a/clang/lib/Driver/Distro.cpp
63+++ b/clang/lib/Driver/Distro.cpp
64@@ -44,6 +44,7 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
65 .Case("sles", Distro::OpenSUSE)
66 .Case("opensuse", Distro::OpenSUSE)
67 .Case("exherbo", Distro::Exherbo)
68+ //CLANG_EXTRA_OE_DISTRO_CASE
69 .Default(Distro::UnknownDistro);
70 return Version;
71 }
72diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
73index 46c83b002e6c..e356616229c1 100644
74--- a/clang/lib/Driver/ToolChains/Linux.cpp
75+++ b/clang/lib/Driver/ToolChains/Linux.cpp
76@@ -77,6 +77,7 @@ std::string Linux::getMultiarchTriple(const Driver &D,
77 return "x86_64-linux-android";
78 if (TargetEnvironment == llvm::Triple::GNUX32)
79 return "x86_64-linux-gnux32";
80+ //CLANG_EXTRA_OE_DISTRO_TRIPLE
81 return "x86_64-linux-gnu";
82 case llvm::Triple::aarch64:
83 if (IsAndroid)
84--
852.32.0
86
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc
index c0d0cd8..7d83c10 100644
--- a/recipes-devtools/clang/common.inc
+++ b/recipes-devtools/clang/common.inc
@@ -46,6 +46,8 @@ SRC_URI = "\
46 file://0034-compiler-rt-Do-not-force-thumb-mode-directive.patch \ 46 file://0034-compiler-rt-Do-not-force-thumb-mode-directive.patch \
47 file://0035-clang-Do-not-use-install-relative-libc-headers.patch \ 47 file://0035-clang-Do-not-use-install-relative-libc-headers.patch \
48 file://0036-clang-Fix-how-driver-finds-GCC-installation-path-on-.patch \ 48 file://0036-clang-Fix-how-driver-finds-GCC-installation-path-on-.patch \
49 file://0037-Fix-lib-paths-for-OpenEmbedded-Host.patch \
50 file://0038-Correct-library-search-path-for-OpenEmbedded-Host.patch \
49 " 51 "
50# Fallback to no-PIE if not set 52# Fallback to no-PIE if not set
51GCCPIE ??= "" 53GCCPIE ??= ""
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 = ""
22# space separated list of additional distro vendor values we want to support e.g. 22# space separated list of additional distro vendor values we want to support e.g.
23# "yoe webos" or "-yoe -webos" '-' is optional 23# "yoe webos" or "-yoe -webos" '-' is optional
24CLANG_EXTRA_OE_VENDORS ?= "${TARGET_VENDOR} ${SDK_VENDOR}" 24CLANG_EXTRA_OE_VENDORS ?= "${TARGET_VENDOR} ${SDK_VENDOR}"
25# Extra OE DISTRO that want to support as build host. space separated list of additional distro.
26# ":" separated the ID in "/etc/os-release" and the triple for finding gcc on this OE DISTRO.
27# eg: "poky:poky wrlinux:wrs"
28CLANG_EXTRA_OE_DISTRO ?= "poky:poky"
25 29
26python add_distro_vendor() { 30python add_distro_vendor() {
27 import subprocess 31 import subprocess
@@ -51,6 +55,33 @@ python add_distro_vendor() {
51 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 55 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
52 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_VENDORS_CASES#%s#g' -i ${S}/llvm/lib/Support/Triple.cpp" % (case)) 56 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_VENDORS_CASES#%s#g' -i ${S}/llvm/lib/Support/Triple.cpp" % (case))
53 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 57 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
58
59
60 case = ""
61 triple = ""
62 name = ""
63 check = ""
64 oe_names = ""
65 distros = d.getVar('CLANG_EXTRA_OE_DISTRO')
66 for distro in distros.split():
67 distro_id = distro.split(":")[0].replace('-','_')
68 distro_triple = distro.split(":")[1]
69 case += '\\n .Case("' + distro_id + '", Distro::' + distro_id.upper() + ')'
70 triple += '\\n if (Distro.Is' + distro_id.upper() + '())\\n return "x86_64-' + distro_triple + '-linux",'
71 name += '\\n '+ distro_id.upper() + ','
72 check += '\\nbool Is' + distro_id.upper() + '() const { return DistroVal == ' + distro_id.upper() + '; }'
73 oe_names += distro_id.upper() + ' ||'
74
75 check += '\\nbool IsOpenEmbedded() const { return DistroVal == ' + oe_names[0:-3] + '; }'
76
77 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_NAME#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (name))
78 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
79 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CHECK#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (check))
80 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
81 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_TRIPLES#%s#g' ${S}/clang/lib/Driver/ToolChains/Linux.cpp" % (triple))
82 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
83 cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CASES#%s#g' -i ${S}/clang/lib/Driver/Distro.cpp" % (case))
84 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
54} 85}
55 86
56do_patch[postfuncs] += "add_distro_vendor" 87do_patch[postfuncs] += "add_distro_vendor"