Skip to content

Commit

Permalink
[Explicit Module Builds] Do not specify Clang dependency '.modulemap'…
Browse files Browse the repository at this point in the history
… files as task inputs

These files exist outside the task execution graph and are not produced by any of the tasks involved, so we rely on trusting they are present. This is crucial because these paths may be pre-VFS-remap paths which means that the driver (not-VFS-aware) may not have access to their "external" path and thus unable to verify their actual existence.
  • Loading branch information
artemcm committed Jan 12, 2024
1 parent c283179 commit 0da3ecf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
// The only required input is the .modulemap for this module.
// Command line options in the dependency scanner output will include the
// required modulemap, so here we must only add it to the list of inputs.
inputs.append(moduleMapPath)
let cacheKeys : [TypedVirtualPath : String]
if let key = moduleDetails.moduleCacheKey {
cacheKeys = [moduleMapPath: key]
Expand Down Expand Up @@ -276,11 +275,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
let clangModulePath =
TypedVirtualPath(file: moduleArtifactInfo.clangModulePath.path,
type: .pcm)
let clangModuleMapPath =
TypedVirtualPath(file: moduleArtifactInfo.clangModuleMapPath.path,
type: .clangModuleMap)
inputs.append(clangModulePath)
inputs.append(clangModuleMapPath)
}

// Swift Main Module dependencies are passed encoded in a JSON file as described by
Expand Down Expand Up @@ -445,11 +440,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
let clangModulePath =
TypedVirtualPath(file: moduleArtifactInfo.clangModulePath.path,
type: .pcm)
let clangModuleMapPath =
TypedVirtualPath(file: moduleArtifactInfo.clangModuleMapPath.path,
type: .clangModuleMap)
inputs.append(clangModulePath)
inputs.append(clangModuleMapPath)
}

// Return if depscanner provided build commands.
Expand Down
10 changes: 1 addition & 9 deletions Tests/SwiftDriverTests/CachingBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ throws {
for command in extraCommandLine {
XCTAssertTrue(job.commandLine.contains(.flag(command)))
}
case .clang(let clangModuleDetails):
let moduleMapPath =
TypedVirtualPath(file: clangModuleDetails.moduleMapPath.path,
type: .clangModuleMap)
case .clang(_):
XCTAssertEqual(job.kind, .generatePCM)
XCTAssertEqual(job.description, "Compiling Clang module \(moduleId.moduleName)")
XCTAssertTrue(job.inputs.contains(moduleMapPath))
case .swiftPrebuiltExternal(_):
XCTFail("Unexpected prebuilt external module dependency found.")
case .swiftPlaceholder(_):
Expand Down Expand Up @@ -167,11 +163,7 @@ private func checkCachingBuildJobDependencies(job: Job,
let clangDependencyModulePathString = dependencyInfo.modulePath.path
let clangDependencyModulePath =
TypedVirtualPath(file: clangDependencyModulePathString, type: .pcm)
let clangDependencyModuleMapPath =
TypedVirtualPath(file: clangDependencyDetails.moduleMapPath.path,
type: .clangModuleMap)
XCTAssertTrue(job.inputs.contains(clangDependencyModulePath))
XCTAssertTrue(job.inputs.contains(clangDependencyModuleMapPath))
XCTAssertTrue(job.commandLine.contains(
.flag(String("-fmodule-file=\(dependencyId.moduleName)=\(clangDependencyModulePathString)"))))
XCTAssertTrue(job.commandLine.contains(
Expand Down
10 changes: 1 addition & 9 deletions Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@ throws {
}
XCTAssertTrue(job.commandLine.filter {$0 == .flag("-candidate-module-file")}.count == compiledCandidateList.count)
}
case .clang(let clangModuleDetails):
let moduleMapPath =
TypedVirtualPath(file: clangModuleDetails.moduleMapPath.path,
type: .clangModuleMap)
case .clang(_):
XCTAssertEqual(job.kind, .generatePCM)
XCTAssertEqual(job.description, "Compiling Clang module \(moduleId.moduleName)")
XCTAssertTrue(job.inputs.contains(moduleMapPath))
case .swiftPrebuiltExternal(_):
XCTFail("Unexpected prebuilt external module dependency found.")
case .swiftPlaceholder(_):
Expand Down Expand Up @@ -88,11 +84,7 @@ private func checkExplicitModuleBuildJobDependencies(job: Job,
let clangDependencyModulePathString = dependencyInfo.modulePath.path
let clangDependencyModulePath =
TypedVirtualPath(file: clangDependencyModulePathString, type: .pcm)
let clangDependencyModuleMapPath =
TypedVirtualPath(file: clangDependencyDetails.moduleMapPath.path,
type: .clangModuleMap)
XCTAssertTrue(job.inputs.contains(clangDependencyModulePath))
XCTAssertTrue(job.inputs.contains(clangDependencyModuleMapPath))
XCTAssertTrue(job.commandLine.contains(
.flag(String("-fmodule-file=\(dependencyId.moduleName)=\(clangDependencyModulePathString)"))))
XCTAssertTrue(job.commandLine.contains(
Expand Down

0 comments on commit 0da3ecf

Please sign in to comment.