[clang] [RISCV] Merging RISCVToolChain and BareMetal toolchains (PR #118809)

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 17:05:56 PST 2024


================
@@ -503,12 +624,22 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
-  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
+  if (!D.SysRoot.empty())
+    CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
+  Args.addAllArgs(CmdArgs, {options::OPT_u});
   CmdArgs.push_back("-Bstatic");
 
-  if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
-    CmdArgs.push_back("--no-relax");
+  if (TC.getTriple().isRISCV()) {
+    if (Args.hasArg(options::OPT_mno_relax))
+      CmdArgs.push_back("--no-relax");
+    if (TC.isUsingLD()) {
+      CmdArgs.push_back("-m");
+      CmdArgs.push_back(TC.getArch() == llvm::Triple::riscv64 ? "elf64lriscv"
----------------
topperc wrote:

`TC.getArch()` is already in a variable called `Arch`

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


More information about the cfe-commits mailing list