Skip to content

Commit dd4e8c0

Browse files
committed
[Dependency Scanning] Treat resource-directory-discovered modules as stable and make them use the SDK-specific module cache path
1 parent 04015fe commit dd4e8c0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,13 +2890,18 @@ void setOutputPath(ResultTy &resolvedOutputPath, const StringRef &moduleName,
28902890
const CompilerInvocation &CI, const ArgListTy &extraArgs) {
28912891
auto &outputPath = resolvedOutputPath.outputPath;
28922892
outputPath = CI.getClangModuleCachePath();
2893+
auto isPrefixedWith = [interfacePath](StringRef path) {
2894+
return !path.empty() &&
2895+
hasPrefix(llvm::sys::path::begin(interfacePath.str()),
2896+
llvm::sys::path::end(interfacePath.str()),
2897+
llvm::sys::path::begin(path), llvm::sys::path::end(path));
2898+
};
28932899

28942900
// Dependency-scanner-specific module output path handling
28952901
if ((CI.getFrontendOptions().RequestedAction ==
28962902
FrontendOptions::ActionType::ScanDependencies)) {
2897-
if (!sdkPath.empty() &&
2898-
hasPrefix(llvm::sys::path::begin(interfacePath.str()), llvm::sys::path::end(interfacePath.str()),
2899-
llvm::sys::path::begin(sdkPath), llvm::sys::path::end(sdkPath)))
2903+
auto runtimeResourcePath = CI.getSearchPathOptions().RuntimeResourcePath;
2904+
if (isPrefixedWith(sdkPath) || isPrefixedWith(runtimeResourcePath))
29002905
outputPath = CI.getFrontendOptions().ExplicitSDKModulesOutputPath;
29012906
else
29022907
outputPath = CI.getFrontendOptions().ExplicitModulesOutputPath;

0 commit comments

Comments
 (0)