-
Couldn't load subscription status.
- Fork 1.4k
Make sure we actually use swift-driver
#5842
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ public protocol Toolchain { | |
| /// Path of the `swiftc` compiler. | ||
| var swiftCompilerPath: AbsolutePath { get } | ||
|
|
||
| /// Path of the `swiftc` compiler to use for manifest compilation. | ||
| var swiftCompilerPathForManifests: AbsolutePath { get } | ||
|
|
||
| /// Path containing the macOS Swift stdlib. | ||
| var macosSwiftStdlib: AbsolutePath { get throws } | ||
|
|
||
|
|
@@ -75,4 +78,21 @@ extension Toolchain { | |
| public var extraSwiftCFlags: [String] { | ||
| extraFlags.swiftCompilerFlags | ||
| } | ||
|
|
||
| private static func commandLineForCompilation(compilerPath: AbsolutePath, fileSystem: FileSystem) -> [String] { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: reverse order of arguments |
||
| let swiftDriverPath = compilerPath.parentDirectory.appending(component: "swift-driver") | ||
| if fileSystem.exists(swiftDriverPath) { | ||
| return [swiftDriverPath.pathString, "--driver-mode=swiftc"] | ||
| } else { | ||
| return [compilerPath.pathString] | ||
| } | ||
| } | ||
|
|
||
| public func commandLineForManifestCompilation(fileSystem: FileSystem) -> [String] { | ||
| return Self.commandLineForCompilation(compilerPath: swiftCompilerPathForManifests, fileSystem: fileSystem) | ||
| } | ||
|
|
||
| public func commandLineForSwiftCompilation(fileSystem: FileSystem) -> [String] { | ||
| return Self.commandLineForCompilation(compilerPath: swiftCompilerPath, fileSystem: fileSystem) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,28 +94,4 @@ extension UserToolchain { | |
| return true | ||
| #endif | ||
| } | ||
|
|
||
| /// Helper function to determine whether serialized diagnostics work properly in the current environment. | ||
| public func supportsSerializedDiagnostics(otherSwiftFlags: [String] = []) -> Bool { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the hope/goal since this was needed because we were using the old driver in CI contexts (which apparently has a bug triggered by some of our tests). |
||
| do { | ||
| try testWithTemporaryDirectory { tmpPath in | ||
| let inputPath = tmpPath.appending(component: "best.swift") | ||
| try localFileSystem.writeFileContents(inputPath, string: "func foo() -> Bool {\nvar unused: Int\nreturn true\n}\n") | ||
| let outputPath = tmpPath.appending(component: "foo") | ||
| let serializedDiagnosticsPath = tmpPath.appending(component: "out.dia") | ||
| let toolchainPath = self.swiftCompilerPath.parentDirectory.parentDirectory | ||
| try Process.checkNonZeroExit(arguments: ["/usr/bin/xcrun", "--toolchain", toolchainPath.pathString, "swiftc", inputPath.pathString, "-Xfrontend", "-serialize-diagnostics-path", "-Xfrontend", serializedDiagnosticsPath.pathString, "-g", "-o", outputPath.pathString] + otherSwiftFlags) | ||
| try Process.checkNonZeroExit(arguments: [outputPath.pathString]) | ||
|
|
||
| let diaFileContents = try localFileSystem.readFileContents(serializedDiagnosticsPath) | ||
| let diagnosticsSet = try SerializedDiagnostics(bytes: diaFileContents) | ||
| if diagnosticsSet.diagnostics.isEmpty { | ||
| throw StringError("does not support diagnostics") | ||
| } | ||
| } | ||
| return true | ||
| } catch { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix this we'd need to move off llbuild's built-in tool and instead create a shell command (which is probably better anyway).