[llvm] Move libSupportHTTP to top-level libHTTP (NFC) (#191202)

The HTTP implementation depends on CURL and would preferably not be part
of the LLVM dylib. This was not possible as a nested library under
libSupport, because libSupport itself is part of the LLVM dylib. This
patch moves the HTTP code into a separate top-level library that is
independent from libSupport and excluded from the LLVM dylib.
This commit is contained in:
Stefan Gränitz
2026-04-15 10:38:53 +02:00
committed by GitHub
parent 738ead2c73
commit 789f30c73e
35 changed files with 75 additions and 90 deletions

View File

@@ -18,9 +18,7 @@ add_lldb_library(lldbPluginSymbolLocatorDebuginfod PLUGIN
lldbHost
lldbSymbol
LLVMDebuginfod
LINK_COMPONENTS
SupportHTTP
LLVMHTTP
)
add_dependencies(lldbPluginSymbolLocatorDebuginfod

View File

@@ -15,7 +15,7 @@
#include "lldb/Utility/Log.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/Support/HTTP/HTTPClient.h"
#include "llvm/HTTP/HTTPClient.h"
using namespace lldb;
using namespace lldb_private;

View File

@@ -13,9 +13,7 @@ add_lldb_library(lldbPluginSymbolLocatorSymStore PLUGIN
lldbCore
lldbHost
lldbSymbol
LINK_COMPONENTS
SupportHTTP
LLVMHTTP
)
add_dependencies(lldbPluginSymbolLocatorSymStore

View File

@@ -18,12 +18,12 @@
#include "lldb/Utility/UUID.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/HTTP/StreamedHTTPResponseHandler.h"
#include "llvm/Support/Caching.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/HTTP/HTTPClient.h"
#include "llvm/Support/HTTP/StreamedHTTPResponseHandler.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"

View File

@@ -22,9 +22,9 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/HTTP/HTTPServer.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"

View File

@@ -12,8 +12,8 @@
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_HTTP_HTTPCLIENT_H
#define LLVM_SUPPORT_HTTP_HTTPCLIENT_H
#ifndef LLVM_HTTP_HTTPCLIENT_H
#define LLVM_HTTP_HTTPCLIENT_H
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
@@ -85,4 +85,4 @@ public:
} // end namespace llvm
#endif // LLVM_SUPPORT_HTTP_HTTPCLIENT_H
#endif // LLVM_HTTP_HTTPCLIENT_H

View File

@@ -13,8 +13,8 @@
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_HTTP_HTTPSERVER_H
#define LLVM_SUPPORT_HTTP_HTTPSERVER_H
#ifndef LLVM_HTTP_HTTPSERVER_H
#define LLVM_HTTP_HTTPSERVER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
@@ -130,4 +130,4 @@ public:
};
} // end namespace llvm
#endif // LLVM_SUPPORT_HTTP_HTTPSERVER_H
#endif // LLVM_HTTP_HTTPSERVER_H

View File

@@ -11,12 +11,12 @@
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
#define LLVM_SUPPORT_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
#ifndef LLVM_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
#define LLVM_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/Support/Caching.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/HTTP/HTTPClient.h"
#include <functional>
#include <memory>
@@ -46,4 +46,4 @@ public:
} // end namespace llvm
#endif // LLVM_SUPPORT_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
#endif // LLVM_HTTP_STREAMEDHTTPRESPONSEHANDLER_H

View File

@@ -32,6 +32,7 @@ add_subdirectory(Object)
add_subdirectory(ObjectYAML)
add_subdirectory(Option)
add_subdirectory(Remarks)
add_subdirectory(HTTP)
add_subdirectory(Debuginfod)
add_subdirectory(DebugInfo)
add_subdirectory(DWARFCFIChecker)

View File

@@ -14,10 +14,10 @@ add_llvm_library(LLVMDebuginfod
LINK_LIBS
${imported_libs}
LLVMHTTP
LINK_COMPONENTS
Support
SupportHTTP
Symbolize
DebugInfoDWARF
BinaryFormat

View File

@@ -27,6 +27,8 @@
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/HTTP/StreamedHTTPResponseHandler.h"
#include "llvm/Object/BuildID.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Support/CachePruning.h"
@@ -34,8 +36,6 @@
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/HTTP/HTTPClient.h"
#include "llvm/Support/HTTP/StreamedHTTPResponseHandler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ThreadPool.h"

View File

@@ -1,26 +1,27 @@
# 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()
# Use WinHTTP on Windows
if (WIN32)
set(imported_libs ${imported_libs} winhttp.lib)
endif()
add_llvm_component_library(LLVMSupportHTTP
HTTPClient.cpp
HTTPServer.cpp
StreamedHTTPResponseHandler.cpp
LINK_LIBS
${imported_libs}
LINK_COMPONENTS
Support
)
# 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()
# Use WinHTTP on Windows
if (WIN32)
set(imported_libs ${imported_libs} winhttp.lib)
endif()
# This is no component library so the LLVM dylib does not gain a dependency on curl
add_llvm_library(LLVMHTTP
HTTPClient.cpp
HTTPServer.cpp
StreamedHTTPResponseHandler.cpp
LINK_LIBS
${imported_libs}
LINK_COMPONENTS
Support
)

View File

@@ -12,7 +12,7 @@
///
//===----------------------------------------------------------------------===//
#include "llvm/Support/HTTP/HTTPClient.h"
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/StringRef.h"

View File

@@ -13,7 +13,7 @@
///
//===----------------------------------------------------------------------===//
#include "llvm/Support/HTTP/HTTPServer.h"
#include "llvm/HTTP/HTTPServer.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"

View File

@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/HTTP/StreamedHTTPResponseHandler.h"
#include "llvm/HTTP/StreamedHTTPResponseHandler.h"
namespace llvm {

View File

@@ -138,7 +138,6 @@ if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
endif()
add_subdirectory(BLAKE3)
add_subdirectory(HTTP)
add_llvm_component_library(LLVMSupport
ABIBreak.cpp

View File

@@ -1,7 +1,6 @@
set(LLVM_LINK_COMPONENTS
Core
Support
SupportHTTP
Object
Coverage
ProfileData
@@ -23,4 +22,4 @@ add_llvm_tool(llvm-cov
TestingSupport.cpp
)
target_link_libraries(llvm-cov PRIVATE LLVMDebuginfod)
target_link_libraries(llvm-cov PRIVATE LLVMHTTP LLVMDebuginfod)

View File

@@ -24,13 +24,13 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Debuginfod/BuildIDFetcher.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/HTTP/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"

View File

@@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS
Option
Object
Support
SupportHTTP
)
set(LLVM_TARGET_DEFINITIONS Opts.td)
tablegen(LLVM Opts.inc -gen-opt-parser-defs)
@@ -14,8 +13,9 @@ add_llvm_tool(llvm-debuginfod-find
DebugInfodFindOptsTableGen
GENERATE_DRIVER
)
if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
target_link_libraries(llvm-debuginfod-find PRIVATE LLVMDebuginfod)
target_link_libraries(llvm-debuginfod-find PRIVATE LLVMDebuginfod LLVMHTTP)
endif()
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(debuginfod-find llvm-debuginfod-find)

View File

@@ -19,10 +19,10 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Debuginfod/BuildIDFetcher.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/HTTP/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"

View File

@@ -1,7 +1,6 @@
set(LLVM_LINK_COMPONENTS
Option
Support
SupportHTTP
)
set(LLVM_TARGET_DEFINITIONS Opts.td)
tablegen(LLVM Opts.inc -gen-opt-parser-defs)
@@ -16,7 +15,7 @@ add_llvm_tool(llvm-debuginfod
)
if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
target_link_libraries(llvm-debuginfod PRIVATE LLVMDebuginfod)
target_link_libraries(llvm-debuginfod PRIVATE LLVMDebuginfod LLVMHTTP)
endif()
if(LLVM_INSTALL_BINUTILS_SYMLINKS)

View File

@@ -18,10 +18,10 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/HTTP/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"

View File

@@ -12,7 +12,6 @@ set(LLVM_LINK_COMPONENTS
Object
Option
Support
SupportHTTP
Symbolize
TargetParser
)
@@ -42,7 +41,7 @@ add_llvm_tool(llvm-objdump
)
if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
target_link_libraries(llvm-objdump PRIVATE LLVMDebuginfod)
target_link_libraries(llvm-objdump PRIVATE LLVMDebuginfod LLVMHTTP)
endif()
add_llvm_tool_symlink(llvm-otool llvm-objdump)

View File

@@ -35,6 +35,7 @@
#include "llvm/Debuginfod/BuildIDFetcher.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler/MCRelocationInfo.h"
@@ -65,7 +66,6 @@
#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"

View File

@@ -3,7 +3,6 @@ set(LLVM_LINK_COMPONENTS
Object
ProfileData
Support
SupportHTTP
)
add_llvm_tool(llvm-profdata
@@ -13,4 +12,4 @@ add_llvm_tool(llvm-profdata
intrinsics_gen
)
target_link_libraries(llvm-profdata PRIVATE LLVMDebuginfod)
target_link_libraries(llvm-profdata PRIVATE LLVMDebuginfod LLVMHTTP)

View File

@@ -14,6 +14,7 @@
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Object/Binary.h"
#include "llvm/ProfileData/DataAccessProf.h"
@@ -34,7 +35,6 @@
#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"

View File

@@ -12,7 +12,6 @@ set(LLVM_LINK_COMPONENTS
Object
Option
Support
SupportHTTP
Symbolize
)
@@ -25,7 +24,7 @@ add_llvm_tool(llvm-symbolizer
)
if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
target_link_libraries(llvm-symbolizer PRIVATE LLVMDebuginfod)
target_link_libraries(llvm-symbolizer PRIVATE LLVMDebuginfod LLVMHTTP)
endif()
add_llvm_tool_symlink(llvm-addr2line llvm-symbolizer)

View File

@@ -25,6 +25,7 @@
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
#include "llvm/Debuginfod/BuildIDFetcher.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
@@ -33,7 +34,6 @@
#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"

View File

@@ -45,6 +45,7 @@ add_subdirectory(ExecutionEngine)
add_subdirectory(FileCheck)
add_subdirectory(Frontend)
add_subdirectory(FuzzMutate)
add_subdirectory(HTTP)
add_subdirectory(InterfaceStub)
add_subdirectory(IR)
add_subdirectory(LineEditor)

View File

@@ -1,7 +1,3 @@
set(LLVM_LINK_COMPONENTS
SupportHTTP
)
add_llvm_unittest(DebuginfodTests
DebuginfodTests.cpp
)

View File

@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/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"

View File

@@ -0,0 +1,8 @@
add_llvm_unittest(HTTPTests
HTTPServerTests.cpp
)
target_link_libraries(HTTPTests PRIVATE
LLVMHTTP
LLVMTestingSupport
)

View File

@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/StringExtras.h"
#include "llvm/HTTP/HTTPClient.h"
#include "llvm/HTTP/HTTPServer.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/HTTP/HTTPClient.h"
#include "llvm/Support/HTTP/HTTPServer.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Testing/Support/Error.h"
#include "gmock/gmock.h"

View File

@@ -128,7 +128,6 @@ add_llvm_unittest(SupportTests
intrinsics_gen
)
add_subdirectory(HTTP)
add_subdirectory(LSP)
target_link_libraries(SupportTests PRIVATE LLVMTestingSupport)

View File

@@ -1,11 +0,0 @@
set(LLVM_LINK_COMPONENTS
SupportHTTP
)
add_llvm_unittest(SupportHTTPTests
HTTPServerTests.cpp
)
target_link_libraries(SupportHTTPTests PRIVATE
LLVMTestingSupport
)