Index: lib/Driver/Tools.cpp |
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp |
index fb8e8721e37d74bc7603a398163221f689721fb9..567fd8cf92b2f83afb05454f749646ee28a8f3ca 100644 |
--- a/lib/Driver/Tools.cpp |
+++ b/lib/Driver/Tools.cpp |
@@ -1229,6 +1229,13 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, |
CmdArgs.push_back(Args.MakeArgString("-mips-ssection-threshold=" + v)); |
A->claim(); |
} |
+ |
+ // @LOCALMOD-BEGIN |
+ if (Triple.getOS() == llvm::Triple::NaCl) { |
+ CmdArgs.push_back("-mllvm"); |
+ CmdArgs.push_back("-direct-to-nacl"); |
+ } |
+ // @LOCALMOD-END |
} |
/// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting. |
@@ -8058,6 +8065,8 @@ void nacltools::Link::ConstructJob(Compilation &C, const JobAction &JA, |
CmdArgs.push_back("armelf_nacl"); |
else if (ToolChain.getArch() == llvm::Triple::x86_64) |
CmdArgs.push_back("elf_x86_64_nacl"); |
+ else if (ToolChain.getArch() == llvm::Triple::mipsel) |
+ CmdArgs.push_back("mipselelf_nacl"); |
else |
D.Diag(diag::err_target_unsupported_arch) << ToolChain.getArchName() << |
"Native Client"; |
@@ -8122,6 +8131,13 @@ void nacltools::Link::ConstructJob(Compilation &C, const JobAction &JA, |
if (Args.hasArg(options::OPT_pthread) || |
Args.hasArg(options::OPT_pthreads) || |
D.CCCIsCXX()) { |
+ // Gold, used by Mips, handles nested groups differently than ld, and |
+ // without '-lnacl' it prefers symbols from libpthread.a over libnacl.a, |
+ // which is not a desired behaviour here. |
+ // See https://sourceware.org/ml/binutils/2015-03/msg00034.html |
+ if (getToolChain().getArch() == llvm::Triple::mipsel) |
+ CmdArgs.push_back("-lnacl"); |
+ |
CmdArgs.push_back("-lpthread"); |
} |
@@ -8132,6 +8148,13 @@ void nacltools::Link::ConstructJob(Compilation &C, const JobAction &JA, |
else |
CmdArgs.push_back("-lgcc_s"); |
CmdArgs.push_back("--no-as-needed"); |
+ |
+ // Mips needs to create and use pnacl_legacy library that contains |
+ // definitions from bitcode/pnaclmm.c and definitions for |
+ // __nacl_tp_tls_offset() and __nacl_tp_tdb_offset(). |
+ if (getToolChain().getArch() == llvm::Triple::mipsel) |
+ CmdArgs.push_back("-lpnacl_legacy"); |
+ |
CmdArgs.push_back("--end-group"); |
} |