Skip to content

Commit eed76b4

Browse files
committed
Handle --driver-mode= when using new driver
Previously the driver mode was always set based on the executable name, ignoring any manually passed flag, now this flag is preferred if it exists. Fixes #60600
1 parent 804e3f0 commit eed76b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/DriverTool/driver.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static int run_driver(StringRef ExecName,
193193
bool isRepl = false;
194194

195195
// Handle integrated tools.
196+
StringRef DriverModeArg;
196197
if (argv.size() > 1) {
197198
StringRef FirstArg(argv[1]);
198199

@@ -219,6 +220,8 @@ static int run_driver(StringRef ExecName,
219220
if (FirstArg == "repl") {
220221
isRepl = true;
221222
argv = argv.drop_front();
223+
} else if (FirstArg.startswith("--driver-mode=")) {
224+
DriverModeArg = FirstArg;
222225
}
223226
}
224227

@@ -239,7 +242,9 @@ static int run_driver(StringRef ExecName,
239242
std::vector<const char *> subCommandArgs;
240243
// Rewrite the program argument.
241244
subCommandArgs.push_back(NewDriverPath.c_str());
242-
if (ExecName == "swiftc") {
245+
if (!DriverModeArg.empty()) {
246+
subCommandArgs.push_back(DriverModeArg.data());
247+
} else if (ExecName == "swiftc") {
243248
subCommandArgs.push_back("--driver-mode=swiftc");
244249
} else {
245250
assert(ExecName == "swift");

0 commit comments

Comments
 (0)