File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -948,6 +948,10 @@ if(XCODE)
948
948
swift_common_xcode_cxx_config()
949
949
endif ()
950
950
951
+ # Check what linux distribution is being used.
952
+ # This can be used to determine the default linker to use.
953
+ cmake_host_system_information (RESULT DISTRO_NAME QUERY DISTRIB_PRETTY_NAME)
954
+
951
955
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
952
956
# our own defaults. This should only be possible in a unified (not stand alone)
953
957
# build environment.
@@ -959,6 +963,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQ
959
963
set (SWIFT_USE_LINKER_default "lld" )
960
964
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
961
965
set (SWIFT_USE_LINKER_default "" )
966
+ elseif (DISTRO_NAME STREQUAL "Amazon Linux 2023" )
967
+ set (SWIFT_USE_LINKER_default "lld" )
962
968
else ()
963
969
set (SWIFT_USE_LINKER_default "gold" )
964
970
endif ()
Original file line number Diff line number Diff line change 9
9
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
+ #include < iostream>
13
+ #include < fstream>
12
14
13
15
#include " ToolChains.h"
14
16
@@ -108,8 +110,22 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation(
108
110
109
111
return II;
110
112
}
111
-
113
+ // Amazon Linux 2023 requires lld as the default linker.
112
114
std::string toolchains::GenericUnix::getDefaultLinker () const {
115
+ if (getTriple ().isOSLinux ()) {
116
+ std::ifstream file (" /etc/os-release" );
117
+ std::string line;
118
+
119
+ while (std::getline (file, line)) {
120
+ if (line.substr (0 , 12 ) == " PRETTY_NAME=" ) {
121
+ if (line.substr (12 ) == " \" Amazon Linux 2023\" " ) {
122
+ file.close ();
123
+ return " lld" ;
124
+ }
125
+ }
126
+ }
127
+ }
128
+
113
129
if (getTriple ().isAndroid ())
114
130
return " lld" ;
115
131
You can’t perform that action at this time.
0 commit comments