PyTorch: fix build with Apple Clang 17 (#50105)

This commit is contained in:
Adam J. Stewart 2025-04-21 09:34:16 +02:00 committed by GitHub
parent 69edcc6d2f
commit aee7455568
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,14 @@
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 1813f4418a2..77211646f34 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1151,6 +1151,9 @@ if(USE_DISTRIBUTED AND USE_TENSORPIPE)
# Tensorpipe uses cuda_add_library
torch_update_find_cuda_flags()
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/tensorpipe)
+ # Suppress warning to unblock libnop comiplation by clang-17
+ # See https://github.com/pytorch/pytorch/issues/151316
+ target_compile_options_if_supported(tensorpipe -Wno-missing-template-arg-list-after-template-kw)
list(APPEND Caffe2_DEPENDENCY_LIBS tensorpipe)
list(APPEND Caffe2_DEPENDENCY_LIBS nlohmann)

View File

@ -323,6 +323,14 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage):
conflicts("%gcc@:9.3", when="@2.2:", msg="C++17 support required")
# https://github.com/pytorch/pytorch/issues/151316
patch(
"https://github.com/pytorch/pytorch/pull/151344.patch?full_index=1",
sha256="edaadfd5f8acee67fee1c77b34145640a1239c9546d77420f3887af24889799e",
when="@2.7.0",
)
patch("apple_clang_17.patch", when="@1.12:2.6")
# https://github.com/pytorch/pytorch/issues/146239
patch(
"https://github.com/pytorch/pytorch/pull/140275.patch?full_index=1",