Skip to content

Commit 1733014

Browse files
committed
[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
1 parent 8dd08e7 commit 1733014

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,15 @@ std::error_code SerializedModuleLoaderBase::openModuleFile(
337337
}
338338

339339
// Actually load the file and error out if necessary.
340+
//
341+
// Use the default arguments except for IsVolatile. Force avoiding the use of
342+
// mmap to workaround issues on NFS when the swiftmodule file loaded changes
343+
// on disk while it's in use.
340344
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ModuleOrErr =
341-
FS.getBufferForFile(ModulePath);
345+
FS.getBufferForFile(ModulePath,
346+
/*FileSize=*/-1,
347+
/*RequiresNullTerminator=*/true,
348+
/*IsVolatile=*/true);
342349
if (!ModuleOrErr)
343350
return ModuleOrErr.getError();
344351

0 commit comments

Comments
 (0)