1- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2- From: Ruben De Smet <ruben.de.smet@rubdos.be>
3- Date: Sun, 26 Jun 2022 10:57:51 +0200
4- Subject: [PATCH] Clang: SailfishOS toolchain
5-
6- Signed-off-by: Ruben De Smet <ruben.de.smet@rubdos.be>
7- ---
8- clang/include/clang/Driver/Distro.h | 5 +++++
9- clang/lib/Driver/Distro.cpp | 3 +++
10- clang/lib/Driver/ToolChains/Gnu.cpp | 4 +++-
11- clang/lib/Driver/ToolChains/Linux.cpp | 8 ++++----
12- 4 files changed, 15 insertions(+), 5 deletions(-)
13-
141diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h
15- index 2723f75e8945..58616ad541e1 100644
2+ index a8de94163e8b..240587994938 100644
163--- a/clang/include/clang/Driver/Distro.h
174+++ b/clang/include/clang/Driver/Distro.h
18- @@ -45 ,6 +45 ,7 @@ public:
5+ @@ -46 ,6 +46 ,7 @@ public:
196 Fedora,
207 Gentoo,
218 OpenSUSE,
229+ Sailfish,
2310 UbuntuHardy,
2411 UbuntuIntrepid,
2512 UbuntuJaunty,
26- @@ -124 ,6 +125 ,10 @@ public:
27- return DistroVal >= DebianLenny && DistroVal <= DebianBookworm ;
13+ @@ -129 ,6 +130 ,10 @@ public:
14+ return DistroVal >= DebianLenny && DistroVal <= DebianTrixie ;
2815 }
2916
3017+ bool IsSailfish() const {
3118+ return DistroVal == Sailfish;
3219+ }
3320+
3421 bool IsUbuntu() const {
35- return DistroVal >= UbuntuHardy && DistroVal <= UbuntuJammy ;
22+ return DistroVal >= UbuntuHardy && DistroVal <= UbuntuNoble ;
3623 }
3724diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
38- index 5ac38c34d112..cccb2026e527 100644
25+ index a7e7f169dc14..cd8684020dfe 100644
3926--- a/clang/lib/Driver/Distro.cpp
4027+++ b/clang/lib/Driver/Distro.cpp
41- @@ -197 ,6 +197 ,9 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
28+ @@ -204 ,6 +204 ,9 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
4229 if (VFS.exists("/etc/gentoo-release"))
4330 return Distro::Gentoo;
4431
@@ -49,10 +36,10 @@ index 5ac38c34d112..cccb2026e527 100644
4936 }
5037
5138diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
52- index 7a9570a686f4..e7f57c824961 100644
39+ index e5e1b1d77269..3d0d38972977 100644
5340--- a/clang/lib/Driver/ToolChains/Gnu.cpp
5441+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
55- @@ -2073 ,7 +2073 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
42+ @@ -2452 ,7 +2452 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
5643 static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
5744 static const char *const AArch64Triples[] = {
5845 "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
@@ -61,27 +48,19 @@ index 7a9570a686f4..e7f57c824961 100644
6148 static const char *const AArch64beLibDirs[] = {"/lib"};
6249 static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
6350 "aarch64_be-linux-gnu"};
64- @@ -2082 ,6 +2082 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
51+ @@ -2461 ,6 +2461 ,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
6552 static const char *const ARMTriples[] = {"arm-linux-gnueabi"};
6653 static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
6754 "armv7hl-redhat-linux-gnueabi",
6855+ "armv7hl-meego-linux-gnueabi",
6956 "armv6hl-suse-linux-gnueabi",
7057 "armv7hl-suse-linux-gnueabi"};
7158 static const char *const ARMebLibDirs[] = {"/lib"};
72- @@ -2108,6 +2109,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
73- "i586-linux-gnu", "i686-linux-gnu", "i686-pc-linux-gnu",
74- "i386-redhat-linux6E", "i686-redhat-linux", "i386-redhat-linux",
75- "i586-suse-linux", "i686-montavista-linux", "i686-gnu",
76- + "i486-meego-linux"
77- };
78-
79- static const char *const M68kLibDirs[] = {"/lib"};
8059diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
81- index 83cb41159de7..e7c2dcaef02a 100644
60+ index 4300a2bdff17..8ac052972ebb 100644
8261--- a/clang/lib/Driver/ToolChains/Linux.cpp
8362+++ b/clang/lib/Driver/ToolChains/Linux.cpp
84- @@ -194 ,7 +194 ,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
63+ @@ -232 ,7 +232 ,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
8564 }
8665
8766 if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
@@ -90,28 +69,22 @@ index 83cb41159de7..e7c2dcaef02a 100644
9069 ExtraOpts.push_back("-z");
9170 ExtraOpts.push_back("relro");
9271 }
93- @@ -233,13 +233,13 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
72+ @@ -275,7 +275,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
9473 // Hexagon linker/loader does not support .gnu.hash
9574 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() ||
75+ if (Distro.IsOpenSUSE() || Distro == Distro::UbuntuLucid ||
76+ - Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic ||
77+ + Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic || Distro.IsSailfish() ||
10678 (IsAndroid && Triple.isAndroidVersionLT(23)))
10779 ExtraOpts.push_back("--hash-style=both");
108- }
109- @@ -248,7 +248,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
80+ else
81+ @@ -286,6 +286,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
11082 ExtraOpts.push_back("--build-id");
11183 #endif
11284
113- - if (IsAndroid || Distro.IsOpenSUSE())
114- + if (IsAndroid || Distro.IsOpenSUSE() || Distro.IsSailfish())
115- ExtraOpts.push_back("--enable-new-dtags");
116-
85+ + if (Distro.IsSailfish())
86+ + ExtraOpts.push_back("--enable-new-dtags");
87+ +
11788 // The selection of paths to try here is designed to match the patterns which
89+ // the GCC driver itself uses, as this is part of the GCC-compatible driver.
90+ // This was determined by running GCC in a fake filesystem, creating all
0 commit comments