https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/184572
From 893d163cee49b9f12d7091e7497874c0ed3b04e8 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea <[email protected]> Date: Thu, 19 Feb 2026 10:22:26 -0500 Subject: [PATCH 1/9] Move HTTP client/server to new LLVMSupportHTTP Relocate HTTPClient and HTTPServer from the Debuginfod library to llvm/Support/HTTP so they can be reused by other components. --- llvm/include/llvm/Debuginfod/Debuginfod.h | 3 +-- .../{Debuginfod => Support/HTTP}/HTTPClient.h | 4 +--- .../{Debuginfod => Support/HTTP}/HTTPServer.h | 0 llvm/lib/Debuginfod/CMakeLists.txt | 13 +---------- llvm/lib/Debuginfod/Debuginfod.cpp | 2 +- llvm/lib/Support/CMakeLists.txt | 1 + llvm/lib/Support/HTTP/CMakeLists.txt | 23 +++++++++++++++++++ .../HTTP}/HTTPClient.cpp | 3 ++- .../HTTP}/HTTPServer.cpp | 3 ++- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- .../llvm-debuginfod-find.cpp | 2 +- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-objdump/llvm-objdump.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp | 2 +- .../tools/llvm-symbolizer/llvm-symbolizer.cpp | 2 +- 15 files changed, 38 insertions(+), 26 deletions(-) rename llvm/include/llvm/{Debuginfod => Support/HTTP}/HTTPClient.h (97%) rename llvm/include/llvm/{Debuginfod => Support/HTTP}/HTTPServer.h (100%) create mode 100644 llvm/lib/Support/HTTP/CMakeLists.txt rename llvm/lib/{Debuginfod => Support/HTTP}/HTTPClient.cpp (99%) rename llvm/lib/{Debuginfod => Support/HTTP}/HTTPServer.cpp (99%) 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 97% rename from llvm/include/llvm/Debuginfod/HTTPClient.h rename to llvm/include/llvm/Support/HTTP/HTTPClient.h index 6ded55502f055..06331b67197b1 100644 --- a/llvm/include/llvm/Debuginfod/HTTPClient.h +++ b/llvm/include/llvm/Support/HTTP/HTTPClient.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(); diff --git a/llvm/include/llvm/Debuginfod/HTTPServer.h b/llvm/include/llvm/Support/HTTP/HTTPServer.h similarity index 100% rename from llvm/include/llvm/Debuginfod/HTTPServer.h rename to llvm/include/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..46fcbd2bd17c6 --- /dev/null +++ b/llvm/lib/Support/HTTP/CMakeLists.txt @@ -0,0 +1,23 @@ +# 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 + + ADDITIONAL_HEADER_DIRS + ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/HTTP + + LINK_LIBS + ${imported_libs} + + LINK_COMPONENTS + Support +) \ No newline at end of file diff --git a/llvm/lib/Debuginfod/HTTPClient.cpp b/llvm/lib/Support/HTTP/HTTPClient.cpp similarity index 99% rename from llvm/lib/Debuginfod/HTTPClient.cpp rename to llvm/lib/Support/HTTP/HTTPClient.cpp index 4cca250746a59..d81c7e33259cc 100644 --- a/llvm/lib/Debuginfod/HTTPClient.cpp +++ b/llvm/lib/Support/HTTP/HTTPClient.cpp @@ -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 99% rename from llvm/lib/Debuginfod/HTTPServer.cpp rename to llvm/lib/Support/HTTP/HTTPServer.cpp index 1264353ce4b33..8138086aa23da 100644 --- a/llvm/lib/Debuginfod/HTTPServer.cpp +++ b/llvm/lib/Support/HTTP/HTTPServer.cpp @@ -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" 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" From 1e75bfed29cb9e48ceb3ff95a592bbe7362323e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 09:54:13 +0100 Subject: [PATCH 2/9] Fix file headers --- llvm/include/llvm/Support/HTTP/HTTPClient.h | 2 +- llvm/include/llvm/Support/HTTP/HTTPServer.h | 2 +- llvm/lib/Support/HTTP/HTTPClient.cpp | 2 +- llvm/lib/Support/HTTP/HTTPServer.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/Support/HTTP/HTTPClient.h b/llvm/include/llvm/Support/HTTP/HTTPClient.h index 06331b67197b1..b05a625ea106e 100644 --- a/llvm/include/llvm/Support/HTTP/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. diff --git a/llvm/include/llvm/Support/HTTP/HTTPServer.h b/llvm/include/llvm/Support/HTTP/HTTPServer.h index c200089200ab7..b71606433b888 100644 --- a/llvm/include/llvm/Support/HTTP/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. diff --git a/llvm/lib/Support/HTTP/HTTPClient.cpp b/llvm/lib/Support/HTTP/HTTPClient.cpp index d81c7e33259cc..97c2fb77ca1b9 100644 --- a/llvm/lib/Support/HTTP/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. diff --git a/llvm/lib/Support/HTTP/HTTPServer.cpp b/llvm/lib/Support/HTTP/HTTPServer.cpp index 8138086aa23da..8cd5ea99c2cee 100644 --- a/llvm/lib/Support/HTTP/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. From 2356629e522b2f2539e37a5ffff5cdd7f704941a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 10:16:13 +0100 Subject: [PATCH 3/9] Fix include guards --- llvm/include/llvm/Support/HTTP/HTTPClient.h | 6 +++--- llvm/include/llvm/Support/HTTP/HTTPServer.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/Support/HTTP/HTTPClient.h b/llvm/include/llvm/Support/HTTP/HTTPClient.h index b05a625ea106e..6fcdabf28bc02 100644 --- a/llvm/include/llvm/Support/HTTP/HTTPClient.h +++ b/llvm/include/llvm/Support/HTTP/HTTPClient.h @@ -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" @@ -83,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/Support/HTTP/HTTPServer.h b/llvm/include/llvm/Support/HTTP/HTTPServer.h index b71606433b888..101ca0e6fbd6b 100644 --- a/llvm/include/llvm/Support/HTTP/HTTPServer.h +++ b/llvm/include/llvm/Support/HTTP/HTTPServer.h @@ -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 From 34a46defbed10a6b2fceabbcafaaa8d38e0cc833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 10:19:54 +0100 Subject: [PATCH 4/9] Fix formatting --- llvm/lib/Support/HTTP/HTTPServer.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Support/HTTP/HTTPServer.cpp b/llvm/lib/Support/HTTP/HTTPServer.cpp index 8cd5ea99c2cee..c6fd49f7ee623 100644 --- a/llvm/lib/Support/HTTP/HTTPServer.cpp +++ b/llvm/lib/Support/HTTP/HTTPServer.cpp @@ -188,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 From d033b5da6409bb0b8f95897c17ff16e797a7458c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 09:39:45 +0100 Subject: [PATCH 5/9] Fix SupportHTTP CMake --- llvm/lib/Support/HTTP/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/llvm/lib/Support/HTTP/CMakeLists.txt b/llvm/lib/Support/HTTP/CMakeLists.txt index 46fcbd2bd17c6..996da4f52cb04 100644 --- a/llvm/lib/Support/HTTP/CMakeLists.txt +++ b/llvm/lib/Support/HTTP/CMakeLists.txt @@ -12,12 +12,9 @@ add_llvm_library(LLVMSupportHTTP HTTPClient.cpp HTTPServer.cpp - ADDITIONAL_HEADER_DIRS - ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/HTTP - LINK_LIBS ${imported_libs} LINK_COMPONENTS Support -) \ No newline at end of file +) From c4653eee98e0f3113a8cd71656ab1aecc9377e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 10:50:20 +0100 Subject: [PATCH 6/9] Fix unit tests --- llvm/unittests/Debuginfod/CMakeLists.txt | 2 +- llvm/unittests/Debuginfod/DebuginfodTests.cpp | 4 ++-- llvm/unittests/Support/CMakeLists.txt | 1 + llvm/unittests/Support/HTTP/CMakeLists.txt | 8 ++++++++ .../{Debuginfod => Support/HTTP}/HTTPServerTests.cpp | 6 +++--- 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 llvm/unittests/Support/HTTP/CMakeLists.txt rename llvm/unittests/{Debuginfod => Support/HTTP}/HTTPServerTests.cpp (98%) diff --git a/llvm/unittests/Debuginfod/CMakeLists.txt b/llvm/unittests/Debuginfod/CMakeLists.txt index 9b084ff33f3b7..4ac75c0720e89 100644 --- a/llvm/unittests/Debuginfod/CMakeLists.txt +++ b/llvm/unittests/Debuginfod/CMakeLists.txt @@ -1,9 +1,9 @@ add_llvm_unittest(DebuginfodTests - HTTPServerTests.cpp DebuginfodTests.cpp ) target_link_libraries(DebuginfodTests PRIVATE LLVMDebuginfod + LLVMSupportHTTP LLVMTestingSupport ) diff --git a/llvm/unittests/Debuginfod/DebuginfodTests.cpp b/llvm/unittests/Debuginfod/DebuginfodTests.cpp index 5312912599e93..a5bceb136d7b9 100644 --- a/llvm/unittests/Debuginfod/DebuginfodTests.cpp +++ b/llvm/unittests/Debuginfod/DebuginfodTests.cpp @@ -1,4 +1,4 @@ -//===-- llvm/unittest/Support/DebuginfodTests.cpp - unit tests ------------===// +//===--- DebuginfodTests.cpp - unit tests ---------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Debuginfod/Debuginfod.h" -#include "llvm/Debuginfod/HTTPClient.h" +#include "llvm/Support/HTTP/HTTPClient.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Testing/Support/Error.h" diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt index a8bf96bbe096f..a291f17331ff3 100644 --- a/llvm/unittests/Support/CMakeLists.txt +++ b/llvm/unittests/Support/CMakeLists.txt @@ -128,6 +128,7 @@ add_llvm_unittest(SupportTests intrinsics_gen ) +add_subdirectory(HTTP) add_subdirectory(LSP) target_link_libraries(SupportTests PRIVATE LLVMTestingSupport) diff --git a/llvm/unittests/Support/HTTP/CMakeLists.txt b/llvm/unittests/Support/HTTP/CMakeLists.txt new file mode 100644 index 0000000000000..59e2393bfae06 --- /dev/null +++ b/llvm/unittests/Support/HTTP/CMakeLists.txt @@ -0,0 +1,8 @@ +add_llvm_unittest(SupportHTTPTests + HTTPServerTests.cpp + ) + +target_link_libraries(SupportHTTPTests PRIVATE + LLVMSupportHTTP + LLVMTestingSupport + ) diff --git a/llvm/unittests/Debuginfod/HTTPServerTests.cpp b/llvm/unittests/Support/HTTP/HTTPServerTests.cpp similarity index 98% rename from llvm/unittests/Debuginfod/HTTPServerTests.cpp rename to llvm/unittests/Support/HTTP/HTTPServerTests.cpp index cd1d5f2d9fc70..6c06ddf5e483c 100644 --- a/llvm/unittests/Debuginfod/HTTPServerTests.cpp +++ b/llvm/unittests/Support/HTTP/HTTPServerTests.cpp @@ -1,4 +1,4 @@ -//===-- llvm/unittest/Support/HTTPServer.cpp - unit tests -------*- C++ -*-===// +//===-- HTTPServerTests.cpp - unit tests ----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringExtras.h" -#include "llvm/Debuginfod/HTTPClient.h" -#include "llvm/Debuginfod/HTTPServer.h" +#include "llvm/Support/HTTP/HTTPClient.h" +#include "llvm/Support/HTTP/HTTPServer.h" #include "llvm/Support/Error.h" #include "llvm/Support/ThreadPool.h" #include "llvm/Testing/Support/Error.h" From 9258dc10b5ff61b9584956366e0661cc45934a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 10:55:18 +0100 Subject: [PATCH 7/9] Fix formatting --- llvm/unittests/Debuginfod/DebuginfodTests.cpp | 2 +- .../Support/HTTP/HTTPServerTests.cpp | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/llvm/unittests/Debuginfod/DebuginfodTests.cpp b/llvm/unittests/Debuginfod/DebuginfodTests.cpp index a5bceb136d7b9..2e39484e7559f 100644 --- a/llvm/unittests/Debuginfod/DebuginfodTests.cpp +++ b/llvm/unittests/Debuginfod/DebuginfodTests.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Debuginfod/Debuginfod.h" -#include "llvm/Support/HTTP/HTTPClient.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/HTTP/HTTPClient.h" #include "llvm/Support/Path.h" #include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/Support/HTTP/HTTPServerTests.cpp b/llvm/unittests/Support/HTTP/HTTPServerTests.cpp index 6c06ddf5e483c..1066fdd2f7735 100644 --- a/llvm/unittests/Support/HTTP/HTTPServerTests.cpp +++ b/llvm/unittests/Support/HTTP/HTTPServerTests.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Error.h" #include "llvm/Support/HTTP/HTTPClient.h" #include "llvm/Support/HTTP/HTTPServer.h" -#include "llvm/Support/Error.h" #include "llvm/Support/ThreadPool.h" #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" @@ -237,15 +237,15 @@ TEST_F(HTTPClientServerTest, ClientTimeout) { TEST_F(HTTPClientServerTest, PathMatching) { HTTPServer Server; - EXPECT_THAT_ERROR( - Server.get(R"(/abc/(.*)/(.*))", - [&](HTTPServerRequest &Request) { - EXPECT_EQ(Request.UrlPath, "/abc/1/2"); - ASSERT_THAT(Request.UrlPathMatches, - testing::ElementsAre("1", "2")); - Request.setResponse({200u, "text/plain", Request.UrlPath}); - }), - Succeeded()); + EXPECT_THAT_ERROR(Server.get(R"(/abc/(.*)/(.*))", + [&](HTTPServerRequest &Request) { + EXPECT_EQ(Request.UrlPath, "/abc/1/2"); + ASSERT_THAT(Request.UrlPathMatches, + testing::ElementsAre("1", "2")); + Request.setResponse( + {200u, "text/plain", Request.UrlPath}); + }), + Succeeded()); EXPECT_THAT_ERROR(Server.get(UrlPathPattern, [&](HTTPServerRequest &Request) { llvm_unreachable( From fbc6e5704373e1f4d0b28afd5250679c04a43d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 11:38:17 +0100 Subject: [PATCH 8/9] Use ManagedStatic for CURL global static cleanup Necessary because LLVMSupport is built with `-Werror=global-constructors` on some platforms --- llvm/lib/Support/HTTP/HTTPClient.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Support/HTTP/HTTPClient.cpp b/llvm/lib/Support/HTTP/HTTPClient.cpp index 97c2fb77ca1b9..6301f86da4086 100644 --- a/llvm/lib/Support/HTTP/HTTPClient.cpp +++ b/llvm/lib/Support/HTTP/HTTPClient.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #ifdef LLVM_ENABLE_CURL #include <curl/curl.h> @@ -40,7 +41,7 @@ class HTTPClientCleanup { public: ~HTTPClientCleanup() { HTTPClient::cleanup(); } }; -static const HTTPClientCleanup Cleanup; +ManagedStatic<HTTPClientCleanup> Cleanup; #ifdef LLVM_ENABLE_CURL From b953a9072b3a09714d5defb952cb7012b883788b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> Date: Wed, 4 Mar 2026 11:40:03 +0100 Subject: [PATCH 9/9] Fix two more details --- .../SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp | 2 +- llvm/include/llvm/Support/HTTP/HTTPClient.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp index a09bb356e3a8c..14f5a6cbc8fa8 100644 --- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp +++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp @@ -15,7 +15,7 @@ #include "lldb/Utility/Log.h" #include "llvm/Debuginfod/Debuginfod.h" -#include "llvm/Debuginfod/HTTPClient.h" +#include "llvm/Support/HTTP/HTTPClient.h" using namespace lldb; using namespace lldb_private; diff --git a/llvm/include/llvm/Support/HTTP/HTTPClient.h b/llvm/include/llvm/Support/HTTP/HTTPClient.h index 6fcdabf28bc02..765594d21dfed 100644 --- a/llvm/include/llvm/Support/HTTP/HTTPClient.h +++ b/llvm/include/llvm/Support/HTTP/HTTPClient.h @@ -51,7 +51,9 @@ class HTTPResponseHandler { /// A reusable client that can perform HTTPRequests through a network socket. class HTTPClient { - void *Handle = nullptr; +#ifdef LLVM_ENABLE_CURL + void *Curl = nullptr; +#endif public: HTTPClient(); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
