diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Driver/ToolChains/RISCVToolchain.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Driver/ToolChains/RISCVToolchain.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/RISCVToolchain.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/RISCVToolchain.cpp index cc912d94cb92..0dc12c7a84b5 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/RISCVToolchain.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/RISCVToolchain.cpp @@ -31,6 +31,21 @@ static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs, addPathIfExists(D, InstallPath + Path, Paths); } +// This function tests whether a gcc installation is present either +// through gcc-toolchain argument or in the same prefix where clang +// is installed. This helps decide whether to instantiate this toolchain +// or Baremetal toolchain. +bool RISCVToolChain::hasGCCToolchain(const Driver &D, + const llvm::opt::ArgList &Args) { + if (Args.getLastArg(options::OPT_gcc_toolchain)) + return true; + + SmallString<128> GCCDir; + llvm::sys::path::append(GCCDir, D.Dir, "..", D.getTargetTriple(), + "lib/crt0.o"); + return llvm::sys::fs::exists(GCCDir); +} + /// RISCV Toolchain RISCVToolChain::RISCVToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) @@ -191,8 +206,8 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - C.addCommand( - std::make_unique<Command>(JA, *this, ResponseFileSupport::AtFileCurCP(), - Args.MakeArgString(Linker), CmdArgs, Inputs)); + C.addCommand(std::make_unique<Command>( + JA, *this, ResponseFileSupport::AtFileCurCP(), Args.MakeArgString(Linker), + CmdArgs, Inputs, Output)); } // RISCV tools end. |