-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e68bb43
commit b018058
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
diff --git a/lib/Driver/UnixToolChains.cpp b/lib/Driver/UnixToolChains.cpp | ||
index 61498c144a2..99d2c479849 100644 | ||
--- a/lib/Driver/UnixToolChains.cpp | ||
+++ b/lib/Driver/UnixToolChains.cpp | ||
@@ -9,6 +9,8 @@ | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
+#include <iostream> | ||
+#include <fstream> | ||
|
||
#include "ToolChains.h" | ||
|
||
@@ -111,6 +113,24 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation( | ||
} | ||
|
||
std::string toolchains::GenericUnix::getDefaultLinker() const { | ||
+ // Check if we are on Amazon Linux and set default linker to lld. | ||
+ if (getTriple().isOSLinux()) { | ||
+ std::string getLinuxDistro() { | ||
+ std::ifstream file("/etc/os-release"); | ||
+ std::string line; | ||
+ | ||
+ while (std::getline(file, line)) { | ||
+ if (line.substr(0, 3) == "ID=") { | ||
+ return line.substr(3); | ||
+ } | ||
+ } | ||
+ return "unknown"; // Return "unknown" if the ID field is not found | ||
+ } | ||
+ if (getLinuxDistro() == "amzn") { | ||
+ return "lld"; | ||
+ } | ||
+ } | ||
+ | ||
if (getTriple().isAndroid()) | ||
return "lld"; | ||
|