Re-apply "ModuleInterface: lock .swiftinterface while generating module cache"

This commit is contained in:
Xi Ge
2020-01-10 10:18:57 -08:00
parent aba9c8b4c2
commit e1f6e846ca
5 changed files with 98 additions and 7 deletions

View File

@@ -950,13 +950,11 @@ class ModuleInterfaceLoaderImpl {
std::unique_ptr<llvm::MemoryBuffer> moduleBuffer;
// We didn't discover a module corresponding to this interface.
// Diagnose that we didn't find a loadable module, if we were asked to.
if (remarkOnRebuildFromInterface) {
auto remarkRebuild = [&]() {
rebuildInfo.diagnose(ctx, diagnosticLoc, moduleName,
interfacePath);
}
};
// If we found an out-of-date .swiftmodule, we still want to add it as
// a dependency of the .swiftinterface. That way if it's updated, but
// the .swiftinterface remains the same, we invalidate the cache and
@@ -966,7 +964,9 @@ class ModuleInterfaceLoaderImpl {
builder.addExtraDependency(modulePath);
if (builder.buildSwiftModule(cachedOutputPath, /*shouldSerializeDeps*/true,
&moduleBuffer))
&moduleBuffer,
remarkOnRebuildFromInterface ? remarkRebuild:
llvm::function_ref<void()>()))
return std::make_error_code(std::errc::invalid_argument);
assert(moduleBuffer &&