Skip to content

Commit e79e748

Browse files
committed
refactor amazon host detection to use bool
1 parent be69270 commit e79e748

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/Driver/UnixToolChains.cpp

+13-12
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,23 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation(
111111
return II;
112112
}
113113
// Amazon Linux 2023 requires lld as the default linker.
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";
114+
bool isAmazonLinux2023Host() {
115+
std::ifstream file("/etc/os-release");
116+
std::string line;
117+
118+
while (std::getline(file, line)) {
119+
if (line.substr(0, 12) == "PRETTY_NAME=") {
120+
if (line.substr(12) == "\"Amazon Linux 2023\"") {
121+
file.close();
122+
return true;
123+
}
124124
}
125125
}
126+
return false;
126127
}
127-
}
128128

129-
if (getTriple().isAndroid())
129+
std::string toolchains::GenericUnix::getDefaultLinker() const {
130+
if (getTriple().isAndroid() || isAmazonLinux2023Host())
130131
return "lld";
131132

132133
switch (getTriple().getArch()) {

0 commit comments

Comments
 (0)