diff options
author | Khem Raj <raj.khem@gmail.com> | 2021-10-20 17:36:48 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2021-10-20 21:47:26 -0700 |
commit | 27d31ea0ee2c4960f3cb1fbd214e99925d80575a (patch) | |
tree | 1f6e5c6d433614e73b0494a6eb32f50f5386923f | |
parent | 68b8f9b2425e54518211e2914064a5dd08c3aec6 (diff) | |
download | meta-clang-27d31ea0ee2c4960f3cb1fbd214e99925d80575a.tar.gz |
clang: Add patch to handle RISCV multilibs
Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r-- | recipes-devtools/clang/clang/0037-clang-Fix-how-driver-finds-GCC-installation-path-on-.patch | 100 | ||||
-rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
2 files changed, 101 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0037-clang-Fix-how-driver-finds-GCC-installation-path-on-.patch b/recipes-devtools/clang/clang/0037-clang-Fix-how-driver-finds-GCC-installation-path-on-.patch new file mode 100644 index 0000000..6b6ad04 --- /dev/null +++ b/recipes-devtools/clang/clang/0037-clang-Fix-how-driver-finds-GCC-installation-path-on-.patch | |||
@@ -0,0 +1,100 @@ | |||
1 | From aafdcb50517464cc915da3108e1d7422610a4fde Mon Sep 17 00:00:00 2001 | ||
2 | From: David Abdurachmanov <david.abdurachmanov@sifive.com> | ||
3 | Date: Wed, 20 Oct 2021 17:30:36 -0700 | ||
4 | Subject: [PATCH 37/37] clang: Fix how driver finds GCC installation path on | ||
5 | OpenEmbedded | ||
6 | |||
7 | Fix how Clang Driver finds GCC installation path on OpenEmbedded | ||
8 | |||
9 | - For RISCV (riscv{32,64}) we define new two multi-lib options without any | ||
10 | subdirectories (e.g., lib32/ilp32d or lib64/lp64d). OpenEmbedded GCC | ||
11 | builds don't use them. | ||
12 | - Modify how Clang Driver finds GCC installation path. This is important | ||
13 | because GCC files on OpenEmbedded are in two different directories: | ||
14 | (1) /usr/bin/../lib/gcc/riscv64-oe-linux/9.2.0 | ||
15 | (2) /usr/lib/riscv64-oe-linux/9.2.0 | ||
16 | |||
17 | Clang Driver will check (1) first. The directory exist, but will produce | ||
18 | no valid multi-libs and there will be no multi-lib selected. (2) contains | ||
19 | actual GCC run-time objects/libraries, but because the path has exact | ||
20 | same GCC version (9.2.0) it will be skipped. | ||
21 | |||
22 | We modify the approach by allowing to check other directories with the same | ||
23 | GCC version. We also avoid picking GCC installation path if it results in | ||
24 | an empty multi-lib list. | ||
25 | |||
26 | Upstream-Status: Pending | ||
27 | Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com> | ||
28 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
29 | --- | ||
30 | clang/lib/Driver/ToolChains/Gnu.cpp | 39 +++++++++++++++++++++-------- | ||
31 | 1 file changed, 28 insertions(+), 11 deletions(-) | ||
32 | |||
33 | diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp | ||
34 | index 553cb985737f..355c7798a7aa 100644 | ||
35 | --- a/clang/lib/Driver/ToolChains/Gnu.cpp | ||
36 | +++ b/clang/lib/Driver/ToolChains/Gnu.cpp | ||
37 | @@ -1652,18 +1652,29 @@ static void findRISCVMultilibs(const Driver &D, | ||
38 | return findRISCVBareMetalMultilibs(D, TargetTriple, Path, Args, Result); | ||
39 | |||
40 | FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS()); | ||
41 | - Multilib Ilp32 = makeMultilib("lib32/ilp32").flag("+m32").flag("+mabi=ilp32"); | ||
42 | - Multilib Ilp32f = | ||
43 | + MultilibSet RISCVMultilibs; | ||
44 | + | ||
45 | + if (TargetTriple.getVendor() == llvm::Triple::OpenEmbedded) { | ||
46 | + Multilib OpenEmbeddedIlp32d = makeMultilib("").flag("+m32").flag("+mabi=ilp32d"); | ||
47 | + Multilib OpenEmbeddedLp64d = makeMultilib("").flag("+m64").flag("+mabi=lp64d"); | ||
48 | + RISCVMultilibs = | ||
49 | + MultilibSet() | ||
50 | + .Either({OpenEmbeddedIlp32d, OpenEmbeddedLp64d}) | ||
51 | + .FilterOut(NonExistent); | ||
52 | + } else { | ||
53 | + Multilib Ilp32 = makeMultilib("lib32/ilp32").flag("+m32").flag("+mabi=ilp32"); | ||
54 | + Multilib Ilp32f = | ||
55 | makeMultilib("lib32/ilp32f").flag("+m32").flag("+mabi=ilp32f"); | ||
56 | - Multilib Ilp32d = | ||
57 | + Multilib Ilp32d = | ||
58 | makeMultilib("lib32/ilp32d").flag("+m32").flag("+mabi=ilp32d"); | ||
59 | - Multilib Lp64 = makeMultilib("lib64/lp64").flag("+m64").flag("+mabi=lp64"); | ||
60 | - Multilib Lp64f = makeMultilib("lib64/lp64f").flag("+m64").flag("+mabi=lp64f"); | ||
61 | - Multilib Lp64d = makeMultilib("lib64/lp64d").flag("+m64").flag("+mabi=lp64d"); | ||
62 | - MultilibSet RISCVMultilibs = | ||
63 | - MultilibSet() | ||
64 | - .Either({Ilp32, Ilp32f, Ilp32d, Lp64, Lp64f, Lp64d}) | ||
65 | - .FilterOut(NonExistent); | ||
66 | + Multilib Lp64 = makeMultilib("lib64/lp64").flag("+m64").flag("+mabi=lp64"); | ||
67 | + Multilib Lp64f = makeMultilib("lib64/lp64f").flag("+m64").flag("+mabi=lp64f"); | ||
68 | + Multilib Lp64d = makeMultilib("lib64/lp64d").flag("+m64").flag("+mabi=lp64d"); | ||
69 | + RISCVMultilibs = | ||
70 | + MultilibSet() | ||
71 | + .Either({Ilp32, Ilp32f, Ilp32d, Lp64, Lp64f, Lp64d}) | ||
72 | + .FilterOut(NonExistent); | ||
73 | + } | ||
74 | |||
75 | Multilib::flags_list Flags; | ||
76 | bool IsRV64 = TargetTriple.getArch() == llvm::Triple::riscv64; | ||
77 | @@ -2561,13 +2572,19 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( | ||
78 | continue; // Saw this path before; no need to look at it again. | ||
79 | if (CandidateVersion.isOlderThan(4, 1, 1)) | ||
80 | continue; | ||
81 | - if (CandidateVersion <= Version) | ||
82 | + if (CandidateVersion < Version) | ||
83 | continue; | ||
84 | |||
85 | if (!ScanGCCForMultilibs(TargetTriple, Args, LI->path(), | ||
86 | NeedsBiarchSuffix)) | ||
87 | continue; | ||
88 | |||
89 | + // We might have found existing directory with GCCVersion, but it | ||
90 | + // might not have GCC libraries we are looking for (i.e. return an | ||
91 | + // empty Mulilibs) | ||
92 | + if (Multilibs.size() == 0) | ||
93 | + continue; | ||
94 | + | ||
95 | Version = CandidateVersion; | ||
96 | GCCTriple.setTriple(CandidateTriple); | ||
97 | // FIXME: We hack together the directory name here instead of | ||
98 | -- | ||
99 | 2.33.1 | ||
100 | |||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index f1bfd19..913d831 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc | |||
@@ -46,6 +46,7 @@ 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-Drop-the-git-suffix-from-various-version-variables.patch \ | 47 | file://0035-Drop-the-git-suffix-from-various-version-variables.patch \ |
48 | file://0036-clang-Do-not-use-install-relative-libc-headers.patch \ | 48 | file://0036-clang-Do-not-use-install-relative-libc-headers.patch \ |
49 | file://0037-clang-Fix-how-driver-finds-GCC-installation-path-on-.patch \ | ||
49 | " | 50 | " |
50 | # Fallback to no-PIE if not set | 51 | # Fallback to no-PIE if not set |
51 | GCCPIE ??= "" | 52 | GCCPIE ??= "" |