Skip to content

[ModuleInterface] Create module cache path if we install a forwarding module #26127

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

Merged
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
6 changes: 5 additions & 1 deletion lib/Frontend/ParseableInterfaceModuleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ class swift::ParseableInterfaceBuilder {
// Note that we don't assume cachePath is the same as the Clang
// module cache path at this point.
if (!moduleCachePath.empty())
(void)llvm::sys::fs::create_directory(moduleCachePath);
(void)llvm::sys::fs::create_directories(moduleCachePath);

configureSubInvocationInputsAndOutputs(OutPath);

Expand Down Expand Up @@ -1267,6 +1267,10 @@ class ParseableInterfaceModuleLoaderImpl {
depsAdjustedToMTime.push_back(adjustedDep);
}

// Create the module cache if we haven't created it yet.
StringRef parentDir = path::parent_path(outputPath);
(void)llvm::sys::fs::create_directories(parentDir);

auto hadError = withOutputFile(diags, outputPath,
[&](llvm::raw_pwrite_stream &out) {
llvm::yaml::Output yamlWriter(out);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %empty-directory(%t)

// Create a prebuilt module cache and populate it with a prebuilt module.
// RUN: %empty-directory(%t/prebuilt-cache)
// RUN: %target-swift-frontend -parse-stdlib %S/Inputs/prebuilt-module-cache/Lib.swiftinterface -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib

// Compile against the module with a module cache that does not exist
// RUN: %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/RandomPath/NonExistentCachePath -sdk %S/Inputs -I %S/Inputs/prebuilt-module-cache -prebuilt-module-cache-path %t/prebuilt-cache %s

// Make sure we installed a forwarding module.
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/RandomPath/NonExistentCachePath/Lib-*.swiftmodule

import Lib