Don't serialize relative resource dir module paths

This commit is contained in:
Richard Howell
2024-09-30 12:58:33 -07:00
parent b5a85ed8dc
commit 7aa94723a6
6 changed files with 29 additions and 1 deletions

View File

@@ -105,6 +105,12 @@ bool ExplicitModuleInterfaceBuilder::collectDepsForSerialization(
path::native(SDKPath);
SmallString<128> ResourcePath(Opts.RuntimeResourcePath);
path::native(ResourcePath);
// When compiling with a relative resource dir, the clang
// importer will track inputs with absolute paths. To avoid
// serializing resource dir inputs we need to check for
// relative _and_ absolute prefixes.
SmallString<128> AbsResourcePath(ResourcePath);
llvm::sys::fs::make_absolute(AbsResourcePath);
auto DTDeps = Instance.getDependencyTracker()->getDependencies();
SmallVector<std::string, 16> InitialDepNames(DTDeps.begin(), DTDeps.end());
@@ -146,7 +152,7 @@ bool ExplicitModuleInterfaceBuilder::collectDepsForSerialization(
}
// Don't serialize compiler-relative deps so the cache is relocatable.
if (DepName.starts_with(ResourcePath))
if (DepName.starts_with(ResourcePath) || DepName.starts_with(AbsResourcePath))
continue;
auto Status = fs.status(DepName);