| OLD | NEW |
| 1 //===- subzero/src/IceBrowserCompileServer.cpp - Browser compile server ---===// | 1 //===- subzero/src/IceBrowserCompileServer.cpp - Browser compile server ---===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 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 /// \file | 10 /// \file |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 size_t QueryResult = | 46 size_t QueryResult = |
| 47 nacl_interface_query(NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1, | 47 nacl_interface_query(NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1, |
| 48 &gIRTFuncs, sizeof(gIRTFuncs)); | 48 &gIRTFuncs, sizeof(gIRTFuncs)); |
| 49 if (QueryResult != sizeof(gIRTFuncs)) | 49 if (QueryResult != sizeof(gIRTFuncs)) |
| 50 llvm::report_fatal_error("Failed to get translator compile IRT interface"); | 50 llvm::report_fatal_error("Failed to get translator compile IRT interface"); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Allow pnacl-sz arguments to be supplied externally, instead of coming from | 53 // Allow pnacl-sz arguments to be supplied externally, instead of coming from |
| 54 // the browser. This is meant to be used for debugging. | 54 // the browser. This is meant to be used for debugging. |
| 55 // | 55 // |
| 56 // NOTE: This functionality is only enabled in non-MINIMAL Subzero builds, for |
| 57 // security/safety reasons. |
| 58 // |
| 56 // If the SZARGFILE environment variable is set to a file name, arguments are | 59 // If the SZARGFILE environment variable is set to a file name, arguments are |
| 57 // read from that file, one argument per line. This requires setting 3 | 60 // read from that file, one argument per line. This requires setting 3 |
| 58 // environment variables before starting the browser: | 61 // environment variables before starting the browser: |
| 59 // | 62 // |
| 60 // NACL_ENV_PASSTHROUGH=NACL_DANGEROUS_ENABLE_FILE_ACCESS,NACLENV_SZARGFILE | 63 // NACL_ENV_PASSTHROUGH=NACL_DANGEROUS_ENABLE_FILE_ACCESS,NACLENV_SZARGFILE |
| 61 // NACL_DANGEROUS_ENABLE_FILE_ACCESS=1 | 64 // NACL_DANGEROUS_ENABLE_FILE_ACCESS=1 |
| 62 // NACLENV_SZARGFILE=/path/to/myargs.txt | 65 // NACLENV_SZARGFILE=/path/to/myargs.txt |
| 63 // | 66 // |
| 64 // In addition, Chrome needs to be launched with the "--no-sandbox" argument. | 67 // In addition, Chrome needs to be launched with the "--no-sandbox" argument. |
| 65 // | 68 // |
| 66 // If the SZARGLIST environment variable is set, arguments are extracted from | 69 // If the SZARGLIST environment variable is set, arguments are extracted from |
| 67 // that variable's value, separated by the '|' character (being careful to | 70 // that variable's value, separated by the '|' character (being careful to |
| 68 // escape/quote special shell characters). This requires setting 2 environment | 71 // escape/quote special shell characters). This requires setting 2 environment |
| 69 // variables before starting the browser: | 72 // variables before starting the browser: |
| 70 // | 73 // |
| 71 // NACL_ENV_PASSTHROUGH=NACLENV_SZARGLIST | 74 // NACL_ENV_PASSTHROUGH=NACLENV_SZARGLIST |
| 72 // NACLENV_SZARGLIST=arg | 75 // NACLENV_SZARGLIST=arg |
| 73 // | 76 // |
| 74 // This does not require the "--no-sandbox" argument, and is therefore much | 77 // This does not require the "--no-sandbox" argument, and is therefore much |
| 75 // safer, but does require restarting the browser to change the arguments. | 78 // safer, but does require restarting the browser to change the arguments. |
| 76 // | 79 // |
| 77 // If external arguments are supplied, the browser's NumThreads specification is | 80 // If external arguments are supplied, the browser's NumThreads specification is |
| 78 // ignored, to allow -threads to be specified as an external argument. Note | 81 // ignored, to allow -threads to be specified as an external argument. Note |
| 79 // that the browser normally supplies the "-O2" argument, so externally supplied | 82 // that the browser normally supplies the "-O2" argument, so externally supplied |
| 80 // arguments might want to provide an explicit -O argument. | 83 // arguments might want to provide an explicit -O argument. |
| 84 // |
| 85 // See Chrome's src/components/nacl/zygote/nacl_fork_delegate_linux.cc for the |
| 86 // NACL_ENV_PASSTHROUGH mechanism. |
| 87 // |
| 88 // See NaCl's src/trusted/service_runtime/env_cleanser.c for the NACLENV_ |
| 89 // mechanism. |
| 81 std::vector<std::string> getExternalArgs() { | 90 std::vector<std::string> getExternalArgs() { |
| 82 std::vector<std::string> ExternalArgs; | 91 std::vector<std::string> ExternalArgs; |
| 83 if (BuildDefs::minimal()) | 92 if (BuildDefs::minimal()) |
| 84 return ExternalArgs; | 93 return ExternalArgs; |
| 85 char ArgsFileVar[] = "SZARGFILE"; | 94 char ArgsFileVar[] = "SZARGFILE"; |
| 86 char ArgsListVar[] = "SZARGLIST"; | 95 char ArgsListVar[] = "SZARGLIST"; |
| 87 if (const char *ArgsFilename = getenv(ArgsFileVar)) { | 96 if (const char *ArgsFilename = getenv(ArgsFileVar)) { |
| 88 std::ifstream ArgsStream(ArgsFilename); | 97 std::ifstream ArgsStream(ArgsFilename); |
| 89 std::string Arg; | 98 std::string Arg; |
| 90 while (ArgsStream >> std::ws, std::getline(ArgsStream, Arg)) { | 99 while (ArgsStream >> std::ws, std::getline(ArgsStream, Arg)) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 llvm::report_fatal_error("no browser hookups"); | 330 llvm::report_fatal_error("no browser hookups"); |
| 322 } | 331 } |
| 323 | 332 |
| 324 ErrorCode &BrowserCompileServer::getErrorCode() { | 333 ErrorCode &BrowserCompileServer::getErrorCode() { |
| 325 llvm::report_fatal_error("no browser hookups"); | 334 llvm::report_fatal_error("no browser hookups"); |
| 326 } | 335 } |
| 327 | 336 |
| 328 } // end of namespace Ice | 337 } // end of namespace Ice |
| 329 | 338 |
| 330 #endif // PNACL_BROWSER_TRANSLATOR | 339 #endif // PNACL_BROWSER_TRANSLATOR |
| OLD | NEW |