Skip to content

Commit 03f4816

Browse files
committed
[Explicit Module Builds] Ensure that plugin paths are specified to the dependency scanning invocation
b0a01d3 accidentally broke this by restricting these flags to never get passed when EBM is enabled, as opposed to ensuring they get passed on non-EBM and dependency scanning tasks. Resolves rdar://154326377
1 parent 396aa30 commit 03f4816

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extension Driver {
8181
break
8282
}
8383

84-
let isPlanJobForExplicitModule = parsedOptions.contains(.driverExplicitModuleBuild)
84+
let isPlanJobForExplicitModule = parsedOptions.contains(.driverExplicitModuleBuild) && explicitModulePlanner != nil
8585
let jobNeedPathRemap: Bool
8686
// If in ExplicitModuleBuild mode and the dependency graph has been computed, add module
8787
// dependencies.

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,52 @@ final class ExplicitModuleBuildTests: XCTestCase {
19861986
}
19871987
}
19881988

1989+
/// Test the libSwiftScan dependency scanning.
1990+
func testDependencyScanningPluginFlagPropagation() throws {
1991+
let (stdlibPath, shimsPath, toolchain, hostTriple) = try getDriverArtifactsForScanning()
1992+
1993+
// The dependency oracle wraps an instance of libSwiftScan and ensures thread safety across
1994+
// queries.
1995+
let dependencyOracle = InterModuleDependencyOracle()
1996+
let scanLibPath = try XCTUnwrap(toolchain.lookupSwiftScanLib())
1997+
try dependencyOracle.verifyOrCreateScannerInstance(swiftScanLibPath: scanLibPath)
1998+
1999+
// Create a simple test case.
2000+
try withTemporaryDirectory { path in
2001+
let main = path.appending(component: "testDependencyScanning.swift")
2002+
try localFileSystem.writeFileContents(main, bytes:
2003+
"""
2004+
import C;\
2005+
import E;\
2006+
import G;
2007+
"""
2008+
)
2009+
2010+
let cHeadersPath: AbsolutePath =
2011+
try testInputsPath.appending(component: "ExplicitModuleBuilds")
2012+
.appending(component: "CHeaders")
2013+
let swiftModuleInterfacesPath: AbsolutePath =
2014+
try testInputsPath.appending(component: "ExplicitModuleBuilds")
2015+
.appending(component: "Swift")
2016+
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
2017+
var driver = try Driver(args: ["swiftc",
2018+
"-I", cHeadersPath.nativePathString(escaped: true),
2019+
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
2020+
"-I", stdlibPath.nativePathString(escaped: true),
2021+
"-I", shimsPath.nativePathString(escaped: true),
2022+
"/tmp/Foo.o",
2023+
"-plugin-path", "PluginA", "-external-plugin-path", "Plugin~B#Bexe",
2024+
"-explicit-module-build",
2025+
"-working-directory", path.nativePathString(escaped: true),
2026+
"-disable-clang-target",
2027+
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
2028+
let resolver = try ArgsResolver(fileSystem: localFileSystem)
2029+
var scannerCommand = try driver.dependencyScannerInvocationCommand().1.map { try resolver.resolve($0) }
2030+
XCTAssertTrue(scannerCommand.contains("-plugin-path"))
2031+
XCTAssertTrue(scannerCommand.contains("-external-plugin-path"))
2032+
}
2033+
}
2034+
19892035
/// Test the libSwiftScan dependency scanning.
19902036
func testDependencyScanning() throws {
19912037
let (stdlibPath, shimsPath, toolchain, hostTriple) = try getDriverArtifactsForScanning()

0 commit comments

Comments
 (0)