[llvm] 5185705 - [CMake] Don't exclude llvm-debuginfod if httplib isn't available
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 12:29:49 PDT 2023
Author: Petr Hosek
Date: 2023-07-14T19:29:28Z
New Revision: 51857058ffa48265a8350fac574c88c0aa0d46f2
URL: https://github.com/llvm/llvm-project/commit/51857058ffa48265a8350fac574c88c0aa0d46f2
DIFF: https://github.com/llvm/llvm-project/commit/51857058ffa48265a8350fac574c88c0aa0d46f2.diff
LOG: [CMake] Don't exclude llvm-debuginfod if httplib isn't available
This will result in a tool that's not usable, but it'll still link
correctly rather than failing with a CMake error. This matches what
we do for other tools that have dependencies such as llvm-mt.
Differential Revision: https://reviews.llvm.org/D155323
Added:
Modified:
llvm/include/llvm/Debuginfod/HTTPServer.h
llvm/lib/Debuginfod/HTTPServer.cpp
llvm/tools/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/include/llvm/Debuginfod/HTTPServer.h b/llvm/include/llvm/Debuginfod/HTTPServer.h
index 15e611ec546f8c..c200089200ab78 100644
--- a/llvm/include/llvm/Debuginfod/HTTPServer.h
+++ b/llvm/include/llvm/Debuginfod/HTTPServer.h
@@ -34,6 +34,16 @@ struct HTTPResponse;
struct StreamingHTTPResponse;
class HTTPServer;
+class HTTPServerError : public ErrorInfo<HTTPServerError, ECError> {
+public:
+ static char ID;
+ HTTPServerError(const Twine &Msg);
+ void log(raw_ostream &OS) const override;
+
+private:
+ std::string Msg;
+};
+
class HTTPServerRequest {
friend HTTPServer;
diff --git a/llvm/lib/Debuginfod/HTTPServer.cpp b/llvm/lib/Debuginfod/HTTPServer.cpp
index 2ea923d5a734c2..a5e992254ead5a 100644
--- a/llvm/lib/Debuginfod/HTTPServer.cpp
+++ b/llvm/lib/Debuginfod/HTTPServer.cpp
@@ -28,6 +28,12 @@
using namespace llvm;
+char HTTPServerError::ID = 0;
+
+HTTPServerError::HTTPServerError(const Twine &Msg) : Msg(Msg.str()) {}
+
+void HTTPServerError::log(raw_ostream &OS) const { OS << Msg; }
+
bool llvm::streamFile(HTTPServerRequest &Request, StringRef FilePath) {
Expected<sys::fs::file_t> FDOrErr = sys::fs::openNativeFileForRead(FilePath);
if (Error Err = FDOrErr.takeError()) {
@@ -159,31 +165,34 @@ HTTPServer::HTTPServer() = default;
HTTPServer::~HTTPServer() = default;
void HTTPServerRequest::setResponse(HTTPResponse Response) {
- llvm_unreachable("No HTTP server implementation available");
+ llvm_unreachable("no httplib");
}
void HTTPServerRequest::setResponse(StreamingHTTPResponse Response) {
- llvm_unreachable("No HTTP server implementation available");
+ llvm_unreachable("no httplib");
}
Error HTTPServer::get(StringRef UrlPathPattern, HTTPRequestHandler Handler) {
- llvm_unreachable("No HTTP server implementation available");
+ // TODO(https://github.com/llvm/llvm-project/issues/63873) We would ideally
+ // return an error as well but that's going to require refactoring of error
+ // handling in DebuginfodServer.
+ return Error::success();
}
Error HTTPServer::bind(unsigned ListenPort, const char *HostInterface) {
- llvm_unreachable("No HTTP server implementation available");
+ return make_error<HTTPServerError>("no httplib");
}
Expected<unsigned> HTTPServer::bind(const char *HostInterface) {
- llvm_unreachable("No HTTP server implementation available");
+ return make_error<HTTPServerError>("no httplib");
}
Error HTTPServer::listen() {
- llvm_unreachable("No HTTP server implementation available");
+ return make_error<HTTPServerError>("no httplib");
}
void HTTPServer::stop() {
- llvm_unreachable("No HTTP server implementation available");
+ llvm_unreachable("no httplib");
}
#endif // LLVM_ENABLE_HTTPLIB
diff --git a/llvm/tools/CMakeLists.txt b/llvm/tools/CMakeLists.txt
index 2113b6a33e9026..c6116ac81d12b2 100644
--- a/llvm/tools/CMakeLists.txt
+++ b/llvm/tools/CMakeLists.txt
@@ -21,10 +21,6 @@ if(CYGWIN OR NOT LLVM_ENABLE_PIC)
set(LLVM_TOOL_LTO_BUILD Off)
endif()
-if(NOT LLVM_ENABLE_HTTPLIB)
- set(LLVM_TOOL_LLVM_DEBUGINFOD_BUILD Off)
-endif()
-
if (LLVM_TOOL_LLVM_DRIVER_BUILD)
add_llvm_tool(llvm-driver)
endif()
More information about the llvm-commits
mailing list