Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: lib/Driver/Tools.cpp

Issue 887223008: Rebased localmods in clang to 223109. (Closed)
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Driver/Tools.h ('k') | lib/Frontend/InitHeaderSearch.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- Tools.cpp - Tools Implementations --------------------------------===// 1 //===--- Tools.cpp - Tools Implementations --------------------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 9
10 #include "Tools.h" 10 #include "Tools.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 case llvm::Triple::GNUEABIHF: 657 case llvm::Triple::GNUEABIHF:
658 FloatABI = "hard"; 658 FloatABI = "hard";
659 break; 659 break;
660 default: 660 default:
661 // FreeBSD defaults to soft float 661 // FreeBSD defaults to soft float
662 FloatABI = "soft"; 662 FloatABI = "soft";
663 break; 663 break;
664 } 664 }
665 break; 665 break;
666 666
667 case llvm::Triple::NaCl: // @LOCALMOD
668 FloatABI = "hard";
669 break;
670
667 default: 671 default:
668 switch(Triple.getEnvironment()) { 672 switch(Triple.getEnvironment()) {
669 case llvm::Triple::GNUEABIHF: 673 case llvm::Triple::GNUEABIHF:
670 FloatABI = "hard"; 674 FloatABI = "hard";
671 break; 675 break;
672 case llvm::Triple::GNUEABI: 676 case llvm::Triple::GNUEABI:
673 FloatABI = "softfp"; 677 FloatABI = "softfp";
674 break; 678 break;
675 case llvm::Triple::EABIHF: 679 case llvm::Triple::EABIHF:
676 FloatABI = "hard"; 680 FloatABI = "hard";
(...skipping 6902 matching lines...) Expand 10 before | Expand all | Expand 10 after
7579 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend))); 7583 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
7580 if (!isAndroid) 7584 if (!isAndroid)
7581 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o"))); 7585 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
7582 } 7586 }
7583 } 7587 }
7584 7588
7585 C.addCommand( 7589 C.addCommand(
7586 llvm::make_unique<Command>(JA, *this, ToolChain.Linker.c_str(), CmdArgs)); 7590 llvm::make_unique<Command>(JA, *this, ToolChain.Linker.c_str(), CmdArgs));
7587 } 7591 }
7588 7592
7593 // @LOCALMOD-BEGIN
7594 // ARM assembly (inline or standalone) can be written with a set of macros for
7595 // the various SFI requirements like register masking. The assembly tool inserts
7596 // the file containing the macros as an input into all the assembly jobs.
7597 void nacltools::AssembleARM::ConstructJob(Compilation &C, const JobAction &JA,
7598 const InputInfo &Output,
7599 const InputInfoList &Inputs,
7600 const ArgList &Args,
7601 const char *LinkingOutput) const {
7602 const toolchains::NaCl_TC& ToolChain =
7603 static_cast<const toolchains::NaCl_TC&>(getToolChain());
7604 InputInfo NaClMacros(ToolChain.GetNaClArmMacrosPath(), types::TY_PP_Asm,
7605 "nacl-arm-macros.s");
7606 InputInfoList NewInputs;
7607 NewInputs.push_back(NaClMacros);
7608 NewInputs.append(Inputs.begin(), Inputs.end());
7609 gnutools::Assemble::ConstructJob(C, JA, Output, NewInputs, Args,
7610 LinkingOutput);
7611 }
7612
7613
7614 // This is almost a duplicate of gnutools::link::ConstructJob with changes that
7615 // we use static by default, do not yet support sanitizers or LTO, and a few
7616 // others. Eventually we can probably migrate back to gnutools::link
7617 void nacltools::Link::ConstructJob(Compilation &C, const JobAction &JA,
7618 const InputInfo &Output,
7619 const InputInfoList &Inputs,
7620 const ArgList &Args,
7621 const char *LinkingOutput) const {
7622
7623 const toolchains::NaCl_TC& ToolChain =
7624 static_cast<const toolchains::NaCl_TC&>(getToolChain());
7625 const Driver &D = ToolChain.getDriver();
7626 const bool IsStatic =
7627 !Args.hasArg(options::OPT_dynamic) &&
7628 !Args.hasArg(options::OPT_shared);
7629
7630 ArgStringList CmdArgs;
7631
7632 // Silence warning for "clang -g foo.o -o foo"
7633 Args.ClaimAllArgs(options::OPT_g_Group);
7634 // and "clang -emit-llvm foo.o -o foo"
7635 Args.ClaimAllArgs(options::OPT_emit_llvm);
7636 // and for "clang -w foo.o -o foo". Other warning options are already
7637 // handled somewhere else.
7638 Args.ClaimAllArgs(options::OPT_w);
7639
7640 if (!D.SysRoot.empty())
7641 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
7642
7643 if (Args.hasArg(options::OPT_rdynamic))
7644 CmdArgs.push_back("-export-dynamic");
7645
7646 if (Args.hasArg(options::OPT_s))
7647 CmdArgs.push_back("-s");
7648
7649 // NaCl_TC doesn't have ExtraOpts like Linux; the only relevant flag from
7650 // there is --build-id, which we do want.
7651 CmdArgs.push_back("--build-id");
7652
7653 if (!IsStatic)
7654 CmdArgs.push_back("--eh-frame-hdr");
7655
7656 CmdArgs.push_back("-m");
7657 if (ToolChain.getArch() == llvm::Triple::x86)
7658 CmdArgs.push_back("elf_i386_nacl");
7659 else if (ToolChain.getArch() == llvm::Triple::arm)
7660 CmdArgs.push_back("armelf_nacl");
7661 else
7662 CmdArgs.push_back("elf_x86_64_nacl");
7663
7664 if (IsStatic)
7665 CmdArgs.push_back("-static");
7666 else if (Args.hasArg(options::OPT_shared))
7667 CmdArgs.push_back("-shared");
7668
7669 CmdArgs.push_back("-o");
7670 CmdArgs.push_back(Output.getFilename());
7671
7672 if (!Args.hasArg(options::OPT_nostdlib) &&
7673 !Args.hasArg(options::OPT_nostartfiles)) {
7674 if (!Args.hasArg(options::OPT_shared))
7675 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
7676 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
7677
7678 const char *crtbegin;
7679 if (IsStatic)
7680 crtbegin = "crtbeginT.o";
7681 else if (Args.hasArg(options::OPT_shared))
7682 crtbegin = "crtbeginS.o";
7683 else
7684 crtbegin = "crtbegin.o";
7685 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
7686 }
7687
7688 Args.AddAllArgs(CmdArgs, options::OPT_L);
7689 Args.AddAllArgs(CmdArgs, options::OPT_u);
7690
7691 const ToolChain::path_list Paths = ToolChain.getFilePaths();
7692
7693 for (const auto &Path : Paths)
7694 CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));
7695
7696 if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
7697 CmdArgs.push_back("--no-demangle");
7698
7699 AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
7700
7701 if (D.CCCIsCXX() &&
7702 !Args.hasArg(options::OPT_nostdlib) &&
7703 !Args.hasArg(options::OPT_nodefaultlibs)) {
7704 bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
7705 !IsStatic;
7706 if (OnlyLibstdcxxStatic)
7707 CmdArgs.push_back("-Bstatic");
7708 ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
7709 if (OnlyLibstdcxxStatic)
7710 CmdArgs.push_back("-Bdynamic");
7711 CmdArgs.push_back("-lm");
7712 }
7713
7714 if (!Args.hasArg(options::OPT_nostdlib)) {
7715 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
7716 // Always use groups, since it has no effect on dynamic libraries.
7717 CmdArgs.push_back("--start-group");
7718 CmdArgs.push_back("-lc");
7719 // libc++ and PPAPI programs always require libpthread, so just always
7720 // include it in the group.
7721 Args.ClaimAllArgs(options::OPT_pthread);
7722 Args.ClaimAllArgs(options::OPT_pthreads);
7723 CmdArgs.push_back("-lpthread");
7724
7725 CmdArgs.push_back("-lgcc");
7726 CmdArgs.push_back("--as-needed");
7727 if (IsStatic)
7728 CmdArgs.push_back("-lgcc_eh");
7729 else
7730 CmdArgs.push_back("-lgcc_s");
7731 CmdArgs.push_back("--no-as-needed");
7732 CmdArgs.push_back("--end-group");
7733 }
7734
7735 if (!Args.hasArg(options::OPT_nostartfiles)) {
7736 const char *crtend;
7737 if (Args.hasArg(options::OPT_shared))
7738 crtend = "crtendS.o";
7739 else
7740 crtend = "crtend.o";
7741
7742 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
7743 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
7744 }
7745 }
7746
7747 C.addCommand(llvm::make_unique<Command>(JA, *this, ToolChain.Linker.c_str(), C mdArgs));
7748 }
7749 // @LOCALMOD-END
7750
7589 void minix::Assemble::ConstructJob(Compilation &C, const JobAction &JA, 7751 void minix::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
7590 const InputInfo &Output, 7752 const InputInfo &Output,
7591 const InputInfoList &Inputs, 7753 const InputInfoList &Inputs,
7592 const ArgList &Args, 7754 const ArgList &Args,
7593 const char *LinkingOutput) const { 7755 const char *LinkingOutput) const {
7594 ArgStringList CmdArgs; 7756 ArgStringList CmdArgs;
7595 7757
7596 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler); 7758 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
7597 7759
7598 CmdArgs.push_back("-o"); 7760 CmdArgs.push_back("-o");
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
8334 AddRunTimeLibs(TC, D, CmdArgs, Args); 8496 AddRunTimeLibs(TC, D, CmdArgs, Args);
8335 } 8497 }
8336 } 8498 }
8337 8499
8338 const std::string Linker = TC.GetProgramPath("ld"); 8500 const std::string Linker = TC.GetProgramPath("ld");
8339 Exec = Args.MakeArgString(Linker); 8501 Exec = Args.MakeArgString(Linker);
8340 8502
8341 C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs)); 8503 C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
8342 } 8504 }
8343 8505
OLDNEW
« no previous file with comments | « lib/Driver/Tools.h ('k') | lib/Frontend/InitHeaderSearch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698