From 17faa2ddff8e4b2f62656db2bcf4770c192ec850 Mon Sep 17 00:00:00 2001 From: "Sv. Lockal" Date: Thu, 6 Aug 2026 02:16:46 +0800 Subject: [PATCH] sci-ml/pytorch: unbundle dev-cpp/cpp-httplib for distributed build Link to system shared httplib instead of using bundled header-only version Closes: https://bugs.gentoo.org/980398 Signed-off-by: Sv. Lockal Part-of: https://github.com/gentoo/gentoo/pull/46650 Closes: https://github.com/gentoo/gentoo/pull/46650 Signed-off-by: Alfredo Tupone --- .../pytorch-2.13.0-unbundle_httplib.patch | 32 +++++++++++++++++++ ...3.0-r2.ebuild => pytorch-2.13.0-r3.ebuild} | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 sci-ml/pytorch/files/pytorch-2.13.0-unbundle_httplib.patch rename sci-ml/pytorch/{pytorch-2.13.0-r2.ebuild => pytorch-2.13.0-r3.ebuild} (99%) diff --git a/sci-ml/pytorch/files/pytorch-2.13.0-unbundle_httplib.patch b/sci-ml/pytorch/files/pytorch-2.13.0-unbundle_httplib.patch new file mode 100644 index 0000000000000..679973a2d23e8 --- /dev/null +++ b/sci-ml/pytorch/files/pytorch-2.13.0-unbundle_httplib.patch @@ -0,0 +1,32 @@ +Link to system shared httplib instead of using bundled header-only version + +Bug: https://bugs.gentoo.org/980398 +--- a/caffe2/CMakeLists.txt ++++ b/caffe2/CMakeLists.txt +@@ -1338,8 +1338,9 @@ if(USE_KINETO) + ${TORCH_ROOT}/third_party/kineto/libkineto/src) + endif() + +-target_include_directories(torch_cpu PRIVATE +- ${TORCH_ROOT}/third_party/cpp-httplib) ++if(USE_DISTRIBUTED) ++ target_link_libraries(torch_cpu PRIVATE httplib) ++endif() + + target_include_directories(torch_cpu PRIVATE + ${TORCH_ROOT}/third_party/nlohmann/include) +--- a/cmake/Dependencies.cmake ++++ b/cmake/Dependencies.cmake +@@ -1732,8 +1732,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/FlatBuffers.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/FlatBuffers.cmake) + + # Include cpp-httplib +-add_library(httplib INTERFACE IMPORTED) +-target_include_directories(httplib SYSTEM INTERFACE ${PROJECT_SOURCE_DIR}/third_party/cpp-httplib) ++if(USE_DISTRIBUTED) ++ find_package(httplib REQUIRED) ++ add_library(httplib ALIAS httplib::httplib) ++endif() + + # Include nlohmann-json + add_library(nlohmann INTERFACE IMPORTED) diff --git a/sci-ml/pytorch/pytorch-2.13.0-r2.ebuild b/sci-ml/pytorch/pytorch-2.13.0-r3.ebuild similarity index 99% rename from sci-ml/pytorch/pytorch-2.13.0-r2.ebuild rename to sci-ml/pytorch/pytorch-2.13.0-r3.ebuild index 3a5d5c55e69ca..54f1028a0e7d2 100644 --- a/sci-ml/pytorch/pytorch-2.13.0-r2.ebuild +++ b/sci-ml/pytorch/pytorch-2.13.0-r3.ebuild @@ -85,6 +85,7 @@ RDEPEND=" ) distributed? ( !rocm? ( sci-ml/tensorpipe[cuda?] ) + dev-cpp/cpp-httplib:= ) fbgemm? ( >=sci-ml/FBGEMM-1.4 ) gloo? ( >=sci-ml/gloo-2025.06.04[cuda?,rocm?] ) @@ -148,7 +149,6 @@ DEPEND=" dev-python/typing-extensions[${PYTHON_USEDEP}] ') cuda? ( ~dev-libs/cutlass-4.4.2[tools(+)] ) - distributed? ( dev-cpp/cpp-httplib:= ) onednn? ( sci-ml/ideep ) rocm? ( >=sci-libs/hipCUB-6.3:=