-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use volatile filesystem on Windows #453
Conversation
Thanks for looking into the issue! It is probably #235 (CC @Riatre)
To expand this topic a bit, // lib/Frontend/FrontendAction.cpp#L673
if (!CI.hasSourceManager())
CI.createSourceManager(CI.getFileManager());
// lib/Frontend/CompilerInstance.cpp
void CompilerInstance::createSourceManager(FileManager &FileMgr) {
SourceMgr = new SourceManager(getDiagnostics(), FileMgr); // third arg defaults to false
}
I don't use Windows and am not clear what Windows does. If my understanding is correct, we need a fix similar to d487120. That commit fixed sema_manager.cc (was
If you can reliably reproduce this issue. Would you mind trying the following patch? diff --git i/src/indexer.cc w/src/indexer.cc
index 280e3c4d..69eb7291 100644
--- i/src/indexer.cc
+++ w/src/indexer.cc
@@ -1263,6 +1263,8 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
Clang->setVirtualFileSystem(FS);
Clang->createFileManager();
#endif
+ Clang->setSourceManager(new SourceManager(Clang->getDiagnostics(),
+ Clang->getFileManager(), true));
IndexParam param(*vfs, no_linkage);
auto DataConsumer = std::make_shared<IndexDataConsumer>(param);
clangd doesn't seem to call setSourceManager(). In addition,
It may very unlikely cause an issue, though. |
That is great, thanks! I was looking at the best way to set As for precompiled headers: I did see that clangd makes an exception for them but I don't think there is any valid rationale for us to do the same. Your patch fixes write locks, especially after saving the file, and so precompiled shouldn't cause any problems. I have updated my pull request but feel free to close and push whatever you think is best. You are more familiar with this than me but I will be very happy to see this resolved. |
@Crunkle Can you confirm that without the fix, you'll see issues like #235?
Can you elaborate the exception?
|
Yes, without the fix I have various issues all somehow related to acquiring a write lock. Similarly, I have no issues with the fix and the debugger shows all is working correctly with no memory maps.
See clangd's FSProvider.cpp:39. This is the check to skip generated premables as they are building them themselves. That may be more optimal but I do not think it is necessary to do so. Also note clang's Basic/SourceManager.cpp:137. |
When Clang loads up the files required for indexing it memory maps any source files over a specific threshold. This is fine for Unix, but the strict file locking policies on Windows cause issues especially when an IDE saves the file and triggers a
textDocument/didSave
. If the file is re-saved before the previous indexing has complete, the save will fail and often produce various ambiguous errors.I have been using this for a month and I believe clangd has something very similar implemented. No issues so far, even on very large source files, so I want to merge if possible.