@@ -3,42 +3,43 @@ From: Ruben De Smet <ruben.de.smet@rubdos.be>
33Date: Sun, 26 Jun 2022 10:57:51 +0200
44Subject: [PATCH] Clang: SailfishOS toolchain
55
6+ Co-authored-by: Matti Viljanen <matti.viljanen@kapsi.fi>
67Signed-off-by: Ruben De Smet <ruben.de.smet@rubdos.be>
78---
89 clang/include/clang/Driver/Distro.h | 5 +++++
910 clang/lib/Driver/Distro.cpp | 3 +++
1011 clang/lib/Driver/ToolChains/Gnu.cpp | 4 +++-
11- clang/lib/Driver/ToolChains/Linux.cpp | 8 ++++-- --
12- 4 files changed, 15 insertions(+), 5 deletions(-)
12+ clang/lib/Driver/ToolChains/Linux.cpp | 7 +++++ --
13+ 4 files changed, 16 insertions(+), 3 deletions(-)
1314
1415diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h
15- index 2723f75e8945..58616ad541e1 100644
16+ index 1aaf93ddb7c43ba8202e53288a934f9c76a13e2b..581a1712d9975dfdbd23792da3174644fdbc2d42 100644
1617--- a/clang/include/clang/Driver/Distro.h
1718+++ b/clang/include/clang/Driver/Distro.h
18- @@ -45 ,6 +45 ,7 @@ public:
19+ @@ -46 ,6 +46 ,7 @@ public:
1920 Fedora,
2021 Gentoo,
2122 OpenSUSE,
2223+ Sailfish,
2324 UbuntuHardy,
2425 UbuntuIntrepid,
2526 UbuntuJaunty,
26- @@ -124 ,6 +125 ,10 @@ public:
27- return DistroVal >= DebianLenny && DistroVal <= DebianBookworm ;
27+ @@ -127 ,6 +128 ,10 @@ public:
28+ return DistroVal >= DebianLenny && DistroVal <= DebianTrixie ;
2829 }
2930
3031+ bool IsSailfish() const {
3132+ return DistroVal == Sailfish;
3233+ }
3334+
3435 bool IsUbuntu() const {
35- return DistroVal >= UbuntuHardy && DistroVal <= UbuntuJammy ;
36+ return DistroVal >= UbuntuHardy && DistroVal <= UbuntuLunar ;
3637 }
3738diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
38- index 5ac38c34d112..cccb2026e527 100644
39+ index 87a0c5a58511561a4eac9e651e313542e638d2ca..de6457bd3dfb8cceeee89fea7cee41308ace337c 100644
3940--- a/clang/lib/Driver/Distro.cpp
4041+++ b/clang/lib/Driver/Distro.cpp
41- @@ -197 ,6 +197 ,9 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
42+ @@ -201 ,6 +201 ,9 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
4243 if (VFS.exists("/etc/gentoo-release"))
4344 return Distro::Gentoo;
4445
@@ -49,10 +50,10 @@ index 5ac38c34d112..cccb2026e527 100644
4950 }
5051
5152diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
52- index 7a9570a686f4..e7f57c824961 100644
53+ index 4f2340316654301ddcc70e293a9bf0da327a6de3..814f3482a1b598b24e4b3f63d811666791a6e260 100644
5354--- a/clang/lib/Driver/ToolChains/Gnu.cpp
5455+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
55- @@ -2073 ,7 +2073 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
56+ @@ -2218 ,7 +2218 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
5657 static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
5758 static const char *const AArch64Triples[] = {
5859 "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
@@ -61,27 +62,27 @@ index 7a9570a686f4..e7f57c824961 100644
6162 static const char *const AArch64beLibDirs[] = {"/lib"};
6263 static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
6364 "aarch64_be-linux-gnu"};
64- @@ -2082 ,6 +2082 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
65+ @@ -2227 ,6 +2227 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
6566 static const char *const ARMTriples[] = {"arm-linux-gnueabi"};
6667 static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
6768 "armv7hl-redhat-linux-gnueabi",
6869+ "armv7hl-meego-linux-gnueabi",
6970 "armv6hl-suse-linux-gnueabi",
7071 "armv7hl-suse-linux-gnueabi"};
7172 static const char *const ARMebLibDirs[] = {"/lib"};
72- @@ -2108 ,6 +2109 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
73+ @@ -2257 ,6 +2258 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
7374 "i586-linux-gnu", "i686-linux-gnu", "i686-pc-linux-gnu",
7475 "i386-redhat-linux6E", "i686-redhat-linux", "i386-redhat-linux",
7576 "i586-suse-linux", "i686-montavista-linux", "i686-gnu",
7677+ "i486-meego-linux"
7778 };
7879
79- static const char *const M68kLibDirs [] = {"/lib"};
80+ static const char *const LoongArch64LibDirs [] = {"/lib64", "/lib"};
8081diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
81- index 83cb41159de7..e7c2dcaef02a 100644
82+ index c6fb290ffdb4dc6a779737a4e838befbc7aba16e..72ef4fff4400f08cf429c1072f7edb69d8e440f5 100644
8283--- a/clang/lib/Driver/ToolChains/Linux.cpp
8384+++ b/clang/lib/Driver/ToolChains/Linux.cpp
84- @@ -194 ,7 +194 ,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
85+ @@ -197 ,7 +197 ,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
8586 }
8687
8788 if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
@@ -90,28 +91,20 @@ index 83cb41159de7..e7c2dcaef02a 100644
9091 ExtraOpts.push_back("-z");
9192 ExtraOpts.push_back("relro");
9293 }
93- @@ -233,13 +233,13 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
94- // Hexagon linker/loader does not support .gnu.hash
94+ @@ -241,12 +241,15 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
9595 if (!IsMips && !IsHexagon) {
96- if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
97- - (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) ||
98- + (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) || Distro.IsSailfish() ||
99- (IsAndroid && !Triple.isAndroidVersionLT(23)))
100- ExtraOpts.push_back("--hash-style=gnu");
101-
102- if (Distro.IsDebian() || Distro.IsOpenSUSE() ||
103- Distro == Distro::UbuntuLucid || Distro == Distro::UbuntuJaunty ||
104- - Distro == Distro::UbuntuKarmic ||
105- + Distro == Distro::UbuntuKarmic || Distro.IsSailfish() ||
106- (IsAndroid && Triple.isAndroidVersionLT(23)))
96+ if (Distro.IsOpenSUSE() || Distro == Distro::UbuntuLucid ||
97+ Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic ||
98+ - (IsAndroid && Triple.isAndroidVersionLT(23)))
99+ + Distro.IsSailfish() || (IsAndroid && Triple.isAndroidVersionLT(23)))
107100 ExtraOpts.push_back("--hash-style=both");
101+ else
102+ ExtraOpts.push_back("--hash-style=gnu");
108103 }
109- @@ -248,7 +248,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
104+
105+ + if (Distro.IsSailfish())
106+ + ExtraOpts.push_back("--enable-new-dtags");
107+ +
108+ #ifdef ENABLE_LINKER_BUILD_ID
110109 ExtraOpts.push_back("--build-id");
111110 #endif
112-
113- - if (IsAndroid || Distro.IsOpenSUSE())
114- + if (IsAndroid || Distro.IsOpenSUSE() || Distro.IsSailfish())
115- ExtraOpts.push_back("--enable-new-dtags");
116-
117- // The selection of paths to try here is designed to match the patterns which
0 commit comments