Skip to content

Revert "Refactor job response file handling to (hopefully) prevent regressions." #1038

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

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
jobs.append(Job(
moduleName: moduleId.moduleName,
kind: .emitModule,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
Expand Down Expand Up @@ -237,7 +237,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
jobs.append(Job(
moduleName: moduleId.moduleName,
kind: .generatePCM,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ public extension Driver {
// Construct the scanning job.
return Job(moduleName: moduleOutputInfo.name,
kind: .scanDependencies,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: VirtualPath.absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)])
outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)],
supportsResponseFiles: false)
}

/// Generate a full command-line invocation to be used for the dependency scanning action
Expand Down Expand Up @@ -262,12 +263,13 @@ public extension Driver {
// Construct the scanning job.
return Job(moduleName: moduleOutputInfo.name,
kind: .scanDependencies,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: VirtualPath.absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)])
outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)],
supportsResponseFiles: false)
}

/// Precompute the dependencies for a given collection of modules using swift frontend's batch scanning mode
Expand Down Expand Up @@ -310,12 +312,13 @@ public extension Driver {
// Construct the scanning job.
return Job(moduleName: moduleOutputInfo.name,
kind: .scanDependencies,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: VirtualPath.absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: outputs)
outputs: outputs,
supportsResponseFiles: false)
}

/// Serialize a collection of modules into an input format expected by the batch module dependency scanner.
Expand Down
15 changes: 9 additions & 6 deletions Sources/SwiftDriver/Jobs/APIDigesterJobs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: mode.baselineGenerationJobKind,
tool: try toolchain.resolvedTool(.swiftAPIDigester),
tool: .absolute(try toolchain.getToolPath(.swiftAPIDigester)),
commandLine: commandLine,
inputs: [.init(file: modulePath, type: .swiftModule)],
primaryInputs: [],
outputs: [.init(file: outputPath, type: mode.baselineFileType)]
outputs: [.init(file: outputPath, type: mode.baselineFileType)],
supportsResponseFiles: true
)
}

Expand Down Expand Up @@ -99,11 +100,12 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .compareABIBaseline,
tool: try toolchain.resolvedTool(.swiftAPIDigester),
tool: .absolute(try toolchain.getToolPath(.swiftAPIDigester)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: [diag]
outputs: [diag],
supportsResponseFiles: true
)
}

Expand Down Expand Up @@ -139,11 +141,12 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: mode.baselineComparisonJobKind,
tool: try toolchain.resolvedTool(.swiftAPIDigester),
tool: .absolute(try toolchain.getToolPath(.swiftAPIDigester)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: [.init(file: serializedDiagnosticsPath ?? VirtualPath.Handle.standardOutput, type: .diagnostics)]
outputs: [.init(file: serializedDiagnosticsPath ?? VirtualPath.Handle.standardOutput, type: .diagnostics)],
supportsResponseFiles: true
)
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/AutolinkExtractJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .autolinkExtract,
tool: try toolchain.resolvedTool(.swiftAutolinkExtract),
tool: .absolute(try toolchain.getToolPath(.swiftAutolinkExtract)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: [.init(file: output.intern(), type: .autolink)]
outputs: [.init(file: output.intern(), type: .autolink)],
supportsResponseFiles: true
)
}
}
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/BackendJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .backend,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: outputs
outputs: outputs,
supportsResponseFiles: true
)
}
}
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/CompileJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,14 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .compile,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: displayInputs,
inputs: inputs,
primaryInputs: primaryInputs,
outputs: outputs,
inputOutputMap: inputOutputMap
inputOutputMap: inputOutputMap,
supportsResponseFiles: true
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftDriver/Jobs/DarwinToolchain+LinkerSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ extension DarwinToolchain {
lto: LTOKind?,
sanitizers: Set<Sanitizer>,
targetInfo: FrontendTargetInfo
) throws -> ResolvedTool {
) throws -> AbsolutePath {
// Set up for linking.
let linkerTool: Tool
switch linkerOutputType {
Expand Down Expand Up @@ -251,7 +251,7 @@ extension DarwinToolchain {
commandLine.appendFlag("-o")
commandLine.appendPath(outputFile)

return try resolvedTool(linkerTool)
return try getToolPath(linkerTool)
}

private func addLinkInputs(shouldUseInputFileList: Bool,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Jobs/EmitModuleJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .emitModule,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/EmitSupportedFeaturesJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ extension Toolchain {
return Job(
moduleName: "",
kind: .emitSupportedFeatures,
tool: try resolvedTool(.swiftCompiler),
tool: .absolute(try getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
primaryInputs: [],
outputs: [.init(file: .standardOutput, type: .jsonCompilerFeatures)],
requiresInPlaceExecution: requiresInPlaceExecution
requiresInPlaceExecution: requiresInPlaceExecution,
supportsResponseFiles: false
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Jobs/GenerateDSYMJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .generateDSYM,
tool: try toolchain.resolvedTool(.dsymutil),
tool: .absolute(try toolchain.getToolPath(.dsymutil)),
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/GeneratePCHJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .generatePCH,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
primaryInputs: [],
outputs: outputs
outputs: outputs,
supportsResponseFiles: true
)
}
}
4 changes: 2 additions & 2 deletions Sources/SwiftDriver/Jobs/GeneratePCMJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .generatePCM,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
Expand Down Expand Up @@ -84,7 +84,7 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .dumpPCM,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension GenericUnixToolchain {
lto: LTOKind?,
sanitizers: Set<Sanitizer>,
targetInfo: FrontendTargetInfo
) throws -> ResolvedTool {
) throws -> AbsolutePath {
let targetTriple = targetInfo.target.triple
switch linkerOutputType {
case .dynamicLibrary:
Expand Down Expand Up @@ -103,9 +103,9 @@ extension GenericUnixToolchain {
// Windows rather than msvcprt). When C++ interop is enabled, we will need to
// surface this via a driver flag. For now, opt for the simpler approach of
// just using `clang` and avoid a dependency on the C++ runtime.
let clangTool: Tool =
parsedOptions.hasArgument(.enableExperimentalCxxInterop) ? .clangxx : .clang
var clangPath = try getToolPath(clangTool)
var clangPath = try parsedOptions.hasArgument(.enableExperimentalCxxInterop)
? getToolPath(.clangxx)
: getToolPath(.clang)
if let toolsDirPath = parsedOptions.getLastArgument(.toolsDirectory) {
// FIXME: What if this isn't an absolute path?
let toolsDir = try AbsolutePath(validating: toolsDirPath.asSingle)
Expand Down Expand Up @@ -296,7 +296,7 @@ extension GenericUnixToolchain {
// This should be the last option, for convenience in checking output.
commandLine.appendFlag(.o)
commandLine.appendPath(outputFile)
return try resolvedTool(clangTool, pathOverride: clangPath)
return clangPath
case .staticLibrary:
// We're using 'ar' as a linker
commandLine.appendFlag("crs")
Expand All @@ -308,9 +308,9 @@ extension GenericUnixToolchain {
}.map { .path($0.file) })
if targetTriple.environment == .android {
// Always use the LTO archiver llvm-ar for Android
return try resolvedTool(.staticLinker(.llvmFull))
return try getToolPath(.staticLinker(.llvmFull))
} else {
return try resolvedTool(.staticLinker(lto))
return try getToolPath(.staticLinker(lto))
}
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/InterpretJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .interpret,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: [],
extraEnvironment: extraEnvironment,
requiresInPlaceExecution: true
requiresInPlaceExecution: true,
supportsResponseFiles: true
)
}
}
9 changes: 5 additions & 4 deletions Sources/SwiftDriver/Jobs/Job.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,20 @@ public struct Job: Codable, Equatable, Hashable {
public init(
moduleName: String,
kind: Kind,
tool: ResolvedTool,
tool: VirtualPath,
commandLine: [ArgTemplate],
displayInputs: [TypedVirtualPath]? = nil,
inputs: [TypedVirtualPath],
primaryInputs: [TypedVirtualPath],
outputs: [TypedVirtualPath],
inputOutputMap: [TypedVirtualPath : [TypedVirtualPath]] = [:],
extraEnvironment: [String: String] = [:],
requiresInPlaceExecution: Bool = false
requiresInPlaceExecution: Bool = false,
supportsResponseFiles: Bool = false
) {
self.moduleName = moduleName
self.kind = kind
self.tool = .absolute(tool.path)
self.tool = tool
self.commandLine = commandLine
self.displayInputs = displayInputs ?? []
self.inputs = inputs
Expand All @@ -127,7 +128,7 @@ public struct Job: Codable, Equatable, Hashable {
self.compileInputOutputMap = inputOutputMap
self.extraEnvironment = extraEnvironment
self.requiresInPlaceExecution = requiresInPlaceExecution
self.supportsResponseFiles = tool.supportsResponseFiles
self.supportsResponseFiles = supportsResponseFiles
}

public var primarySwiftSourceFiles: [SwiftSourceFile] { primaryInputs.swiftSourceFiles }
Expand Down
9 changes: 6 additions & 3 deletions Sources/SwiftDriver/Jobs/LinkJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extension Driver {
}

// Defer to the toolchain for platform-specific linking
let linkTool = try toolchain.addPlatformSpecificLinkerArgs(
let toolPath = try toolchain.addPlatformSpecificLinkerArgs(
to: &commandLine,
parsedOptions: &parsedOptions,
linkerOutputType: linkerOutputType!,
Expand All @@ -67,12 +67,15 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .link,
tool: linkTool,
tool: .absolute(toolPath),
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: [.init(file: outputFile.intern(), type: .image)]
outputs: [.init(file: outputFile.intern(), type: .image)],
// FIXME: newer ld64 supports response files as well, though really,
// Darwin should use clang as the linker driver like the other targets
supportsResponseFiles: !frontendTargetInfo.target.triple.isDarwin
)
}
}
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/MergeModuleJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .mergeModule,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: outputs
outputs: outputs,
supportsResponseFiles: true
)
}
}
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/ModuleWrapJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ extension Driver {
return Job(
moduleName: moduleOutputInfo.name,
kind: .moduleWrap,
tool: try toolchain.resolvedTool(.swiftCompiler),
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: [moduleInput],
primaryInputs: [],
outputs: [.init(file: outputPath.intern(), type: .object)]
outputs: [.init(file: outputPath.intern(), type: .object)],
supportsResponseFiles: true
)
}
}
Loading