Front-end: add an option to not lock interface file when building module

This could help fix a flaky test.

Related to: rdar://58578342
This commit is contained in:
Xi Ge
2020-02-25 11:11:31 -08:00
parent 853c0f545b
commit 8c2a041822
10 changed files with 56 additions and 17 deletions

View File

@@ -390,7 +390,15 @@ bool ModuleInterfaceBuilder::buildSwiftModule(StringRef OutPath,
bool ShouldSerializeDeps,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
llvm::function_ref<void()> RemarkRebuild) {
auto build = [&]() {
if (RemarkRebuild) {
RemarkRebuild();
}
return buildSwiftModuleInternal(OutPath, ShouldSerializeDeps, ModuleBuffer);
};
if (disableInterfaceFileLock) {
return build();
}
while (1) {
// Attempt to lock the interface file. Only one process is allowed to build
// module from the interface so we don't consume too much memory when multiple
@@ -412,10 +420,7 @@ bool ModuleInterfaceBuilder::buildSwiftModule(StringRef OutPath,
LLVM_FALLTHROUGH;
}
case llvm::LockFileManager::LFS_Owned: {
if (RemarkRebuild) {
RemarkRebuild();
}
return buildSwiftModuleInternal(OutPath, ShouldSerializeDeps, ModuleBuffer);
return build();
}
case llvm::LockFileManager::LFS_Shared: {
// Someone else is responsible for building the module. Wait for them to