[clangd] Add platform triple (host & target) to version info
Useful in logs to understand issues around some platforms we don't have much experience with (e.g. m1, mingw) Differential Revision: https://reviews.llvm.org/D105681
This commit is contained in:
parent
cad2affb78
commit
e2559e5dc6
|
@ -619,9 +619,10 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
|
|||
|
||||
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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -19,6 +19,10 @@ namespace clangd {
|
|||
// 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();
|
||||
|
|
|
@ -74,6 +74,7 @@ class IndexClient : public clangd::SymbolIndex {
|
|||
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;
|
||||
|
|
|
@ -679,7 +679,8 @@ int main(int argc, char *argv[]) {
|
|||
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 =
|
||||
|
|
Loading…
Reference in New Issue
Block a user