[PATCH] D105681: [clangd] Add platform triple (host & target) to version info
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 9 01:26:56 PDT 2021
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, mstorsjo, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
Useful in logs to understand issues around some platforms we don't have much
experience with (e.g. m1, mingw)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105681
Files:
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/Features.cpp
clang-tools-extra/clangd/Features.h
clang-tools-extra/clangd/index/remote/Client.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -679,7 +679,8 @@
llvm::sys::SetInterruptFunction(&requestShutdown);
llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
OS << versionString() << "\n"
- << "Features: " << featureString() << "\n";
+ << "Features: " << featureString() << "\n"
+ << "Platform: " << platformString() << "\n";
});
const char *FlagsEnvVar = "CLANGD_FLAGS";
const char *Overview =
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===================================================================
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -74,6 +74,7 @@
grpc::ClientContext Context;
Context.AddMetadata("version", versionString());
Context.AddMetadata("features", featureString());
+ Context.AddMetadata("platform", platformString());
std::chrono::system_clock::time_point StartTime =
std::chrono::system_clock::now();
auto Deadline = StartTime + DeadlineWaitingTime;
Index: clang-tools-extra/clangd/Features.h
===================================================================
--- clang-tools-extra/clangd/Features.h
+++ clang-tools-extra/clangd/Features.h
@@ -19,6 +19,10 @@
// Returns a version string for clangd, e.g. "clangd 10.0.0"
std::string versionString();
+// Returns the platform triple for clangd, e.g. "x86_64-pc-linux-gnu"
+// May include both the host and target triple if they differ.
+std::string platformString();
+
// Returns a string describing the compile-time configuration.
// e.g. mac+debug+asan+grpc
std::string featureString();
Index: clang-tools-extra/clangd/Features.cpp
===================================================================
--- clang-tools-extra/clangd/Features.cpp
+++ clang-tools-extra/clangd/Features.cpp
@@ -9,12 +9,26 @@
#include "Features.h"
#include "clang/Basic/Version.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Host.h"
namespace clang {
namespace clangd {
std::string versionString() { return clang::getClangToolFullVersion("clangd"); }
+std::string platformString() {
+ static std::string PlatformString = []() {
+ std::string Host = llvm::sys::getProcessTriple();
+ std::string Target = llvm::sys::getDefaultTargetTriple();
+ if (Host != Target) {
+ Host += "; target=";
+ Host += Target;
+ }
+ return Host;
+ }();
+ return PlatformString;
+}
+
std::string featureString() {
return
#if defined(_WIN32)
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -619,9 +619,10 @@
llvm::json::Object Result{
{{"serverInfo",
- llvm::json::Object{{"name", "clangd"},
- {"version", llvm::formatv("{0} {1}", versionString(),
- featureString())}}},
+ llvm::json::Object{
+ {"name", "clangd"},
+ {"version", llvm::formatv("{0} {1} {2}", versionString(),
+ featureString(), platformString())}}},
{"capabilities", std::move(ServerCaps)}}};
if (Opts.Encoding)
Result["offsetEncoding"] = *Opts.Encoding;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105681.357433.patch
Type: text/x-patch
Size: 3512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210709/d44a8250/attachment.bin>
More information about the cfe-commits
mailing list