-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0000-clang-openmandriva-triples.patch
265 lines (244 loc) · 13.9 KB
/
0000-clang-openmandriva-triples.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
diff -up llvm-project-release-19.x/clang/include/clang/Driver/Distro.h.1~ llvm-project-release-19.x/clang/include/clang/Driver/Distro.h
--- llvm-project-release-19.x/clang/include/clang/Driver/Distro.h.1~ 2024-09-03 16:09:11.000000000 +0200
+++ llvm-project-release-19.x/clang/include/clang/Driver/Distro.h 2024-09-05 14:19:06.507647381 +0200
@@ -80,6 +80,8 @@ public:
UbuntuMantic,
UbuntuNoble,
UbuntuOracular,
+ OpenMandriva,
+ ROSA,
UnknownDistro
};
@@ -138,6 +140,8 @@ public:
bool IsGentoo() const { return DistroVal == Gentoo; }
+ bool IsOpenMandriva() const { return DistroVal == OpenMandriva || DistroVal == ROSA; }
+
/// @}
};
diff -up llvm-project-release-19.x/clang/lib/Driver/Distro.cpp.1~ llvm-project-release-19.x/clang/lib/Driver/Distro.cpp
--- llvm-project-release-19.x/clang/lib/Driver/Distro.cpp.1~ 2024-09-03 16:09:11.000000000 +0200
+++ llvm-project-release-19.x/clang/lib/Driver/Distro.cpp 2024-09-05 14:19:06.507647381 +0200
@@ -33,7 +33,7 @@ static Distro::DistroType DetectOsReleas
Distro::DistroType Version = Distro::UnknownDistro;
// Obviously this can be improved a lot.
- for (StringRef Line : Lines)
+ for (StringRef Line : Lines) {
if (Version == Distro::UnknownDistro && Line.starts_with("ID="))
Version = llvm::StringSwitch<Distro::DistroType>(Line.substr(3))
.Case("alpine", Distro::AlpineLinux)
@@ -45,6 +45,15 @@ static Distro::DistroType DetectOsReleas
.Case("opensuse", Distro::OpenSUSE)
.Case("exherbo", Distro::Exherbo)
.Default(Distro::UnknownDistro);
+ else if (Version == Distro::UnknownDistro && Line.starts_with("DISTRIB_ID=MandrivaLinux"))
+ // It's one of the Mandriva successors -- will get details
+ // from DISTRIB_DESCRIPTION
+ Version = Distro::OpenMandriva;
+ else if (Version == Distro::OpenMandriva && Line.starts_with("DISTRIB_DESCRIPTION=")) {
+ if (Line.substr(20).find("ROSA") != StringRef::npos)
+ Version = Distro::ROSA;
+ }
+ }
return Version;
}
diff -up llvm-project-release-19.x/clang/lib/Driver/ToolChains/Gnu.cpp.1~ llvm-project-release-19.x/clang/lib/Driver/ToolChains/Gnu.cpp
--- llvm-project-release-19.x/clang/lib/Driver/ToolChains/Gnu.cpp.1~ 2024-09-03 16:09:11.000000000 +0200
+++ llvm-project-release-19.x/clang/lib/Driver/ToolChains/Gnu.cpp 2024-09-05 14:19:48.788112757 +0200
@@ -2464,7 +2464,8 @@ void Generic_GCC::GCCInstallationDetecto
static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const AArch64Triples[] = {
"aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
- "aarch64-suse-linux"};
+ "aarch64-suse-linux", "aarch64-openmandriva-linux-gnu", "aarch64-openmandriva-linux-musl",
+ "aarch64-openmandriva-linux-uclibc" };
static const char *const AArch64beLibDirs[] = {"/lib"};
static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu"};
@@ -2473,7 +2474,28 @@ void Generic_GCC::GCCInstallationDetecto
static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
"armv7hl-redhat-linux-gnueabi",
"armv6hl-suse-linux-gnueabi",
- "armv7hl-suse-linux-gnueabi"};
+ "armv7hl-suse-linux-gnueabi",
+ "armv7l-openmandriva-linux-gnueabihf",
+ "armv7hl-openmandriva-linux-gnueabihf",
+ "armv7hnl-openmandriva-linux-gnueabihf",
+ "armv8l-openmandriva-linux-gnueabihf",
+ "armv8hl-openmandriva-linux-gnueabihf",
+ "armv8hnl-openmandriva-linux-gnueabihf",
+ "armv8hcnl-openmandriva-linux-gnueabihf",
+ "armv7l-openmandriva-linux-musleabihf",
+ "armv7hl-openmandriva-linux-musleabihf",
+ "armv7hnl-openmandriva-linux-musleabihf",
+ "armv8l-openmandriva-linux-musleabihf",
+ "armv8hl-openmandriva-linux-musleabihf",
+ "armv8hnl-openmandriva-linux-musleabihf",
+ "armv8hcnl-openmandriva-linux-musleabihf",
+ "armv7l-openmandriva-linux-uclibceabihf",
+ "armv7hl-openmandriva-linux-uclibceabihf",
+ "armv7hnl-openmandriva-linux-uclibceabihf",
+ "armv8l-openmandriva-linux-uclibceabihf",
+ "armv8hl-openmandriva-linux-uclibceabihf",
+ "armv8hnl-openmandriva-linux-uclibceabihf",
+ "armv8hcnl-openmandriva-linux-uclibceabihf"};
static const char *const ARMebLibDirs[] = {"/lib"};
static const char *const ARMebTriples[] = {"armeb-linux-gnueabi"};
static const char *const ARMebHFTriples[] = {
@@ -2492,20 +2514,31 @@ void Generic_GCC::GCCInstallationDetecto
"x86_64-pc-linux-gnu", "x86_64-redhat-linux6E",
"x86_64-redhat-linux", "x86_64-suse-linux",
"x86_64-manbo-linux-gnu", "x86_64-slackware-linux",
- "x86_64-unknown-linux", "x86_64-amazon-linux"};
+ "x86_64-unknown-linux", "x86_64-amazon-linux",
+ "x86_64-openmandriva-linux-gnu", "x86_64-openmandriva-linux-musl",
+ "x86_64-openmandriva-linux-uclibc"
+ };
static const char *const X32Triples[] = {"x86_64-linux-gnux32",
- "x86_64-pc-linux-gnux32"};
+ "x86_64-pc-linux-gnux32",
+ "x86_64-openmandriva-linux-gnux32",
+ "x86_64-openmandriva-linux-muslx32",
+ "x86_64-openmandriva-linux-uclibcx32",
+ };
static const char *const X32LibDirs[] = {"/libx32", "/lib"};
static const char *const X86LibDirs[] = {"/lib32", "/lib"};
static const char *const X86Triples[] = {
"i586-linux-gnu", "i686-linux-gnu", "i686-pc-linux-gnu",
"i386-redhat-linux6E", "i686-redhat-linux", "i386-redhat-linux",
- "i586-suse-linux", "i686-montavista-linux",
+ "i586-suse-linux", "i686-montavista-linux", "i686-openmandriva-linux-gnu",
+ "i686-openmandriva-linux-musl", "i686-openmandriva-linux-uclibc"
};
static const char *const LoongArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const LoongArch64Triples[] = {
- "loongarch64-linux-gnu", "loongarch64-unknown-linux-gnu"};
+ "loongarch64-linux-gnu", "loongarch64-unknown-linux-gnu",
+ "loongarch64-openmandriva-linux-gnu", "loongarch64-openmandriva-linux-musl",
+ "loongarch64-openmandriva-linux-uclibc"
+ };
static const char *const M68kLibDirs[] = {"/lib"};
static const char *const M68kTriples[] = {"m68k-unknown-linux-gnu",
@@ -2551,18 +2584,33 @@ void Generic_GCC::GCCInstallationDetecto
static const char *const PPC64LibDirs[] = {"/lib64", "/lib"};
static const char *const PPC64Triples[] = {"powerpc64-unknown-linux-gnu",
"powerpc64-suse-linux",
- "ppc64-redhat-linux"};
+ "ppc64-redhat-linux",
+ "ppc64-openmandriva-linux-gnu",
+ "ppc64-openmandriva-linux-musl",
+ "ppc64-openmandriva-linux-uclibc"
+ };
static const char *const PPC64LELibDirs[] = {"/lib64", "/lib"};
static const char *const PPC64LETriples[] = {
"powerpc64le-unknown-linux-gnu", "powerpc64le-none-linux-gnu",
- "powerpc64le-suse-linux", "ppc64le-redhat-linux"};
+ "powerpc64le-suse-linux", "ppc64le-redhat-linux",
+ "ppc64le-openmandriva-linux-gnu", "ppc64le-openmandriva-linux-musl",
+ "ppc64le-openmandriva-linux-uclibc"
+ };
static const char *const RISCV32LibDirs[] = {"/lib32", "/lib"};
static const char *const RISCV32Triples[] = {"riscv32-unknown-linux-gnu",
- "riscv32-unknown-elf"};
+ "riscv32-unknown-elf",
+ "riscv32-openmandriva-linux-gnu",
+ "riscv32-openmandriva-linux-musl",
+ "riscv32-openmandriva-linux-uclibc"
+ };
static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"};
static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
- "riscv64-unknown-elf"};
+ "riscv64-unknown-elf",
+ "riscv64-openmandriva-linux-gnu",
+ "riscv64-openmandriva-linux-musl",
+ "riscv64-openmandriva-linux-uclibc"
+ };
static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",
diff -up llvm-project-release-19.x/clang/lib/Driver/ToolChains/Linux.cpp.1~ llvm-project-release-19.x/clang/lib/Driver/ToolChains/Linux.cpp
--- llvm-project-release-19.x/clang/lib/Driver/ToolChains/Linux.cpp.1~ 2024-09-03 16:09:11.000000000 +0200
+++ llvm-project-release-19.x/clang/lib/Driver/ToolChains/Linux.cpp 2024-09-05 14:19:06.507647381 +0200
@@ -175,7 +175,7 @@ std::string Linux::getMultiarchTriple(co
return TargetTriple.str();
}
-static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) {
+static StringRef getOSLibDir(const Distro &distro, const llvm::Triple &Triple, const ArgList &Args) {
if (Triple.isMIPS()) {
if (Triple.isAndroid()) {
StringRef CPUName;
@@ -203,14 +203,15 @@ static StringRef getOSLibDir(const llvm:
// FIXME: This is a bit of a hack. We should really unify this code for
// reasoning about oslibdir spellings with the lib dir spellings in the
// GCCInstallationDetector, but that is a more significant refactoring.
- if (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() ||
- Triple.getArch() == llvm::Triple::sparc)
+ if (!distro.IsOpenMandriva() &&
+ (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() ||
+ Triple.getArch() == llvm::Triple::sparc))
return "lib32";
if (Triple.getArch() == llvm::Triple::x86_64 && Triple.isX32())
return "libx32";
- if (Triple.getArch() == llvm::Triple::riscv32)
+ if (!distro.IsOpenMandriva() && Triple.getArch() == llvm::Triple::riscv32)
return "lib32";
return Triple.isArch32Bit() ? "lib" : "lib64";
@@ -235,7 +236,7 @@ Linux::Linux(const Driver &D, const llvm
}
if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
- Triple.isAndroid()) {
+ Distro.IsOpenMandriva() || Triple.isAndroid()) {
ExtraOpts.push_back("-z");
ExtraOpts.push_back("relro");
}
@@ -304,7 +305,7 @@ Linux::Linux(const Driver &D, const llvm
// to the link paths.
path_list &Paths = getFilePaths();
- const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
+ const std::string OSLibDir = std::string(getOSLibDir(Distro, Triple, Args));
const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
// mips32: Debian multilib, we use /libo32, while in other case, /lib is
diff -up llvm-project-release-19.x/llvm/include/llvm/TargetParser/Triple.h.1~ llvm-project-release-19.x/llvm/include/llvm/TargetParser/Triple.h
--- llvm-project-release-19.x/llvm/include/llvm/TargetParser/Triple.h.1~ 2024-09-03 16:09:11.000000000 +0200
+++ llvm-project-release-19.x/llvm/include/llvm/TargetParser/Triple.h 2024-09-05 14:19:06.507647381 +0200
@@ -194,7 +194,8 @@ public:
Mesa,
SUSE,
OpenEmbedded,
- LastVendorType = OpenEmbedded
+ OpenMandriva,
+ LastVendorType = OpenMandriva
};
enum OSType {
UnknownOS,
@@ -972,7 +973,7 @@ public:
return (getArch() == Triple::ppc64 &&
((getOS() == Triple::FreeBSD &&
(getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
- getOS() == Triple::OpenBSD || isMusl()));
+ getOS() == Triple::OpenBSD || isMusl()) || getVendor() == VendorType::OpenMandriva);
}
/// Tests whether the target 32-bit PowerPC uses Secure PLT.
@@ -981,7 +982,7 @@ public:
((getOS() == Triple::FreeBSD &&
(getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
getOS() == Triple::NetBSD || getOS() == Triple::OpenBSD ||
- isMusl()));
+ isMusl()) || getVendor() == VendorType::OpenMandriva);
}
/// Tests whether the target is 32-bit RISC-V.
diff -up llvm-project-release-19.x/llvm/lib/TargetParser/Triple.cpp.1~ llvm-project-release-19.x/llvm/lib/TargetParser/Triple.cpp
--- llvm-project-release-19.x/llvm/lib/TargetParser/Triple.cpp.1~ 2024-09-03 16:09:11.000000000 +0200
+++ llvm-project-release-19.x/llvm/lib/TargetParser/Triple.cpp 2024-09-05 14:19:06.507647381 +0200
@@ -250,6 +250,7 @@ StringRef Triple::getVendorTypeName(Vend
case MipsTechnologies: return "mti";
case NVIDIA: return "nvidia";
case OpenEmbedded: return "oe";
+ case OpenMandriva: return "openmandriva";
case PC: return "pc";
case SCEI: return "scei";
case SUSE: return "suse";
@@ -637,6 +638,7 @@ static Triple::VendorType parseVendor(St
.Case("mesa", Triple::Mesa)
.Case("suse", Triple::SUSE)
.Case("oe", Triple::OpenEmbedded)
+ .Case("openmandriva", Triple::OpenMandriva)
.Default(Triple::UnknownVendor);
}