diff --git a/llvm/include/llvm/Support/FileCollector.h b/llvm/include/llvm/Support/FileCollector.h --- a/llvm/include/llvm/Support/FileCollector.h +++ b/llvm/include/llvm/Support/FileCollector.h @@ -69,7 +69,7 @@ addDirectoryImpl(const llvm::Twine &Dir, IntrusiveRefCntPtr FS, std::error_code &EC); - /// Synchronizes adding files. + /// Synchronizes access to Seen, VFSWriter and SymlinkMap. std::mutex Mutex; /// The root directory where files are copied. diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp --- a/llvm/lib/Support/FileCollector.cpp +++ b/llvm/lib/Support/FileCollector.cpp @@ -150,6 +150,8 @@ } std::error_code FileCollector::copyFiles(bool StopOnError) { + std::lock_guard lock(Mutex); + for (auto &entry : VFSWriter.getMappings()) { // Create directory tree. if (std::error_code EC =