#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
using namespace clang::driver;
using namespace clang::driver::toolchains;
: Generic_ELF(D, Triple, Args) {
GCCInstallation.init(Triple, Args);
- if (getCPUName(D, Args, Triple).empty())
+ std::string CPU = getCPUName(D, Args, Triple);
+ if (CPU.empty())
D.Diag(diag::warn_drv_avr_mcu_not_specified);
// Only add default libraries if the user hasn't explicitly opted out.
return new tools::AVR::Linker(getTriple(), *this);
}
-std::string
-AVRToolChain::getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
- FileType Type = ToolChain::FT_Static) const {
- assert(Type == ToolChain::FT_Static && "AVR only supports static libraries");
- // Since AVR can never be a host environment, its compiler-rt library files
- // should always have ".a" suffix, even on windows.
- SmallString<32> File("/libclang_rt.");
- File += Component.str();
- File += ".a";
- // Return the default compiler-rt path appended with
- // "avr/libclang_rt.$COMPONENT.a".
- SmallString<256> Path(ToolChain::getCompilerRTPath());
- llvm::sys::path::append(Path, "avr");
- llvm::sys::path::append(Path, File.str());
- return std::string(Path.str());
-}
-
void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs, const ArgList &Args,
Args.AddAllArgs(CmdArgs, options::OPT_L);
getToolChain().AddFilePathLibArgs(Args, CmdArgs);
- // Currently we only support libgcc and compiler-rt.
- auto RtLib = TC.GetRuntimeLibType(Args);
- assert(
- (RtLib == ToolChain::RLT_Libgcc || RtLib == ToolChain::RLT_CompilerRT) &&
- "unknown runtime library");
-
// Only add default libraries if the user hasn't explicitly opted out.
bool LinkStdlib = false;
if (!Args.hasArg(options::OPT_nostdlib) &&
D.Diag(diag::warn_drv_avr_libc_not_found);
} else {
std::string SubPath = GetMCUSubPath(CPU);
- // Add path of avr-libc.
CmdArgs.push_back(
Args.MakeArgString(Twine("-L") + *AVRLibcRoot + "/lib/" + SubPath));
- if (RtLib == ToolChain::RLT_Libgcc)
- CmdArgs.push_back(Args.MakeArgString("-L" + TC.getGCCInstallPath() +
- "/" + SubPath));
+ CmdArgs.push_back(
+ Args.MakeArgString("-L" + TC.getGCCInstallPath() + "/" + SubPath));
LinkStdlib = true;
}
}
std::string CrtFileName = std::string("-l:crt") + CPU + std::string(".o");
CmdArgs.push_back(Args.MakeArgString(CrtFileName));
- // Link to libgcc.
- if (RtLib == ToolChain::RLT_Libgcc)
- CmdArgs.push_back("-lgcc");
-
- // Link to generic libraries of avr-libc.
+ CmdArgs.push_back("-lgcc");
CmdArgs.push_back("-lm");
CmdArgs.push_back("-lc");
// Add the link library specific to the MCU.
CmdArgs.push_back(Args.MakeArgString(std::string("-l") + CPU));
- // Add the relocatable inputs.
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
-
- // We directly use libclang_rt.builtins.a as input file, instead of using
- // '-lclang_rt.builtins'.
- if (RtLib == ToolChain::RLT_CompilerRT) {
- std::string RtLib =
- getToolChain().getCompilerRT(Args, "builtins", ToolChain::FT_Static);
- if (llvm::sys::fs::exists(RtLib))
- CmdArgs.push_back(Args.MakeArgString(RtLib));
- }
-
CmdArgs.push_back("--end-group");
// Add user specified linker script.