Skip to content

Commit e613b4b

Browse files
committed
Add symlinks for the legacy driver invocation (for emergency fallback invoked from 'swift-driver')
1 parent 905c840 commit e613b4b

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

lib/Driver/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ void Driver::parseDriverKind(ArrayRef<const char *> Args) {
9999
llvm::StringSwitch<llvm::Optional<DriverKind>>(DriverName)
100100
.Case("swift", DriverKind::Interactive)
101101
.Case("swiftc", DriverKind::Batch)
102+
.Case("swift-legacy-driver", DriverKind::Interactive)
103+
.Case("swiftc-legacy-driver", DriverKind::Batch)
102104
.Case("sil-opt", DriverKind::SILOpt)
103105
.Case("sil-func-extractor", DriverKind::SILFuncExtractor)
104106
.Case("sil-nm", DriverKind::SILNM)

lib/DriverTool/driver.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,15 @@ static bool shouldRunAsSubcommand(StringRef ExecName,
167167
static bool shouldDisallowNewDriver(DiagnosticEngine &diags,
168168
StringRef ExecName,
169169
const ArrayRef<const char *> argv) {
170+
// We are expected to use the legacy driver to `exec` an overload
171+
// for testing purposes.
172+
if (llvm::sys::Process::GetEnv("SWIFT_OVERLOAD_DRIVER").has_value()) {
173+
return false;
174+
}
170175
// We are not invoking the driver, so don't forward.
171-
if (ExecName != "swift" && ExecName != "swiftc") {
176+
if (ExecName != "swift" && ExecName != "swiftc" &&
177+
ExecName != "swift-legacy-driver" &&
178+
ExecName != "swiftc-legacy-driver") {
172179
return true;
173180
}
174181
StringRef disableArg = "-disallow-use-new-driver";
@@ -193,7 +200,7 @@ static bool shouldDisallowNewDriver(DiagnosticEngine &diags,
193200

194201
static bool appendSwiftDriverName(SmallString<256> &buffer) {
195202
assert(llvm::sys::fs::exists(buffer));
196-
if (auto driverNameOp = llvm::sys::Process::GetEnv("SWIFT_USE_NEW_DRIVER")) {
203+
if (auto driverNameOp = llvm::sys::Process::GetEnv("SWIFT_OVERLOAD_DRIVER")) {
197204
llvm::sys::path::append(buffer, *driverNameOp);
198205
return true;
199206
}

test/Driver/LegacyDriver/legacy-driver-propagates-response-file-to-new-driver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// REQUIRES: shell
77
// RUN: %{python} -c 'for i in range(500001): print("-DTEST5_" + str(i))' > %t.resp
88
// RUN: cp %S/Inputs/print-args.sh %swift-bin-dir/legacy-driver-propagates-response-file.sh
9-
// RUN: env SWIFT_USE_NEW_DRIVER=legacy-driver-propagates-response-file.sh %swiftc_driver_plain %s @%t.resp | %FileCheck %s
9+
// RUN: env SWIFT_OVERLOAD_DRIVER=legacy-driver-propagates-response-file.sh %swiftc_driver_plain -disallow-use-new-driver %s @%t.resp | %FileCheck %s
1010
// RUN: rm %swift-bin-dir/legacy-driver-propagates-response-file.sh
1111

1212
// CHECK: -Xfrontend

tools/driver/CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,20 @@ if(EXISTS "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-driver${CMAKE_EXECUTABLE_SUFFIX}
8585
SOURCE "swift-driver${CMAKE_EXECUTABLE_SUFFIX}"
8686
DESTINATION "swift${CMAKE_EXECUTABLE_SUFFIX}"
8787
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
88-
8988
swift_create_post_build_symlink(swift-frontend
9089
SOURCE "swift-driver${CMAKE_EXECUTABLE_SUFFIX}"
9190
DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}"
9291
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
92+
93+
message(STATUS "Pointing 'swift-legacy-driver' and 'swiftc-legacy-driver' symlinks at 'swift-frontend'.")
94+
swift_create_post_build_symlink(swift-frontend
95+
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
96+
DESTINATION "swift-legacy-driver${CMAKE_EXECUTABLE_SUFFIX}"
97+
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
98+
swift_create_post_build_symlink(swift-frontend
99+
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
100+
DESTINATION "swiftc-legacy-driver${CMAKE_EXECUTABLE_SUFFIX}"
101+
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
93102
else()
94103
message(STATUS "Pointing 'swift' and 'swiftc' symlinks at 'swift-frontend' - no early SwiftDriver build found.")
95104
swift_create_post_build_symlink(swift-frontend
@@ -207,4 +216,10 @@ if(EXISTS "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-driver${CMAKE_EXECUTABLE_SUFFIX}
207216
swift_install_in_component(PROGRAMS "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-help${CMAKE_EXECUTABLE_SUFFIX}"
208217
DESTINATION "bin"
209218
COMPONENT compiler)
219+
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swiftc-legacy-driver${CMAKE_EXECUTABLE_SUFFIX}"
220+
DESTINATION "bin"
221+
COMPONENT compiler)
222+
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-legacy-driver${CMAKE_EXECUTABLE_SUFFIX}"
223+
DESTINATION "bin"
224+
COMPONENT compiler)
210225
endif()

0 commit comments

Comments
 (0)