[llvm] [Support] Move HTTP client/server to new LLVMSupportHTTP lib (NFC) (PR #184572)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 01:30:42 PST 2026


Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/184572 at github.com>


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-llvm-binary-utilities

Author: Stefan Gränitz (weliveindetail)

<details>
<summary>Changes</summary>

Relocate HTTPClient and HTTPServer from the Debuginfod library to llvm/Support/HTTP so they can be reused by other components.

---
Full diff: https://github.com/llvm/llvm-project/pull/184572.diff


15 Files Affected:

- (modified) llvm/include/llvm/Debuginfod/Debuginfod.h (+1-2) 
- (renamed) llvm/include/llvm/Support/HTTP/HTTPClient.h (+5-7) 
- (renamed) llvm/include/llvm/Support/HTTP/HTTPServer.h (+4-4) 
- (modified) llvm/lib/Debuginfod/CMakeLists.txt (+1-12) 
- (modified) llvm/lib/Debuginfod/Debuginfod.cpp (+1-1) 
- (modified) llvm/lib/Support/CMakeLists.txt (+1) 
- (added) llvm/lib/Support/HTTP/CMakeLists.txt (+20) 
- (renamed) llvm/lib/Support/HTTP/HTTPClient.cpp (+3-2) 
- (renamed) llvm/lib/Support/HTTP/HTTPServer.cpp (+5-8) 
- (modified) llvm/tools/llvm-cov/CodeCoverage.cpp (+1-1) 
- (modified) llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp (+1-1) 
- (modified) llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp (+1-1) 
- (modified) llvm/tools/llvm-objdump/llvm-objdump.cpp (+1-1) 
- (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+1-1) 
- (modified) llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp (+1-1) 


``````````diff
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h b/llvm/include/llvm/Debuginfod/Debuginfod.h
index 99fe15ad85979..0bdb5d3ce3882 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -20,12 +20,11 @@
 #ifndef LLVM_DEBUGINFOD_DEBUGINFOD_H
 #define LLVM_DEBUGINFOD_DEBUGINFOD_H
 
-#include "HTTPServer.h"
-
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Object/BuildID.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/HTTP/HTTPServer.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/RWMutex.h"
diff --git a/llvm/include/llvm/Debuginfod/HTTPClient.h b/llvm/include/llvm/Support/HTTP/HTTPClient.h
similarity index 91%
rename from llvm/include/llvm/Debuginfod/HTTPClient.h
rename to llvm/include/llvm/Support/HTTP/HTTPClient.h
index 6ded55502f055..6fcdabf28bc02 100644
--- a/llvm/include/llvm/Debuginfod/HTTPClient.h
+++ b/llvm/include/llvm/Support/HTTP/HTTPClient.h
@@ -1,4 +1,4 @@
-//===-- llvm/Support/HTTPClient.h - HTTP client library ---------*- C++ -*-===//
+//===--- HTTPClient.h - HTTP client library ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,8 +12,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_DEBUGINFOD_HTTPCLIENT_H
-#define LLVM_DEBUGINFOD_HTTPCLIENT_H
+#ifndef LLVM_SUPPORT_HTTP_HTTPCLIENT_H
+#define LLVM_SUPPORT_HTTP_HTTPCLIENT_H
 
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -51,9 +51,7 @@ class HTTPResponseHandler {
 
 /// A reusable client that can perform HTTPRequests through a network socket.
 class HTTPClient {
-#ifdef LLVM_ENABLE_CURL
-  void *Curl = nullptr;
-#endif
+  void *Handle = nullptr;
 
 public:
   HTTPClient();
@@ -85,4 +83,4 @@ class HTTPClient {
 
 } // end namespace llvm
 
-#endif // LLVM_DEBUGINFOD_HTTPCLIENT_H
+#endif // LLVM_SUPPORT_HTTP_HTTPCLIENT_H
diff --git a/llvm/include/llvm/Debuginfod/HTTPServer.h b/llvm/include/llvm/Support/HTTP/HTTPServer.h
similarity index 95%
rename from llvm/include/llvm/Debuginfod/HTTPServer.h
rename to llvm/include/llvm/Support/HTTP/HTTPServer.h
index c200089200ab7..101ca0e6fbd6b 100644
--- a/llvm/include/llvm/Debuginfod/HTTPServer.h
+++ b/llvm/include/llvm/Support/HTTP/HTTPServer.h
@@ -1,4 +1,4 @@
-//===-- llvm/Debuginfod/HTTPServer.h - HTTP server library ------*- C++ -*-===//
+//===--- HTTPServer.h - HTTP server library ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,8 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_DEBUGINFOD_HTTPSERVER_H
-#define LLVM_DEBUGINFOD_HTTPSERVER_H
+#ifndef LLVM_SUPPORT_HTTP_HTTPSERVER_H
+#define LLVM_SUPPORT_HTTP_HTTPSERVER_H
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -130,4 +130,4 @@ class HTTPServer {
 };
 } // end namespace llvm
 
-#endif // LLVM_DEBUGINFOD_HTTPSERVER_H
+#endif // LLVM_SUPPORT_HTTP_HTTPSERVER_H
diff --git a/llvm/lib/Debuginfod/CMakeLists.txt b/llvm/lib/Debuginfod/CMakeLists.txt
index b1329bd2d077e..c31481cc97f08 100644
--- a/llvm/lib/Debuginfod/CMakeLists.txt
+++ b/llvm/lib/Debuginfod/CMakeLists.txt
@@ -1,13 +1,3 @@
-# Link LibCURL if the user wants it
-if (LLVM_ENABLE_CURL)
-  set(imported_libs CURL::libcurl)
-endif()
-
-# Link cpp-httplib if the user wants it
-if (LLVM_ENABLE_HTTPLIB)
-  set(imported_libs ${imported_libs} httplib::httplib)
-endif()
-
 # Make sure pthread is linked if this is a unix host
 if (CMAKE_HOST_UNIX)
   set(imported_libs ${imported_libs} ${LLVM_PTHREAD_LIB})
@@ -18,8 +8,6 @@ endif()
 add_llvm_library(LLVMDebuginfod
   BuildIDFetcher.cpp
   Debuginfod.cpp
-  HTTPClient.cpp
-  HTTPServer.cpp
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Debuginfod
@@ -29,6 +17,7 @@ add_llvm_library(LLVMDebuginfod
 
   LINK_COMPONENTS
   Support
+  SupportHTTP
   Symbolize
   DebugInfoDWARF
   BinaryFormat
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 12f817c9e4bf0..6847dc092dfdb 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -27,7 +27,6 @@
 #include "llvm/BinaryFormat/Magic.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
-#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Object/BuildID.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Support/CachePruning.h"
@@ -35,6 +34,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ThreadPool.h"
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index b4e39fced3853..380be042df69d 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -135,6 +135,7 @@ if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
 endif()
 
 add_subdirectory(BLAKE3)
+add_subdirectory(HTTP)
 
 add_llvm_component_library(LLVMSupport
   ABIBreak.cpp
diff --git a/llvm/lib/Support/HTTP/CMakeLists.txt b/llvm/lib/Support/HTTP/CMakeLists.txt
new file mode 100644
index 0000000000000..996da4f52cb04
--- /dev/null
+++ b/llvm/lib/Support/HTTP/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Link LibCURL if the user wants it
+if (LLVM_ENABLE_CURL)
+  set(imported_libs CURL::libcurl)
+endif()
+
+# Link cpp-httplib if the user wants it
+if (LLVM_ENABLE_HTTPLIB)
+  set(imported_libs ${imported_libs} httplib::httplib)
+endif()
+
+add_llvm_library(LLVMSupportHTTP
+  HTTPClient.cpp
+  HTTPServer.cpp
+
+  LINK_LIBS
+  ${imported_libs}
+
+  LINK_COMPONENTS
+  Support
+)
diff --git a/llvm/lib/Debuginfod/HTTPClient.cpp b/llvm/lib/Support/HTTP/HTTPClient.cpp
similarity index 97%
rename from llvm/lib/Debuginfod/HTTPClient.cpp
rename to llvm/lib/Support/HTTP/HTTPClient.cpp
index 4cca250746a59..97c2fb77ca1b9 100644
--- a/llvm/lib/Debuginfod/HTTPClient.cpp
+++ b/llvm/lib/Support/HTTP/HTTPClient.cpp
@@ -1,4 +1,4 @@
-//===-- llvm/Debuginfod/HTTPClient.cpp - HTTP client library ----*- C++ -*-===//
+//===--- HTTPClient.cpp - HTTP client library -----------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Debuginfod/HTTPClient.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
+
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
diff --git a/llvm/lib/Debuginfod/HTTPServer.cpp b/llvm/lib/Support/HTTP/HTTPServer.cpp
similarity index 95%
rename from llvm/lib/Debuginfod/HTTPServer.cpp
rename to llvm/lib/Support/HTTP/HTTPServer.cpp
index 1264353ce4b33..c6fd49f7ee623 100644
--- a/llvm/lib/Debuginfod/HTTPServer.cpp
+++ b/llvm/lib/Support/HTTP/HTTPServer.cpp
@@ -1,4 +1,4 @@
-//===-- llvm/Debuginfod/HTTPServer.cpp - HTTP server library -----*- C++-*-===//
+//===--- HTTPServer.cpp - HTTP server library -----------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Debuginfod/HTTPServer.h"
+#include "llvm/Support/HTTP/HTTPServer.h"
+
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
@@ -187,12 +188,8 @@ Expected<unsigned> HTTPServer::bind(const char *HostInterface) {
   return make_error<HTTPServerError>("no httplib");
 }
 
-Error HTTPServer::listen() {
-  return make_error<HTTPServerError>("no httplib");
-}
+Error HTTPServer::listen() { return make_error<HTTPServerError>("no httplib"); }
 
-void HTTPServer::stop() {
-  llvm_unreachable("no httplib");
-}
+void HTTPServer::stop() { llvm_unreachable("no httplib"); }
 
 #endif // LLVM_ENABLE_HTTPLIB
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 0066d10156499..0a01ef36728d1 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -24,13 +24,13 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Debuginfod/BuildIDFetcher.h"
 #include "llvm/Debuginfod/Debuginfod.h"
-#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Object/BuildID.h"
 #include "llvm/ProfileData/Coverage/CoverageMapping.h"
 #include "llvm/ProfileData/InstrProfReader.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
diff --git a/llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp b/llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp
index 934833bf6fe42..8f1b9d0f4659d 100644
--- a/llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp
+++ b/llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp
@@ -19,10 +19,10 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Debuginfod/BuildIDFetcher.h"
 #include "llvm/Debuginfod/Debuginfod.h"
-#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/LLVMDriver.h"
 
diff --git a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
index 7b85166c1b4ae..16d95532a9edc 100644
--- a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
+++ b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
@@ -18,10 +18,10 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Debuginfod/Debuginfod.h"
-#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
 #include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/ThreadPool.h"
 
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 7981ec8f6d713..96d82754d48df 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -34,7 +34,6 @@
 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
 #include "llvm/Debuginfod/BuildIDFetcher.h"
 #include "llvm/Debuginfod/Debuginfod.h"
-#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Demangle/Demangle.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
@@ -66,6 +65,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
 #include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 74c4732ca129a..ab67d75770fee 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -14,7 +14,6 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/ProfileData/DataAccessProf.h"
@@ -35,6 +34,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MemoryBuffer.h"
diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 4784dafeb2948..7f7f17ef94750 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -25,7 +25,6 @@
 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
 #include "llvm/Debuginfod/BuildIDFetcher.h"
 #include "llvm/Debuginfod/Debuginfod.h"
-#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
@@ -34,6 +33,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
 #include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"

``````````

</details>


https://github.com/llvm/llvm-project/pull/184572


More information about the llvm-commits mailing list