From 1999828ccc5e6059fdba7bee0d37977abe256b05 Mon Sep 17 00:00:00 2001 From: artemcm Date: Mon, 8 Jul 2024 09:36:46 -0700 Subject: [PATCH] [PrebuiltModuleGen] Ensure the dependency scanner always ignores existing prebuilt modules --- Sources/swift-build-sdk-interfaces/main.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sources/swift-build-sdk-interfaces/main.swift b/Sources/swift-build-sdk-interfaces/main.swift index 0bf3aa26a..cdc76a295 100644 --- a/Sources/swift-build-sdk-interfaces/main.swift +++ b/Sources/swift-build-sdk-interfaces/main.swift @@ -169,6 +169,19 @@ do { args.append("-Xfrontend") args.append(outputDir.appending(component: "__nonexistent__").pathString) + // If the compiler/scanner supports it, instruct it to ignore any existing prebuilt + // modules for which a textual interface is discovered, ensuring that modules + // always build from interface when one is available. + if let supportedFlagsTestDriver = try? Driver(args: ["swiftc", "-v"], + executor: executor, + compilerExecutableDir: swiftcPath.parentDirectory), + supportedFlagsTestDriver.isFrontendArgSupported(.moduleLoadMode) { + args.append("-Xfrontend") + args.append("-module-load-mode") + args.append("-Xfrontend") + args.append("only-interface") + } + let baselineABIDir = try getArgumentAsPath("-baseline-abi-dir") var driver = try Driver(args: args, diagnosticsOutput: .engine(diagnosticsEngine),