[clang] [RISCV] Merging RISCVToolChain and BareMetal toolchains (PR #118809)
Kito Cheng via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 6 04:55:47 PST 2024
================
@@ -519,9 +650,24 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
}
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
- options::OPT_r)) {
- CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+ bool WantCRTs =
+ !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+ const char *crtbegin, *crtend;
+ if (WantCRTs) {
+ if (!Args.hasArg(options::OPT_r))
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+ auto RuntimeLib = TC.GetRuntimeLibType(Args);
+ if (RuntimeLib == ToolChain::RLT_Libgcc) {
+ crtbegin = "crtbegin.o";
+ crtend = "crtend.o";
+ } else {
+ assert(RuntimeLib == ToolChain::RLT_CompilerRT);
+ crtbegin =
+ TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+ crtend = TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+ }
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtbegin)));
}
Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
----------------
kito-cheng wrote:
Add `options::OPT_u` here:
e.g.
```suggestion
Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group, options::OPT_u,
```
https://github.com/llvm/llvm-project/pull/118809
More information about the cfe-commits
mailing list