[llvm-branch-commits] [clang] [Driver] Change linker job in Baremetal toolchain object accomodate GCCInstallation.(2/3) (PR #121830)

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Mar 12 22:46:28 PDT 2025


================
@@ -331,6 +333,32 @@ BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const {
   return llvm::reverse(Default);
 }
 
+ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+    return ToolChain::CST_Libstdcxx;
+  return ToolChain::CST_Libcxx;
+}
+
+ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+    return ToolChain::RLT_Libgcc;
+  return ToolChain::RLT_CompilerRT;
+}
+
+ToolChain::UnwindLibType
+BareMetal::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
+  if (getTriple().isRISCV())
+    return ToolChain::UNW_None;
+
+  return ToolChain::GetUnwindLibType(Args);
+}
+
+const char *BareMetal::getDefaultLinker() const {
+  if (isUsingLD())
----------------
MaskRay wrote:

this ld/ld.lld selection feels very odd. Ideally we just stick with one `ld`. If a user prefers `ld.lld`, customize this preference in Clang configuration file.
The shared C++ code trying to appease some sets of users could easily end up with something with unprecdictable behavior, which offers worse user experience for the other set of users.

https://github.com/llvm/llvm-project/pull/121830


More information about the llvm-branch-commits mailing list