return cl::TokenizeWindowsCommandLine;
return cl::TokenizeGNUCommandLine;
}
- if (Triple(sys::getProcessTriple()).getOS() == Triple::Win32)
+ if (Triple(sys::getProcessTriple()).isOSWindows())
return cl::TokenizeWindowsCommandLine;
return cl::TokenizeGNUCommandLine;
}
RUN: llvm-readobj --sections %t.wasm | FileCheck %s
CHECK: InitialPages: 10
+RUN: not wasm-ld --rsp-quoting=foobar @%t.rsp 2>&1 | \
+RUN: FileCheck --check-prefix=INVRSP %s
+INVRSP: invalid response file quoting: foobar
+
+RUN: echo "blah\foo" > %t.rsp
+RUN: not wasm-ld --rsp-quoting=windows @%t.rsp 2>&1 | \
+RUN: FileCheck --check-prefix=WINRSP %s
+WINRSP: error: cannot open blah\foo:
+
RUN: echo "blah\foo" > %t.rsp
-RUN: not wasm-ld @%t.rsp 2>&1 | FileCheck --check-prefix=ESCAPE %s
-ESCAPE: error: cannot open blahfoo: {{[Nn]}}o such file or directory
+RUN: not wasm-ld --rsp-quoting=posix @%t.rsp 2>&1 | \
+RUN: FileCheck --check-prefix=POSRSP %s
+POSRSP: error: cannot open blahfoo:
}
}
+static cl::TokenizerCallback getQuotingStyle(opt::InputArgList &args) {
+ if (auto *arg = args.getLastArg(OPT_rsp_quoting)) {
+ StringRef s = arg->getValue();
+ if (s != "windows" && s != "posix")
+ error("invalid response file quoting: " + s);
+ if (s == "windows")
+ return cl::TokenizeWindowsCommandLine;
+ return cl::TokenizeGNUCommandLine;
+ }
+ if (Triple(sys::getProcessTriple()).isOSWindows())
+ return cl::TokenizeWindowsCommandLine;
+ return cl::TokenizeGNUCommandLine;
+}
+
// Find a file by concatenating given paths.
static Optional<std::string> findFile(StringRef path1, const Twine &path2) {
SmallString<128> s;
unsigned missingIndex;
unsigned missingCount;
- // Expand response files (arguments in the form of @<filename>)
- cl::ExpandResponseFiles(saver, cl::TokenizeGNUCommandLine, vec);
-
+ // We need to get the quoting style for response files before parsing all
+ // options so we parse here before and ignore all the options but
+ // --rsp-quoting.
opt::InputArgList args = this->ParseArgs(vec, missingIndex, missingCount);
+ // Expand response files (arguments in the form of @<filename>)
+ // and then parse the argument again.
+ cl::ExpandResponseFiles(saver, getQuotingStyle(args), vec);
+ args = this->ParseArgs(vec, missingIndex, missingCount);
+
handleColorDiagnostics(args);
for (auto *arg : args.filtered(OPT_UNKNOWN))
error("unknown argument: " + arg->getAsString(args));
defm reproduce: Eq<"reproduce", "Dump linker invocation and input files for debugging">;
+defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
+ MetaVarName<"[posix,windows]">;
+
def shared: F<"shared">, HelpText<"Build a shared object">;
def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;