17330f729Sjoerg //===--- NaCl.cpp - Native Client ToolChain Implementations -----*- C++ -*-===//
27330f729Sjoerg //
37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67330f729Sjoerg //
77330f729Sjoerg //===----------------------------------------------------------------------===//
87330f729Sjoerg
97330f729Sjoerg #include "NaCl.h"
107330f729Sjoerg #include "InputInfo.h"
117330f729Sjoerg #include "CommonArgs.h"
127330f729Sjoerg #include "clang/Driver/Compilation.h"
137330f729Sjoerg #include "clang/Driver/Driver.h"
147330f729Sjoerg #include "clang/Driver/DriverDiagnostic.h"
157330f729Sjoerg #include "clang/Driver/Options.h"
167330f729Sjoerg #include "llvm/Option/ArgList.h"
177330f729Sjoerg #include "llvm/Support/Path.h"
187330f729Sjoerg
197330f729Sjoerg using namespace clang::driver;
207330f729Sjoerg using namespace clang::driver::tools;
217330f729Sjoerg using namespace clang::driver::toolchains;
227330f729Sjoerg using namespace clang;
237330f729Sjoerg using namespace llvm::opt;
247330f729Sjoerg
257330f729Sjoerg // NaCl ARM assembly (inline or standalone) can be written with a set of macros
267330f729Sjoerg // for the various SFI requirements like register masking. The assembly tool
277330f729Sjoerg // inserts the file containing the macros as an input into all the assembly
287330f729Sjoerg // jobs.
ConstructJob(Compilation & C,const JobAction & JA,const InputInfo & Output,const InputInfoList & Inputs,const ArgList & Args,const char * LinkingOutput) const297330f729Sjoerg void nacltools::AssemblerARM::ConstructJob(Compilation &C, const JobAction &JA,
307330f729Sjoerg const InputInfo &Output,
317330f729Sjoerg const InputInfoList &Inputs,
327330f729Sjoerg const ArgList &Args,
337330f729Sjoerg const char *LinkingOutput) const {
347330f729Sjoerg const toolchains::NaClToolChain &ToolChain =
357330f729Sjoerg static_cast<const toolchains::NaClToolChain &>(getToolChain());
367330f729Sjoerg InputInfo NaClMacros(types::TY_PP_Asm, ToolChain.GetNaClArmMacrosPath(),
377330f729Sjoerg "nacl-arm-macros.s");
387330f729Sjoerg InputInfoList NewInputs;
397330f729Sjoerg NewInputs.push_back(NaClMacros);
407330f729Sjoerg NewInputs.append(Inputs.begin(), Inputs.end());
417330f729Sjoerg gnutools::Assembler::ConstructJob(C, JA, Output, NewInputs, Args,
427330f729Sjoerg LinkingOutput);
437330f729Sjoerg }
447330f729Sjoerg
457330f729Sjoerg // This is quite similar to gnutools::Linker::ConstructJob with changes that
467330f729Sjoerg // we use static by default, do not yet support sanitizers or LTO, and a few
477330f729Sjoerg // others. Eventually we can support more of that and hopefully migrate back
487330f729Sjoerg // to gnutools::Linker.
ConstructJob(Compilation & C,const JobAction & JA,const InputInfo & Output,const InputInfoList & Inputs,const ArgList & Args,const char * LinkingOutput) const497330f729Sjoerg void nacltools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
507330f729Sjoerg const InputInfo &Output,
517330f729Sjoerg const InputInfoList &Inputs,
527330f729Sjoerg const ArgList &Args,
537330f729Sjoerg const char *LinkingOutput) const {
547330f729Sjoerg
557330f729Sjoerg const toolchains::NaClToolChain &ToolChain =
567330f729Sjoerg static_cast<const toolchains::NaClToolChain &>(getToolChain());
577330f729Sjoerg const Driver &D = ToolChain.getDriver();
587330f729Sjoerg const llvm::Triple::ArchType Arch = ToolChain.getArch();
597330f729Sjoerg const bool IsStatic =
607330f729Sjoerg !Args.hasArg(options::OPT_dynamic) && !Args.hasArg(options::OPT_shared);
617330f729Sjoerg
627330f729Sjoerg ArgStringList CmdArgs;
637330f729Sjoerg
647330f729Sjoerg // Silence warning for "clang -g foo.o -o foo"
657330f729Sjoerg Args.ClaimAllArgs(options::OPT_g_Group);
667330f729Sjoerg // and "clang -emit-llvm foo.o -o foo"
677330f729Sjoerg Args.ClaimAllArgs(options::OPT_emit_llvm);
687330f729Sjoerg // and for "clang -w foo.o -o foo". Other warning options are already
697330f729Sjoerg // handled somewhere else.
707330f729Sjoerg Args.ClaimAllArgs(options::OPT_w);
717330f729Sjoerg
727330f729Sjoerg if (!D.SysRoot.empty())
737330f729Sjoerg CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
747330f729Sjoerg
757330f729Sjoerg if (Args.hasArg(options::OPT_rdynamic))
767330f729Sjoerg CmdArgs.push_back("-export-dynamic");
777330f729Sjoerg
787330f729Sjoerg if (Args.hasArg(options::OPT_s))
797330f729Sjoerg CmdArgs.push_back("-s");
807330f729Sjoerg
817330f729Sjoerg // NaClToolChain doesn't have ExtraOpts like Linux; the only relevant flag
827330f729Sjoerg // from there is --build-id, which we do want.
837330f729Sjoerg CmdArgs.push_back("--build-id");
847330f729Sjoerg
857330f729Sjoerg if (!IsStatic)
867330f729Sjoerg CmdArgs.push_back("--eh-frame-hdr");
877330f729Sjoerg
887330f729Sjoerg CmdArgs.push_back("-m");
897330f729Sjoerg if (Arch == llvm::Triple::x86)
907330f729Sjoerg CmdArgs.push_back("elf_i386_nacl");
917330f729Sjoerg else if (Arch == llvm::Triple::arm)
927330f729Sjoerg CmdArgs.push_back("armelf_nacl");
937330f729Sjoerg else if (Arch == llvm::Triple::x86_64)
947330f729Sjoerg CmdArgs.push_back("elf_x86_64_nacl");
957330f729Sjoerg else if (Arch == llvm::Triple::mipsel)
967330f729Sjoerg CmdArgs.push_back("mipselelf_nacl");
977330f729Sjoerg else
987330f729Sjoerg D.Diag(diag::err_target_unsupported_arch) << ToolChain.getArchName()
997330f729Sjoerg << "Native Client";
1007330f729Sjoerg
1017330f729Sjoerg if (IsStatic)
1027330f729Sjoerg CmdArgs.push_back("-static");
1037330f729Sjoerg else if (Args.hasArg(options::OPT_shared))
1047330f729Sjoerg CmdArgs.push_back("-shared");
1057330f729Sjoerg
1067330f729Sjoerg CmdArgs.push_back("-o");
1077330f729Sjoerg CmdArgs.push_back(Output.getFilename());
1087330f729Sjoerg if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
1097330f729Sjoerg if (!Args.hasArg(options::OPT_shared))
1107330f729Sjoerg CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
1117330f729Sjoerg CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
1127330f729Sjoerg
1137330f729Sjoerg const char *crtbegin;
1147330f729Sjoerg if (IsStatic)
1157330f729Sjoerg crtbegin = "crtbeginT.o";
1167330f729Sjoerg else if (Args.hasArg(options::OPT_shared))
1177330f729Sjoerg crtbegin = "crtbeginS.o";
1187330f729Sjoerg else
1197330f729Sjoerg crtbegin = "crtbegin.o";
1207330f729Sjoerg CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
1217330f729Sjoerg }
1227330f729Sjoerg
1237330f729Sjoerg Args.AddAllArgs(CmdArgs, options::OPT_L);
1247330f729Sjoerg Args.AddAllArgs(CmdArgs, options::OPT_u);
1257330f729Sjoerg
1267330f729Sjoerg ToolChain.AddFilePathLibArgs(Args, CmdArgs);
1277330f729Sjoerg
1287330f729Sjoerg if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
1297330f729Sjoerg CmdArgs.push_back("--no-demangle");
1307330f729Sjoerg
1317330f729Sjoerg AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
1327330f729Sjoerg
1337330f729Sjoerg if (D.CCCIsCXX() &&
1347330f729Sjoerg !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
1357330f729Sjoerg if (ToolChain.ShouldLinkCXXStdlib(Args)) {
1367330f729Sjoerg bool OnlyLibstdcxxStatic =
1377330f729Sjoerg Args.hasArg(options::OPT_static_libstdcxx) && !IsStatic;
1387330f729Sjoerg if (OnlyLibstdcxxStatic)
1397330f729Sjoerg CmdArgs.push_back("-Bstatic");
1407330f729Sjoerg ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
1417330f729Sjoerg if (OnlyLibstdcxxStatic)
1427330f729Sjoerg CmdArgs.push_back("-Bdynamic");
1437330f729Sjoerg }
1447330f729Sjoerg CmdArgs.push_back("-lm");
1457330f729Sjoerg }
1467330f729Sjoerg
1477330f729Sjoerg if (!Args.hasArg(options::OPT_nostdlib)) {
1487330f729Sjoerg if (!Args.hasArg(options::OPT_nodefaultlibs)) {
1497330f729Sjoerg // Always use groups, since it has no effect on dynamic libraries.
1507330f729Sjoerg CmdArgs.push_back("--start-group");
1517330f729Sjoerg CmdArgs.push_back("-lc");
1527330f729Sjoerg // NaCl's libc++ currently requires libpthread, so just always include it
1537330f729Sjoerg // in the group for C++.
1547330f729Sjoerg if (Args.hasArg(options::OPT_pthread) ||
1557330f729Sjoerg Args.hasArg(options::OPT_pthreads) || D.CCCIsCXX()) {
1567330f729Sjoerg // Gold, used by Mips, handles nested groups differently than ld, and
1577330f729Sjoerg // without '-lnacl' it prefers symbols from libpthread.a over libnacl.a,
1587330f729Sjoerg // which is not a desired behaviour here.
1597330f729Sjoerg // See https://sourceware.org/ml/binutils/2015-03/msg00034.html
1607330f729Sjoerg if (getToolChain().getArch() == llvm::Triple::mipsel)
1617330f729Sjoerg CmdArgs.push_back("-lnacl");
1627330f729Sjoerg
1637330f729Sjoerg CmdArgs.push_back("-lpthread");
1647330f729Sjoerg }
1657330f729Sjoerg
1667330f729Sjoerg CmdArgs.push_back("-lgcc");
1677330f729Sjoerg CmdArgs.push_back("--as-needed");
1687330f729Sjoerg if (IsStatic)
1697330f729Sjoerg CmdArgs.push_back("-lgcc_eh");
1707330f729Sjoerg else
1717330f729Sjoerg CmdArgs.push_back("-lgcc_s");
1727330f729Sjoerg CmdArgs.push_back("--no-as-needed");
1737330f729Sjoerg
1747330f729Sjoerg // Mips needs to create and use pnacl_legacy library that contains
1757330f729Sjoerg // definitions from bitcode/pnaclmm.c and definitions for
1767330f729Sjoerg // __nacl_tp_tls_offset() and __nacl_tp_tdb_offset().
1777330f729Sjoerg if (getToolChain().getArch() == llvm::Triple::mipsel)
1787330f729Sjoerg CmdArgs.push_back("-lpnacl_legacy");
1797330f729Sjoerg
1807330f729Sjoerg CmdArgs.push_back("--end-group");
1817330f729Sjoerg }
1827330f729Sjoerg
1837330f729Sjoerg if (!Args.hasArg(options::OPT_nostartfiles)) {
1847330f729Sjoerg const char *crtend;
1857330f729Sjoerg if (Args.hasArg(options::OPT_shared))
1867330f729Sjoerg crtend = "crtendS.o";
1877330f729Sjoerg else
1887330f729Sjoerg crtend = "crtend.o";
1897330f729Sjoerg
1907330f729Sjoerg CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
1917330f729Sjoerg CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
1927330f729Sjoerg }
1937330f729Sjoerg }
1947330f729Sjoerg
1957330f729Sjoerg const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
196*e038c9c4Sjoerg C.addCommand(std::make_unique<Command>(JA, *this,
197*e038c9c4Sjoerg ResponseFileSupport::AtFileCurCP(),
198*e038c9c4Sjoerg Exec, CmdArgs, Inputs, Output));
1997330f729Sjoerg }
2007330f729Sjoerg
2017330f729Sjoerg /// NaCl Toolchain
NaClToolChain(const Driver & D,const llvm::Triple & Triple,const ArgList & Args)2027330f729Sjoerg NaClToolChain::NaClToolChain(const Driver &D, const llvm::Triple &Triple,
2037330f729Sjoerg const ArgList &Args)
2047330f729Sjoerg : Generic_ELF(D, Triple, Args) {
2057330f729Sjoerg
2067330f729Sjoerg // Remove paths added by Generic_GCC. NaCl Toolchain cannot use the
2077330f729Sjoerg // default paths, and must instead only use the paths provided
2087330f729Sjoerg // with this toolchain based on architecture.
2097330f729Sjoerg path_list &file_paths = getFilePaths();
2107330f729Sjoerg path_list &prog_paths = getProgramPaths();
2117330f729Sjoerg
2127330f729Sjoerg file_paths.clear();
2137330f729Sjoerg prog_paths.clear();
2147330f729Sjoerg
2157330f729Sjoerg // Path for library files (libc.a, ...)
2167330f729Sjoerg std::string FilePath(getDriver().Dir + "/../");
2177330f729Sjoerg
2187330f729Sjoerg // Path for tools (clang, ld, etc..)
2197330f729Sjoerg std::string ProgPath(getDriver().Dir + "/../");
2207330f729Sjoerg
2217330f729Sjoerg // Path for toolchain libraries (libgcc.a, ...)
2227330f729Sjoerg std::string ToolPath(getDriver().ResourceDir + "/lib/");
2237330f729Sjoerg
2247330f729Sjoerg switch (Triple.getArch()) {
2257330f729Sjoerg case llvm::Triple::x86:
2267330f729Sjoerg file_paths.push_back(FilePath + "x86_64-nacl/lib32");
2277330f729Sjoerg file_paths.push_back(FilePath + "i686-nacl/usr/lib");
2287330f729Sjoerg prog_paths.push_back(ProgPath + "x86_64-nacl/bin");
2297330f729Sjoerg file_paths.push_back(ToolPath + "i686-nacl");
2307330f729Sjoerg break;
2317330f729Sjoerg case llvm::Triple::x86_64:
2327330f729Sjoerg file_paths.push_back(FilePath + "x86_64-nacl/lib");
2337330f729Sjoerg file_paths.push_back(FilePath + "x86_64-nacl/usr/lib");
2347330f729Sjoerg prog_paths.push_back(ProgPath + "x86_64-nacl/bin");
2357330f729Sjoerg file_paths.push_back(ToolPath + "x86_64-nacl");
2367330f729Sjoerg break;
2377330f729Sjoerg case llvm::Triple::arm:
2387330f729Sjoerg file_paths.push_back(FilePath + "arm-nacl/lib");
2397330f729Sjoerg file_paths.push_back(FilePath + "arm-nacl/usr/lib");
2407330f729Sjoerg prog_paths.push_back(ProgPath + "arm-nacl/bin");
2417330f729Sjoerg file_paths.push_back(ToolPath + "arm-nacl");
2427330f729Sjoerg break;
2437330f729Sjoerg case llvm::Triple::mipsel:
2447330f729Sjoerg file_paths.push_back(FilePath + "mipsel-nacl/lib");
2457330f729Sjoerg file_paths.push_back(FilePath + "mipsel-nacl/usr/lib");
2467330f729Sjoerg prog_paths.push_back(ProgPath + "bin");
2477330f729Sjoerg file_paths.push_back(ToolPath + "mipsel-nacl");
2487330f729Sjoerg break;
2497330f729Sjoerg default:
2507330f729Sjoerg break;
2517330f729Sjoerg }
2527330f729Sjoerg
2537330f729Sjoerg NaClArmMacrosPath = GetFilePath("nacl-arm-macros.s");
2547330f729Sjoerg }
2557330f729Sjoerg
AddClangSystemIncludeArgs(const ArgList & DriverArgs,ArgStringList & CC1Args) const2567330f729Sjoerg void NaClToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
2577330f729Sjoerg ArgStringList &CC1Args) const {
2587330f729Sjoerg const Driver &D = getDriver();
2597330f729Sjoerg if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
2607330f729Sjoerg return;
2617330f729Sjoerg
2627330f729Sjoerg if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
2637330f729Sjoerg SmallString<128> P(D.ResourceDir);
2647330f729Sjoerg llvm::sys::path::append(P, "include");
2657330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
2667330f729Sjoerg }
2677330f729Sjoerg
2687330f729Sjoerg if (DriverArgs.hasArg(options::OPT_nostdlibinc))
2697330f729Sjoerg return;
2707330f729Sjoerg
2717330f729Sjoerg SmallString<128> P(D.Dir + "/../");
2727330f729Sjoerg switch (getTriple().getArch()) {
2737330f729Sjoerg case llvm::Triple::x86:
2747330f729Sjoerg // x86 is special because multilib style uses x86_64-nacl/include for libc
2757330f729Sjoerg // headers but the SDK wants i686-nacl/usr/include. The other architectures
2767330f729Sjoerg // have the same substring.
2777330f729Sjoerg llvm::sys::path::append(P, "i686-nacl/usr/include");
2787330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
2797330f729Sjoerg llvm::sys::path::remove_filename(P);
2807330f729Sjoerg llvm::sys::path::remove_filename(P);
2817330f729Sjoerg llvm::sys::path::remove_filename(P);
2827330f729Sjoerg llvm::sys::path::append(P, "x86_64-nacl/include");
2837330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
2847330f729Sjoerg return;
2857330f729Sjoerg case llvm::Triple::arm:
2867330f729Sjoerg llvm::sys::path::append(P, "arm-nacl/usr/include");
2877330f729Sjoerg break;
2887330f729Sjoerg case llvm::Triple::x86_64:
2897330f729Sjoerg llvm::sys::path::append(P, "x86_64-nacl/usr/include");
2907330f729Sjoerg break;
2917330f729Sjoerg case llvm::Triple::mipsel:
2927330f729Sjoerg llvm::sys::path::append(P, "mipsel-nacl/usr/include");
2937330f729Sjoerg break;
2947330f729Sjoerg default:
2957330f729Sjoerg return;
2967330f729Sjoerg }
2977330f729Sjoerg
2987330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
2997330f729Sjoerg llvm::sys::path::remove_filename(P);
3007330f729Sjoerg llvm::sys::path::remove_filename(P);
3017330f729Sjoerg llvm::sys::path::append(P, "include");
3027330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
3037330f729Sjoerg }
3047330f729Sjoerg
AddCXXStdlibLibArgs(const ArgList & Args,ArgStringList & CmdArgs) const3057330f729Sjoerg void NaClToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
3067330f729Sjoerg ArgStringList &CmdArgs) const {
3077330f729Sjoerg // Check for -stdlib= flags. We only support libc++ but this consumes the arg
3087330f729Sjoerg // if the value is libc++, and emits an error for other values.
3097330f729Sjoerg GetCXXStdlibType(Args);
3107330f729Sjoerg CmdArgs.push_back("-lc++");
3117330f729Sjoerg }
3127330f729Sjoerg
addLibCxxIncludePaths(const llvm::opt::ArgList & DriverArgs,llvm::opt::ArgStringList & CC1Args) const3137330f729Sjoerg void NaClToolChain::addLibCxxIncludePaths(
3147330f729Sjoerg const llvm::opt::ArgList &DriverArgs,
3157330f729Sjoerg llvm::opt::ArgStringList &CC1Args) const {
3167330f729Sjoerg const Driver &D = getDriver();
3177330f729Sjoerg
3187330f729Sjoerg SmallString<128> P(D.Dir + "/../");
3197330f729Sjoerg switch (getTriple().getArch()) {
3207330f729Sjoerg default:
3217330f729Sjoerg break;
3227330f729Sjoerg case llvm::Triple::arm:
3237330f729Sjoerg llvm::sys::path::append(P, "arm-nacl/include/c++/v1");
3247330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
3257330f729Sjoerg break;
3267330f729Sjoerg case llvm::Triple::x86:
3277330f729Sjoerg llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
3287330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
3297330f729Sjoerg break;
3307330f729Sjoerg case llvm::Triple::x86_64:
3317330f729Sjoerg llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
3327330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
3337330f729Sjoerg break;
3347330f729Sjoerg case llvm::Triple::mipsel:
3357330f729Sjoerg llvm::sys::path::append(P, "mipsel-nacl/include/c++/v1");
3367330f729Sjoerg addSystemInclude(DriverArgs, CC1Args, P.str());
3377330f729Sjoerg break;
3387330f729Sjoerg }
3397330f729Sjoerg }
3407330f729Sjoerg
3417330f729Sjoerg ToolChain::CXXStdlibType
GetCXXStdlibType(const ArgList & Args) const3427330f729Sjoerg NaClToolChain::GetCXXStdlibType(const ArgList &Args) const {
3437330f729Sjoerg if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
3447330f729Sjoerg StringRef Value = A->getValue();
3457330f729Sjoerg if (Value == "libc++")
3467330f729Sjoerg return ToolChain::CST_Libcxx;
3477330f729Sjoerg getDriver().Diag(clang::diag::err_drv_invalid_stdlib_name)
3487330f729Sjoerg << A->getAsString(Args);
3497330f729Sjoerg }
3507330f729Sjoerg
3517330f729Sjoerg return ToolChain::CST_Libcxx;
3527330f729Sjoerg }
3537330f729Sjoerg
3547330f729Sjoerg std::string
ComputeEffectiveClangTriple(const ArgList & Args,types::ID InputType) const3557330f729Sjoerg NaClToolChain::ComputeEffectiveClangTriple(const ArgList &Args,
3567330f729Sjoerg types::ID InputType) const {
3577330f729Sjoerg llvm::Triple TheTriple(ComputeLLVMTriple(Args, InputType));
3587330f729Sjoerg if (TheTriple.getArch() == llvm::Triple::arm &&
3597330f729Sjoerg TheTriple.getEnvironment() == llvm::Triple::UnknownEnvironment)
3607330f729Sjoerg TheTriple.setEnvironment(llvm::Triple::GNUEABIHF);
3617330f729Sjoerg return TheTriple.getTriple();
3627330f729Sjoerg }
3637330f729Sjoerg
buildLinker() const3647330f729Sjoerg Tool *NaClToolChain::buildLinker() const {
3657330f729Sjoerg return new tools::nacltools::Linker(*this);
3667330f729Sjoerg }
3677330f729Sjoerg
buildAssembler() const3687330f729Sjoerg Tool *NaClToolChain::buildAssembler() const {
3697330f729Sjoerg if (getTriple().getArch() == llvm::Triple::arm)
3707330f729Sjoerg return new tools::nacltools::AssemblerARM(*this);
3717330f729Sjoerg return new tools::gnutools::Assembler(*this);
3727330f729Sjoerg }
373