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

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

Issue 1208073002: [MIPS] Add support for direct-to-nacl in Clang (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-clang.git@master
Patch Set: Updated change. Created 5 years, 5 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/ToolChains.cpp ('k') | test/Driver/nacl-direct.c » ('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 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 CmdArgs.push_back("-mno-check-zero-division"); 1222 CmdArgs.push_back("-mno-check-zero-division");
1223 } 1223 }
1224 } 1224 }
1225 1225
1226 if (Arg *A = Args.getLastArg(options::OPT_G)) { 1226 if (Arg *A = Args.getLastArg(options::OPT_G)) {
1227 StringRef v = A->getValue(); 1227 StringRef v = A->getValue();
1228 CmdArgs.push_back("-mllvm"); 1228 CmdArgs.push_back("-mllvm");
1229 CmdArgs.push_back(Args.MakeArgString("-mips-ssection-threshold=" + v)); 1229 CmdArgs.push_back(Args.MakeArgString("-mips-ssection-threshold=" + v));
1230 A->claim(); 1230 A->claim();
1231 } 1231 }
1232
1233 // @LOCALMOD-BEGIN
1234 if (Triple.getOS() == llvm::Triple::NaCl) {
1235 CmdArgs.push_back("-mllvm");
1236 CmdArgs.push_back("-direct-to-nacl");
1237 }
1238 // @LOCALMOD-END
1232 } 1239 }
1233 1240
1234 /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting. 1241 /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting.
1235 static std::string getPPCTargetCPU(const ArgList &Args) { 1242 static std::string getPPCTargetCPU(const ArgList &Args) {
1236 if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { 1243 if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
1237 StringRef CPUName = A->getValue(); 1244 StringRef CPUName = A->getValue();
1238 1245
1239 if (CPUName == "native") { 1246 if (CPUName == "native") {
1240 std::string CPU = llvm::sys::getHostCPUName(); 1247 std::string CPU = llvm::sys::getHostCPUName();
1241 if (!CPU.empty() && CPU != "generic") 1248 if (!CPU.empty() && CPU != "generic")
(...skipping 6809 matching lines...) Expand 10 before | Expand all | Expand 10 after
8051 if (!IsStatic) 8058 if (!IsStatic)
8052 CmdArgs.push_back("--eh-frame-hdr"); 8059 CmdArgs.push_back("--eh-frame-hdr");
8053 8060
8054 CmdArgs.push_back("-m"); 8061 CmdArgs.push_back("-m");
8055 if (ToolChain.getArch() == llvm::Triple::x86) 8062 if (ToolChain.getArch() == llvm::Triple::x86)
8056 CmdArgs.push_back("elf_i386_nacl"); 8063 CmdArgs.push_back("elf_i386_nacl");
8057 else if (ToolChain.getArch() == llvm::Triple::arm) 8064 else if (ToolChain.getArch() == llvm::Triple::arm)
8058 CmdArgs.push_back("armelf_nacl"); 8065 CmdArgs.push_back("armelf_nacl");
8059 else if (ToolChain.getArch() == llvm::Triple::x86_64) 8066 else if (ToolChain.getArch() == llvm::Triple::x86_64)
8060 CmdArgs.push_back("elf_x86_64_nacl"); 8067 CmdArgs.push_back("elf_x86_64_nacl");
8068 else if (ToolChain.getArch() == llvm::Triple::mipsel)
8069 CmdArgs.push_back("mipselelf_nacl");
8061 else 8070 else
8062 D.Diag(diag::err_target_unsupported_arch) << ToolChain.getArchName() << 8071 D.Diag(diag::err_target_unsupported_arch) << ToolChain.getArchName() <<
8063 "Native Client"; 8072 "Native Client";
8064 8073
8065 8074
8066 if (IsStatic) 8075 if (IsStatic)
8067 CmdArgs.push_back("-static"); 8076 CmdArgs.push_back("-static");
8068 else if (Args.hasArg(options::OPT_shared)) 8077 else if (Args.hasArg(options::OPT_shared))
8069 CmdArgs.push_back("-shared"); 8078 CmdArgs.push_back("-shared");
8070 8079
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
8115 if (!Args.hasArg(options::OPT_nostdlib)) { 8124 if (!Args.hasArg(options::OPT_nostdlib)) {
8116 if (!Args.hasArg(options::OPT_nodefaultlibs)) { 8125 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
8117 // Always use groups, since it has no effect on dynamic libraries. 8126 // Always use groups, since it has no effect on dynamic libraries.
8118 CmdArgs.push_back("--start-group"); 8127 CmdArgs.push_back("--start-group");
8119 CmdArgs.push_back("-lc"); 8128 CmdArgs.push_back("-lc");
8120 // NaCl's libc++ currently requires libpthread, so just always include it 8129 // NaCl's libc++ currently requires libpthread, so just always include it
8121 // in the group for C++. 8130 // in the group for C++.
8122 if (Args.hasArg(options::OPT_pthread) || 8131 if (Args.hasArg(options::OPT_pthread) ||
8123 Args.hasArg(options::OPT_pthreads) || 8132 Args.hasArg(options::OPT_pthreads) ||
8124 D.CCCIsCXX()) { 8133 D.CCCIsCXX()) {
8134 // Gold, used by Mips, handles nested groups differently than ld, and
8135 // without '-lnacl' it prefers symbols from libpthread.a over libnacl.a,
8136 // which is not a desired behaviour here.
8137 // See https://sourceware.org/ml/binutils/2015-03/msg00034.html
8138 if (getToolChain().getArch() == llvm::Triple::mipsel)
8139 CmdArgs.push_back("-lnacl");
8140
8125 CmdArgs.push_back("-lpthread"); 8141 CmdArgs.push_back("-lpthread");
8126 } 8142 }
8127 8143
8128 CmdArgs.push_back("-lgcc"); 8144 CmdArgs.push_back("-lgcc");
8129 CmdArgs.push_back("--as-needed"); 8145 CmdArgs.push_back("--as-needed");
8130 if (IsStatic) 8146 if (IsStatic)
8131 CmdArgs.push_back("-lgcc_eh"); 8147 CmdArgs.push_back("-lgcc_eh");
8132 else 8148 else
8133 CmdArgs.push_back("-lgcc_s"); 8149 CmdArgs.push_back("-lgcc_s");
8134 CmdArgs.push_back("--no-as-needed"); 8150 CmdArgs.push_back("--no-as-needed");
8151
8152 // Mips needs to create and use pnacl_legacy library that contains
8153 // definitions from bitcode/pnaclmm.c and definitions for
8154 // __nacl_tp_tls_offset() and __nacl_tp_tdb_offset().
8155 if (getToolChain().getArch() == llvm::Triple::mipsel)
8156 CmdArgs.push_back("-lpnacl_legacy");
8157
8135 CmdArgs.push_back("--end-group"); 8158 CmdArgs.push_back("--end-group");
8136 } 8159 }
8137 8160
8138 if (!Args.hasArg(options::OPT_nostartfiles)) { 8161 if (!Args.hasArg(options::OPT_nostartfiles)) {
8139 const char *crtend; 8162 const char *crtend;
8140 if (Args.hasArg(options::OPT_shared)) 8163 if (Args.hasArg(options::OPT_shared))
8141 crtend = "crtendS.o"; 8164 crtend = "crtendS.o";
8142 else 8165 else
8143 crtend = "crtend.o"; 8166 crtend = "crtend.o";
8144 8167
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
8896 CmdArgs.push_back("-lmsvcrt"); 8919 CmdArgs.push_back("-lmsvcrt");
8897 AddRunTimeLibs(TC, D, CmdArgs, Args); 8920 AddRunTimeLibs(TC, D, CmdArgs, Args);
8898 } 8921 }
8899 } 8922 }
8900 8923
8901 const std::string Linker = TC.GetProgramPath("ld"); 8924 const std::string Linker = TC.GetProgramPath("ld");
8902 Exec = Args.MakeArgString(Linker); 8925 Exec = Args.MakeArgString(Linker);
8903 8926
8904 C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs)); 8927 C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
8905 } 8928 }
OLDNEW
« no previous file with comments | « lib/Driver/ToolChains.cpp ('k') | test/Driver/nacl-direct.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698