-
-
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
91eadcc
commit b4f09db
Showing
5 changed files
with
132 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,23 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index c758792bf4a..e7fb71577f2 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -890,6 +890,9 @@ if(XCODE) | ||
swift_common_xcode_cxx_config() | ||
endif() | ||
|
||
+# Check what linux distribution is being used. | ||
+cmake_host_system_information(RESULT DISTRO_ID QUERY DISTRIB_ID) | ||
+ | ||
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use | ||
# our own defaults. This should only be possible in a unified (not stand alone) | ||
# build environment. | ||
@@ -901,6 +904,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQ | ||
set(SWIFT_USE_LINKER_default "lld") | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
set(SWIFT_USE_LINKER_default "") | ||
+elseif(DISTRO_ID STREQUAL "amzn") | ||
+ set(SWIFT_USE_LINKER_default "lld") | ||
else() | ||
set(SWIFT_USE_LINKER_default "gold") | ||
endif() |
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,23 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 43747db4d55..e96519c9169 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -948,6 +948,9 @@ if(XCODE) | ||
swift_common_xcode_cxx_config() | ||
endif() | ||
|
||
+# Check what linux distribution is being used. | ||
+cmake_host_system_information(RESULT DISTRO_NAME QUERY DISTRIB_PRETTY_NAME) | ||
+ | ||
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use | ||
# our own defaults. This should only be possible in a unified (not stand alone) | ||
# build environment. | ||
@@ -959,6 +962,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQ | ||
set(SWIFT_USE_LINKER_default "lld") | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
set(SWIFT_USE_LINKER_default "") | ||
+elseif(DISTRO_NAME STREQUAL "Amazon Linux 2023") | ||
+ set(SWIFT_USE_LINKER_default "lld") | ||
else() | ||
set(SWIFT_USE_LINKER_default "gold") | ||
endif() |
39 changes: 39 additions & 0 deletions
39
test-patches/amazonlinux-lld-UnixToolchains-main-bool.patch
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,39 @@ | ||
diff --git a/lib/Driver/UnixToolChains.cpp b/lib/Driver/UnixToolChains.cpp | ||
index f6856c17e16..f9162d82c07 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" | ||
|
||
@@ -109,8 +111,24 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation( | ||
return II; | ||
} | ||
|
||
+bool isAmazonLinux2023Host() { | ||
+ std::ifstream file("/etc/os-release"); | ||
+ std::string line; | ||
+ | ||
+ while (std::getline(file, line)) { | ||
+ if (line.substr(0, 12) == "PRETTY_NAME=") { | ||
+ if (line.substr(12) == "\"Amazon Linux 2023\"") { | ||
+ file.close(); | ||
+ return true; | ||
+ } | ||
+ } | ||
+ } | ||
+ return false; | ||
+ } | ||
+ | ||
std::string toolchains::GenericUnix::getDefaultLinker() const { | ||
- if (getTriple().isAndroid()) | ||
+ | ||
+ if (getTriple().isAndroid() || isAmazonLinux2023Host()) | ||
return "lld"; | ||
|
||
switch (getTriple().getArch()) { |
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,34 @@ | ||
diff --git a/lib/Driver/UnixToolChains.cpp b/lib/Driver/UnixToolChains.cpp | ||
index f6856c17e16..a34eecaefe1 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" | ||
|
||
@@ -110,6 +112,20 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation( | ||
} | ||
|
||
std::string toolchains::GenericUnix::getDefaultLinker() const { | ||
+ if (getTriple().isOSLinux()) { | ||
+ std::ifstream file("/etc/os-release"); | ||
+ std::string line; | ||
+ | ||
+ while (std::getline(file, line)) { | ||
+ if (line.substr(0, 12) == "PRETTY_NAME=") { | ||
+ if (line.substr(12) == "\"Amazon Linux 2023\"") { | ||
+ file.close(); | ||
+ return "lld"; | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
if (getTriple().isAndroid()) | ||
return "lld"; | ||
|
13 changes: 13 additions & 0 deletions
13
test-patches/amazonlinux-lld-swift-corelibs-foundation-main.patch
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,13 @@ | ||
diff --git a/lib/target.py b/lib/target.py | ||
index d1db48b1..44fd41da 100644 | ||
--- a/lib/target.py | ||
+++ b/lib/target.py | ||
@@ -342,7 +342,7 @@ class Target: | ||
if "linux" in triple: | ||
self.sdk = OSType.Linux | ||
self.dynamic_library_suffix = ".so" | ||
- self.linker = "gold" | ||
+ self.linker = "lld" | ||
elif "freebsd" in triple: | ||
self.sdk = OSType.FreeBSD | ||
self.dynamic_library_suffix = ".so" |