@@ -149,6 +149,20 @@ static void handleColorDiagnostics(opt::InputArgList &args) {
149
149
}
150
150
}
151
151
152
+ static cl::TokenizerCallback getQuotingStyle (opt::InputArgList &args) {
153
+ if (auto *arg = args.getLastArg (OPT_rsp_quoting)) {
154
+ StringRef s = arg->getValue ();
155
+ if (s != " windows" && s != " posix" )
156
+ error (" invalid response file quoting: " + s);
157
+ if (s == " windows" )
158
+ return cl::TokenizeWindowsCommandLine;
159
+ return cl::TokenizeGNUCommandLine;
160
+ }
161
+ if (Triple (sys::getProcessTriple ()).isOSWindows ())
162
+ return cl::TokenizeWindowsCommandLine;
163
+ return cl::TokenizeGNUCommandLine;
164
+ }
165
+
152
166
// Find a file by concatenating given paths.
153
167
static Optional<std::string> findFile (StringRef path1, const Twine &path2) {
154
168
SmallString<128 > s;
@@ -164,11 +178,16 @@ opt::InputArgList WasmOptTable::parse(ArrayRef<const char *> argv) {
164
178
unsigned missingIndex;
165
179
unsigned missingCount;
166
180
167
- // Expand response files (arguments in the form of @<filename>)
168
- cl::ExpandResponseFiles (saver, cl::TokenizeGNUCommandLine, vec);
169
-
181
+ // We need to get the quoting style for response files before parsing all
182
+ // options so we parse here before and ignore all the options but
183
+ // --rsp-quoting.
170
184
opt::InputArgList args = this ->ParseArgs (vec, missingIndex, missingCount);
171
185
186
+ // Expand response files (arguments in the form of @<filename>)
187
+ // and then parse the argument again.
188
+ cl::ExpandResponseFiles (saver, getQuotingStyle (args), vec);
189
+ args = this ->ParseArgs (vec, missingIndex, missingCount);
190
+
172
191
handleColorDiagnostics (args);
173
192
for (auto *arg : args.filtered (OPT_UNKNOWN))
174
193
error (" unknown argument: " + arg->getAsString (args));
0 commit comments