Skip to content

Commit a4becda

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 7573a64 commit a4becda

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
@@ -347,8 +347,15 @@ std::error_code SerializedModuleLoaderBase::openModuleFile(
347347
}
348348

349349
// Actually load the file and error out if necessary.
350+
//
351+
// Use the default arguments except for IsVolatile. Force avoiding the use of
352+
// mmap to workaround issues on NFS when the swiftmodule file loaded changes
353+
// on disk while it's in use.
350354
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ModuleOrErr =
351-
FS.getBufferForFile(ModulePath);
355+
FS.getBufferForFile(ModulePath,
356+
/*FileSize=*/-1,
357+
/*RequiresNullTerminator=*/true,
358+
/*IsVolatile=*/true);
352359
if (!ModuleOrErr)
353360
return ModuleOrErr.getError();
354361

0 commit comments

Comments
 (0)