-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[LLVM][MLIR] Move LSP server support library from MLIR into LLVM #157885
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
Conversation
@nikic can I ask for a review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you confirmed this works with the dylib build?
) | ||
target_link_libraries(LLVMSupportLSPTests | ||
PRIVATE | ||
LLVMSupportLSP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also link as component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -12,6 +12,9 @@ llvm_add_library(TableGenLspServerLib | |||
ADDITIONAL_HEADER_DIRS | |||
${MLIR_MAIN_INCLUDE_DIR}/mlir/Tools/tblgen-lsp-server | |||
|
|||
LINK_COMPONENTS | |||
SupportLSP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add this to LLVM_LINK_COMPONENTS above to avoid mixing two styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sure, missed that
Yes, I checked that compiling with the same CMake settings as the dylib build linked all fine. |
Thanks for the approve, can you also merge this please? I don't have the permissions to do that. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/13305 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/30551 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/206/builds/6062 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/21740 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/9702 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/21091 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/24/builds/12498 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/24715 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/24855 Here is the relevant piece of the build log for the reference
|
Reverts llvm#157691 Change was relanded in llvm#157885
Reverts llvm/llvm-project#157691 Change was relanded in llvm/llvm-project#157885
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/53/builds/19913 Here is the relevant piece of the build log for the reference
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Unfortunately, according to git bisect, this change is also responsible for the following test regression:
Full logs (with CMake invocations, etc.): |
// mapping and erase it. | ||
ResponseHandlerTy ResponseHandler; | ||
{ | ||
std::lock_guard<std::mutex> responseHandlersLock(ResponseHandlerTy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bertik23 @nikic I'm seeing MSVC warnings from this line:
E:\llvm\llvm-project\llvm\lib\Support\LSP\Transport.cpp(123): warning C4930: 'std::lock_guard<std::mutex> responseHandlersLock(llvm::lsp::MessageHandler::ResponseHandlerTy)': prototyped function not called (was a variable definition intended?)
Should it be this instead?
std::lock_guard<std::mutex> responseHandlersLock(ResponseHandler);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to me running clang-tidy on that file it was
std::lock_guard<std::mutex> responseHandlersLock(ResponseHandlersMutex);
so I'd change it back to that
PR ready #158666
@Bertik23, could you help with that test regression too? |
@mgorny yes, I'm looking into it, but I was not yet able to reproduce the issue |
I can try to help (since I can reproduce it reliably), but I'd need some hints what to look at. The tests look quite opaque to me. |
@mgorny Would it be possible to get the actual output of the test by running This is a strange failure because the PR should be NFC, just moving code to a different place. Either something really got broken, or it could be some small detail, perhaps the JSON object being serialized in a different order? I checked and it uses DenseMap as storage, and AFAICT there is no guarantee about preserving insertion order. |
Isn't that the first big block in the test output? I'm pretty sure when I ran it manually, I got the same thing. I can recheck in a few minutes. |
Yep. Here's the output from a different (amd64) machine:
|
Not quite sure. I was looking lower at the last chunk which lists the FileCheck stderr, and that one says |
Ah thanks for the output. I guess only stdout is piped to filecheck, that's why the content length is not in the second chunk. |
Somehow, we started returning errors when previously there were normal results. Expected:
Actual:
|
What I really don't get is where is the input it's supposed to process (i.e. the thing missing |
This is the json that is sent to the lsp server:
and it should find the uri in the params object but somehow doesn't. Wondering if root is the top-level object or the params. But in any case, I don't understand how this patch could cause this. I must be missing something... |
Oh! I was looking for an actual Yeah, it's weird. I've checked twice, but I'll check one more time, just in case. |
It seems to me there is no actual file foo.pdll, there is instead a message that tells the server that a file foo.pdll was opened and what the contents are:
|
Shit, I'm sorry — I think I've messed up the bisect after all. |
Okay, in my defense, I didn't screw up the bisect. This is some kind nasty bug. It is triggered by this commit on arm64, but on amd64 it happens prior to that. I'll try to bisect further there, but I suspect I won't find anything meaningful either. |
I think I see a potential cause:
|
This is a second PR on this patch (first #155572), that fixes the linking problem for
flang-aarch64-dylib
test.The SupportLSP library was made a component library.
This PR moves the generic Language Server Protocol (LSP) server support code that was copied from clangd into MLIR, into the LLVM tree so it can be reused by multiple subprojects.
Centralizing the generic LSP support in LLVM lowers the barrier to building new LSP servers across the LLVM ecosystem and avoids each subproject maintaining its own copy.
The code originated in clangd and was copied into MLIR for its LSP server. MLIR had this code seperate to be reused by all of their LSP server. This PR relocates the MLIR copy into LLVM as a shared component into LLVM/Support. If this is not a suitable place, please suggest a better one.
A follow up to this move could be deduplication with the original clangd implementation and converge on a single shared LSP support library used by clangd, MLIR, and future servers.
What changes
and their namespace was changed from mlir to llvm
I ran clang-tidy --fix and clang-format on the whole moved files (last two commits), as they are basically new files and should hold up to the code style used by LLVM.
MLIR LSP servers where updated to include these files from their new location and account for the namespace change.
This PR is made as part of the LLVM IR LSP project (RFC)