llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Chen Miao (ChenMiaoi) <details> <summary>Changes</summary> The global module index could be generated while a module was being rebuilt because the check for .pcm.lock files never matched: sys::path::extension() returns ".lock", not ".pcm.lock". --- Full diff: https://github.com/llvm/llvm-project/pull/236360.diff 2 Files Affected: - (modified) clang/lib/Serialization/GlobalModuleIndex.cpp (+1-1) - (modified) clang/test/Modules/global_index.m (+10) ``````````diff diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp index 7ab9a3d299f64..7a154898e4b25 100644 --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -887,7 +887,7 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr, // ... unless it's a .pcm.lock file, which indicates that someone is // in the process of rebuilding a module. They'll rebuild the index // at the end of that translation unit, so we don't have to. - if (llvm::sys::path::extension(D->path()) == ".pcm.lock") + if (StringRef(D->path()).ends_with(".pcm.lock")) return llvm::createStringError(std::errc::device_or_resource_busy, "someone else is building the index"); diff --git a/clang/test/Modules/global_index.m b/clang/test/Modules/global_index.m index 3857e10c2e922..c8e2b27912d65 100644 --- a/clang/test/Modules/global_index.m +++ b/clang/test/Modules/global_index.m @@ -8,6 +8,16 @@ // Run and use the global module index // RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t/cache -fdisable-module-hash -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -print-stats 2>&1 | FileCheck %s +// Skip index generation while another module is being built. +// RUN: rm %t/cache/modules.idx +// RUN: touch %t/cache/building.pcm.lock +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t/cache -fdisable-module-hash -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: not test -e %t/cache/modules.idx +// Resume index generation once the module lock is removed. +// RUN: rm %t/cache/building.pcm.lock +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t/cache -fdisable-module-hash -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: test -f %t/cache/modules.idx + // expected-no-diagnostics @import DependsOnModule; @import Module; `````````` </details> https://github.com/llvm/llvm-project/pull/236360 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
