Skip to content

Commit 3223f09

Browse files
committed
[CHERIoT] Restore pre-clang-21 behavior of using LLD as the default baremetal linker.
1 parent 6c5cd94 commit 3223f09

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
274274
}
275275
}
276276
}
277+
278+
if (Triple.getOS() == llvm::Triple::CheriotRTOS ||
279+
Args.getLastArgValue(options::OPT_mcpu_EQ) == "cheriot" ||
280+
Args.getLastArgValue(options::OPT_mabi_EQ) ==
281+
"cheriot" Args.getLastArgValue(options::OPT_mabi_EQ) ==
282+
"cheriot-baremetal")
283+
IsCheriot = true;
284+
else
285+
IsCheriot = false;
277286
}
278287

279288
static void

clang/lib/Driver/ToolChains/BareMetal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
5656
return UnwindTableLevel::None;
5757
}
5858

59+
const char *getDefaultLinker() const override {
60+
// XXX CHERIOT: Restore pre-clang21 behavior of defaulting to lld.
61+
if (IsCheriot)
62+
return "ld.lld";
63+
return "ld.lld";
64+
}
65+
5966
CXXStdlibType GetDefaultCXXStdlibType() const override;
6067

6168
RuntimeLibType GetDefaultRuntimeLibType() const override;
@@ -92,6 +99,8 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
9299
bool IsGCCInstallationValid;
93100

94101
SmallVector<std::string> MultilibMacroDefines;
102+
103+
bool IsCheriot;
95104
};
96105

97106
} // namespace toolchains

0 commit comments

Comments
 (0)