Skip to content

Commit db7a726

Browse files
author
Harlan Haskins
committed
[ModuleInterface] Create module cache path if we install a forwarding module
If we are installing a forwarding module to something in the prebuilt cache, make sure to create the module cache directory if it doesn't exist. rdar://52964217
1 parent ca1e808 commit db7a726

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Frontend/ParseableInterfaceModuleLoader.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ class swift::ParseableInterfaceBuilder {
504504
// Note that we don't assume cachePath is the same as the Clang
505505
// module cache path at this point.
506506
if (!moduleCachePath.empty())
507-
(void)llvm::sys::fs::create_directory(moduleCachePath);
507+
(void)llvm::sys::fs::create_directories(moduleCachePath);
508508

509509
configureSubInvocationInputsAndOutputs(OutPath);
510510

@@ -1267,6 +1267,10 @@ class ParseableInterfaceModuleLoaderImpl {
12671267
depsAdjustedToMTime.push_back(adjustedDep);
12681268
}
12691269

1270+
// Create the module cache if we haven't created it yet.
1271+
StringRef parentDir = path::parent_path(outputPath);
1272+
(void)llvm::sys::fs::create_directories(parentDir);
1273+
12701274
auto hadError = withOutputFile(diags, outputPath,
12711275
[&](llvm::raw_pwrite_stream &out) {
12721276
llvm::yaml::Output yamlWriter(out);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// Create a prebuilt module cache and populate it with a prebuilt module.
4+
// RUN: %empty-directory(%t/prebuilt-cache)
5+
// RUN: %target-swift-frontend -parse-stdlib %S/Inputs/prebuilt-module-cache/Lib.swiftinterface -emit-module-path %t/prebuilt-cache/Lib.swiftmodule - -module-name Lib
6+
7+
// Compile against the module with a module cache that does not exist
8+
// 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
9+
10+
// Make sure we installed a forwarding module.
11+
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/RandomPath/NonExistentCachePath/Lib-*.swiftmodule
12+
13+
import Lib

0 commit comments

Comments
 (0)