Skip to content

Commit 4a93414

Browse files
committed
[llvm] Add support for SailfishOS gcc toolchain. Contributes to JB#50500
1 parent 227d6e8 commit 4a93414

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

rpm/llvm-sailfishos-toolchain.patch

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
2+
index edeb31efab8..fd9e38db0ac 100644
3+
--- a/llvm/include/llvm/ADT/Triple.h
4+
+++ b/llvm/include/llvm/ADT/Triple.h
5+
@@ -149,7 +149,8 @@ public:
6+
Mesa,
7+
SUSE,
8+
OpenEmbedded,
9+
- LastVendorType = OpenEmbedded
10+
+ MeeGo,
11+
+ LastVendorType = MeeGo
12+
};
13+
enum OSType {
14+
UnknownOS,
15+
diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
16+
index d419463e6a5..916ebc28856 100644
17+
--- a/llvm/lib/Support/Triple.cpp
18+
+++ b/llvm/lib/Support/Triple.cpp
19+
@@ -166,6 +166,7 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {
20+
case AMD: return "amd";
21+
case Mesa: return "mesa";
22+
case SUSE: return "suse";
23+
+ case MeeGo: return "meego";
24+
case OpenEmbedded: return "oe";
25+
}
26+
27+
@@ -476,6 +477,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
28+
.Case("mesa", Triple::Mesa)
29+
.Case("suse", Triple::SUSE)
30+
.Case("oe", Triple::OpenEmbedded)
31+
+ .Case("meego", Triple::MeeGo)
32+
.Default(Triple::UnknownVendor);
33+
}
34+
35+
@@ -738,6 +740,9 @@ Triple::Triple(const Twine &Str)
36+
OS = parseOS(Components[2]);
37+
if (Components.size() > 3) {
38+
Environment = parseEnvironment(Components[3]);
39+
+ // MeeGo uses "gnueabi" to mean "gnueabihf"
40+
+ if (Vendor == Triple::MeeGo && Environment == Triple::GNUEABI)
41+
+ Environment = Triple::GNUEABIHF;
42+
ObjectFormat = parseFormat(Components[3]);
43+
}
44+
}
45+
@@ -789,6 +794,10 @@ Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
46+
ObjectFormat(parseFormat(EnvironmentStr.str())) {
47+
if (ObjectFormat == Triple::UnknownObjectFormat)
48+
ObjectFormat = getDefaultFormat(*this);
49+
+
50+
+ // MeeGo uses "gnueabi" to mean "gnueabihf"
51+
+ if (Vendor == Triple::MeeGo && Environment == Triple::GNUEABI)
52+
+ Environment = Triple::GNUEABIHF;
53+
}
54+
55+
std::string Triple::normalize(StringRef Str) {
56+
@@ -1051,6 +1065,9 @@ void Triple::getEnvironmentVersion(unsigned &Major, unsigned &Minor,
57+
unsigned &Micro) const {
58+
StringRef EnvironmentName = getEnvironmentName();
59+
StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
60+
+ // MeeGo uses "gnueabi" to mean "gnueabihf"
61+
+ if (Vendor == Triple::MeeGo && getEnvironment() == Triple::GNUEABIHF)
62+
+ EnvironmentTypeName = "gnueabi";
63+
if (EnvironmentName.startswith(EnvironmentTypeName))
64+
EnvironmentName = EnvironmentName.substr(EnvironmentTypeName.size());
65+
66+
diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp
67+
index 37ebe5dbcb2..2a69a2af8f5 100644
68+
--- a/llvm/unittests/ADT/TripleTest.cpp
69+
+++ b/llvm/unittests/ADT/TripleTest.cpp
70+
@@ -336,6 +336,12 @@ TEST(TripleTest, ParsedIDs) {
71+
EXPECT_EQ(Triple::Linux, T.getOS());
72+
EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
73+
74+
+ T = Triple("armv7hl-meego-linux-gnueabi");
75+
+ EXPECT_EQ(Triple::arm, T.getArch());
76+
+ EXPECT_EQ(Triple::MeeGo, T.getVendor());
77+
+ EXPECT_EQ(Triple::Linux, T.getOS());
78+
+ EXPECT_EQ(Triple::GNUEABIHF, T.getEnvironment());
79+
+
80+
T = Triple("i586-pc-haiku");
81+
EXPECT_EQ(Triple::x86, T.getArch());
82+
EXPECT_EQ(Triple::PC, T.getVendor());

rpm/llvm.spec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Summary: The Low Level Virtual Machine (An Optimizing Compiler Infrastructure)
1616
License: University of Illinois/NCSA Open Source License
1717
URL: http://llvm.org/
1818
Source: %{version}/%{name}-%{version}.tar.gz
19+
Patch0: llvm-sailfishos-toolchain.patch
1920
Requires(post): /sbin/ldconfig
2021
Requires(postun): /sbin/ldconfig
2122
BuildRequires: cmake, ninja
@@ -40,7 +41,7 @@ Requires: %{name} = %{version}
4041
LLVM Header files
4142

4243
%prep
43-
%setup -q -n %{name}-%{version}/%{name}
44+
%autosetup -p1 -n %{name}-%{version}/%{name}
4445

4546
%build
4647
pushd llvm

0 commit comments

Comments
 (0)