Commit 9c1d3869 by Jan Voung

Add argv[0] before parsing commandline flags.

The \0 delimited string array that the browser sends doesn't have the program name and the IRT only tokenizes that and forwards it along. We need argv[0] to make the llvm CL parser happy (used for -help message, etc). Alternatively, we could have the IRT fill in a program name so that the argv is a real argv. That will involve less copying since the argv will be the right size to begin with, but prevents each app from customizing its argv[0] =/ BUG= https://code.google.com/p/nativeclient/issues/detail?id=4091 TEST= manual for now (construct the sel_universal script to only pass the "--build-atts" flag and see it exits without being swallowed, or pass "-Ofoo" and see an error + exit) R=mtrofin@chromium.org, stichnot@chromium.org Review URL: https://codereview.chromium.org/1041843003
parent 28a1a366
......@@ -41,7 +41,7 @@ void getIRTInterfaces() {
}
char *onInitCallback(uint32_t NumThreads, int *ObjFileFDs,
size_t ObjFileFDCount, char **argv, size_t argc) {
size_t ObjFileFDCount, char **CLArgs, size_t CLArgsLen) {
if (ObjFileFDCount < 1) {
std::string Buffer;
llvm::raw_string_ostream StrBuf(Buffer);
......@@ -56,8 +56,17 @@ char *onInitCallback(uint32_t NumThreads, int *ObjFileFDs,
StrBuf << "Invalid FD given for onInitCallback " << ObjFileFD << "\n";
return strdup(StrBuf.str().c_str());
}
// NOTE: argv is owned by the caller, but we parse here before returning.
gCompileServer->getParsedFlags(NumThreads, argc, argv);
// CLArgs is almost an "argv", but is missing the argv[0] program name.
std::vector<char *> Argv;
char ProgramName[] = "pnacl-sz.nexe";
Argv.reserve(CLArgsLen + 1);
Argv.push_back(ProgramName);
for (size_t i = 0; i < CLArgsLen; ++i) {
Argv.push_back(CLArgs[i]);
}
// NOTE: strings pointed to by argv are owned by the caller, but we parse
// here before returning and don't store them.
gCompileServer->getParsedFlags(NumThreads, Argv.size(), Argv.data());
gCompileServer->startCompileThread(ObjFileFD);
return nullptr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment