From dc26b11b9708d615f9dbb97cb64f059cf1e6689d Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Sat, 6 Jul 2024 11:48:40 -0700 Subject: [PATCH] Ignore prebuilt module cache when building the prebuilt module cache When building modules for an SDK, we need to ignore any existing prebuilt modules to avoid building a partial prebult module cache. Do so by passing an intentially-bad path for the prebuilt module cache path that's derived from the output path (but not the same as that path). This prohibits the frontend scanning job from adding the default prebuilt module cache path, while ensuring that we find no prebuilt modules. Fixes rdar://131183526. --- Sources/swift-build-sdk-interfaces/main.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/swift-build-sdk-interfaces/main.swift b/Sources/swift-build-sdk-interfaces/main.swift index 07eced80c..0bf3aa26a 100644 --- a/Sources/swift-build-sdk-interfaces/main.swift +++ b/Sources/swift-build-sdk-interfaces/main.swift @@ -157,6 +157,18 @@ do { try localFileSystem.createDirectory(mcpPath, recursive: true) } } + + // When building modules for an SDK, ignore any existing prebuilt modules. + // modules. Do so by passing an intentially-bad path for the prebuilt + // module cache path that's derived from the output path (but not the same + // as that path). This prohibits the frontend scanning job from adding the + // default prebuilt module cache path, while ensuring that we find no + // prebuilt modules during this scan. + args.append("-Xfrontend") + args.append("-prebuilt-module-cache-path") + args.append("-Xfrontend") + args.append(outputDir.appending(component: "__nonexistent__").pathString) + let baselineABIDir = try getArgumentAsPath("-baseline-abi-dir") var driver = try Driver(args: args, diagnosticsOutput: .engine(diagnosticsEngine),