-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
[bazel] Add clangd as a library support #81556
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clangd Author: None (josh11b) ChangesBoth creates a This upstreams the patch that allows https://github.com/carbon-language/carbon-lang/tree/trunk/language_server to use Thanks! Full diff: https://github.com/llvm/llvm-project/pull/81556.diff 2 Files Affected:
diff --git a/clang-tools-extra/clangd/Transport.h b/clang-tools-extra/clangd/Transport.h
index 4e80ea95b8537d..f17441cfc1ef22 100644
--- a/clang-tools-extra/clangd/Transport.h
+++ b/clang-tools-extra/clangd/Transport.h
@@ -18,7 +18,6 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H
-#include "Feature.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel
new file mode 100644
index 00000000000000..0e25dd1c166560
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel
@@ -0,0 +1,45 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+cc_library(
+ name = "clangd_library",
+ srcs = [
+ "JSONTransport.cpp",
+ "Protocol.cpp",
+ "URI.cpp",
+ "index/SymbolID.cpp",
+ "support/Logger.cpp",
+ "support/Trace.cpp",
+ "support/MemoryTree.cpp",
+ "support/Context.cpp",
+ "support/Cancellation.cpp",
+ "support/ThreadCrashReporter.cpp",
+ "support/Shutdown.cpp",
+ ],
+ hdrs = [
+ "Transport.h",
+ "Protocol.h",
+ "URI.h",
+ "LSPBinder.h",
+ "index/SymbolID.h",
+ "support/Function.h",
+ "support/Cancellation.h",
+ "support/ThreadCrashReporter.h",
+ "support/Logger.h",
+ "support/Trace.h",
+ "support/MemoryTree.h",
+ "support/Context.h",
+ "support/Shutdown.h",
+ ],
+ includes = ["."],
+ deps = [
+ "//llvm:Support",
+ "//clang:basic",
+ "//clang:index",
+ ],
+)
|
|
I've made my email address public, as requested. |
Ping! |
1 similar comment
Ping! |
licenses(["notice"]) | ||
|
||
cc_library( | ||
name = "clangd_library", |
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.
clangDaemon would match the library name in clang-tools-extra/clangd/CMakeLists.txt
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.
Renamed
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.
Small nit: IIUC the convention in the llvm bzl tree is to use casing like ClangDaemon
.
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.
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
package(default_visibility = ["//visibility:public"]) |
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.
Add features = ["layering_check"],
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.
Added
llvm-project email notifications are extremely high-volume and nobody can notice every change even if they are subscribed to the relevant labels... If you don't have write/triage role (https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization#repository-roles-for-organizations), the best is to CC relevant people ( Feel free to ping the patch once a week when no feedback is received per https://llvm.org/docs/Contributing.html#how-to-submit-a-patch
|
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.
bazel-specific changes often have a title [bazel] Add clangd support
. Please consider following suit.
It would be nice to have a more complete support for clangd, but I guess having this cc_library first can make your downstream changes easier, so LGTM.
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
package(features = ["layering_check"], |
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.
llvm/BUILD.bazel places default_visibility
before features
. Best to follow its convention.
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.
clang-tools-extra/clangd/Transport.h
Outdated
@@ -18,7 +18,6 @@ | |||
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H | |||
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H | |||
|
|||
#include "Feature.h" |
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.
This change should be removed.
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.
srcs = [ | ||
"JSONTransport.cpp", | ||
"Protocol.cpp", | ||
"URI.cpp", | ||
"index/SymbolID.cpp", | ||
"support/Logger.cpp", | ||
"support/Trace.cpp", | ||
"support/MemoryTree.cpp", | ||
"support/Context.cpp", | ||
"support/Cancellation.cpp", | ||
"support/ThreadCrashReporter.cpp", | ||
"support/Shutdown.cpp", | ||
], | ||
hdrs = [ | ||
"Transport.h", | ||
"Protocol.h", | ||
"URI.h", | ||
"LSPBinder.h", | ||
"index/SymbolID.h", | ||
"support/Function.h", | ||
"support/Cancellation.h", | ||
"support/ThreadCrashReporter.h", | ||
"support/Logger.h", | ||
"support/Trace.h", | ||
"support/MemoryTree.h", | ||
"support/Context.h", | ||
"support/Shutdown.h", | ||
], |
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.
clangd/CMakeLists.txt lists many other files needed by the clangDaemon target.
I think this is totally fine to submit as-is, as maybe this is the minimal set of files that one needs for basic clangd functionality, but we should probably have a TODO to pick up other files (e.g. glob(["*.cpp", "dir/**/*.cpp", ...])
) for more complete functionality. (I'm not a clangd expert, so I'm not sure what the implication of leaving out all those other files is).
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 added a # TODO comment.
licenses(["notice"]) | ||
|
||
cc_library( | ||
name = "clangd_library", |
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.
Small nit: IIUC the convention in the llvm bzl tree is to use casing like ClangDaemon
.
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.
Thank you for the feedback!
srcs = [ | ||
"JSONTransport.cpp", | ||
"Protocol.cpp", | ||
"URI.cpp", | ||
"index/SymbolID.cpp", | ||
"support/Logger.cpp", | ||
"support/Trace.cpp", | ||
"support/MemoryTree.cpp", | ||
"support/Context.cpp", | ||
"support/Cancellation.cpp", | ||
"support/ThreadCrashReporter.cpp", | ||
"support/Shutdown.cpp", | ||
], | ||
hdrs = [ | ||
"Transport.h", | ||
"Protocol.h", | ||
"URI.h", | ||
"LSPBinder.h", | ||
"index/SymbolID.h", | ||
"support/Function.h", | ||
"support/Cancellation.h", | ||
"support/ThreadCrashReporter.h", | ||
"support/Logger.h", | ||
"support/Trace.h", | ||
"support/MemoryTree.h", | ||
"support/Context.h", | ||
"support/Shutdown.h", | ||
], |
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 added a # TODO comment.
licenses(["notice"]) | ||
|
||
cc_library( | ||
name = "clangd_library", |
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.
@josh11b Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Thanks! Sorry about the delay, we should get the bzl tree setup for automatic assignment to reviewers. |
Creates a
BUILD.bazel
file for theclangd
directory in the project overlay.This upstreams the patch that allows https://github.com/carbon-language/carbon-lang/tree/trunk/language_server to use
clangd
as a library. This was created as part of a Summer of Code project building a prototype Carbon language server. If this is not an appropriate architecture, I'm very open to alternative paths forward.Thanks!