Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
futurejones committed Mar 1, 2024
1 parent e68bb43 commit b018058
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test-patches/amazonlinux-lld-UnixToolchains-v2.patch
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";

0 comments on commit b018058

Please sign in to comment.