[Serialization] Load swiftmodule files as volatile to avoid mmap

Avoid mmaping swiftmodule files to hopefully fix issues seen when
building many Swift projects in parallel on NFS. This only affects
loading ModuleFile, it doesn't affect scanning swiftmodule for
dependecies which are still handled as non-volatile.

rdar://63755989
This commit is contained in:
Alexis Laferrière
2020-07-17 18:03:37 -07:00
parent 7573a640ed
commit a4becdac81

View File

@@ -347,8 +347,15 @@ std::error_code SerializedModuleLoaderBase::openModuleFile(
}
// Actually load the file and error out if necessary.
//
// Use the default arguments except for IsVolatile. Force avoiding the use of
// mmap to workaround issues on NFS when the swiftmodule file loaded changes
// on disk while it's in use.
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ModuleOrErr =
FS.getBufferForFile(ModulePath);
FS.getBufferForFile(ModulePath,
/*FileSize=*/-1,
/*RequiresNullTerminator=*/true,
/*IsVolatile=*/true);
if (!ModuleOrErr)
return ModuleOrErr.getError();