Skip to content

PrebuiltModuleGen: Print an error instead of crashing when SWIFT_EXEC is invalid #1246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Jobs/PrebuiltModulesJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ extension Driver {
// of mac native so those macabi-only modules cannot be found by the scanner.
// We have to handle those modules separately without any dependency info.
try unhandledModules.forEach { moduleName in
diagnosticEngine.emit(warning: "handle \(moduleName) as dangling jobs")
diagnosticEngine.emit(warning: "handle \(moduleName) has dangling jobs")
try forEachInputOutputPair(moduleName) { input, output in
danglingJobs.append(contentsOf: try generateSingleModuleBuildingJob(moduleName,
prebuiltModuleDir, input, output, [], currentABIDir, baselineABIDir))
Expand Down
7 changes: 6 additions & 1 deletion Sources/swift-build-sdk-interfaces/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ do {
let swiftcPathRaw = ProcessEnv.vars["SWIFT_EXEC"]
var swiftcPath: AbsolutePath
if let swiftcPathRaw = swiftcPathRaw {
swiftcPath = try VirtualPath(path: swiftcPathRaw).absolutePath!
let virtualPath = try VirtualPath(path: swiftcPathRaw)
guard let absolutePath = virtualPath.absolutePath else {
diagnosticsEngine.emit(error: "value of SWIFT_EXEC is not a valid absolute path: \(swiftcPathRaw)")
exit(1)
}
swiftcPath = absolutePath
} else {
swiftcPath = AbsolutePath("Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc",
relativeTo: sdkPath.parentDirectory
Expand Down