Skip to content

Commit 4365024

Browse files
committed
PrebuiltModuleGen: Print an error instead of crashing when SWIFT_EXEC is invalid.
Also, fix a diagnostic typo.
1 parent cee8c66 commit 4365024

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/SwiftDriver/Jobs/PrebuiltModulesJob.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ extension Driver {
792792
// of mac native so those macabi-only modules cannot be found by the scanner.
793793
// We have to handle those modules separately without any dependency info.
794794
try unhandledModules.forEach { moduleName in
795-
diagnosticEngine.emit(warning: "handle \(moduleName) as dangling jobs")
795+
diagnosticEngine.emit(warning: "handle \(moduleName) has dangling jobs")
796796
try forEachInputOutputPair(moduleName) { input, output in
797797
danglingJobs.append(contentsOf: try generateSingleModuleBuildingJob(moduleName,
798798
prebuiltModuleDir, input, output, [], currentABIDir, baselineABIDir))

Sources/swift-build-sdk-interfaces/main.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ do {
9090
let swiftcPathRaw = ProcessEnv.vars["SWIFT_EXEC"]
9191
var swiftcPath: AbsolutePath
9292
if let swiftcPathRaw = swiftcPathRaw {
93-
swiftcPath = try VirtualPath(path: swiftcPathRaw).absolutePath!
93+
let virtualPath = try VirtualPath(path: swiftcPathRaw)
94+
guard let absolutePath = virtualPath.absolutePath else {
95+
diagnosticsEngine.emit(error: "value of SWIFT_EXEC is not a valid absolute path: \(swiftcPathRaw)")
96+
exit(1)
97+
}
98+
swiftcPath = absolutePath
9499
} else {
95100
swiftcPath = AbsolutePath("Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc",
96101
relativeTo: sdkPath.parentDirectory

0 commit comments

Comments
 (0)