From aee7455568faf14df657b393895f40eaa2561c6e Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Mon, 21 Apr 2025 09:34:16 +0200 Subject: [PATCH] PyTorch: fix build with Apple Clang 17 (#50105) --- .../builtin/packages/py-torch/apple_clang_17.patch | 14 ++++++++++++++ .../repos/builtin/packages/py-torch/package.py | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 var/spack/repos/builtin/packages/py-torch/apple_clang_17.patch diff --git a/var/spack/repos/builtin/packages/py-torch/apple_clang_17.patch b/var/spack/repos/builtin/packages/py-torch/apple_clang_17.patch new file mode 100644 index 00000000000..6983c57f7f9 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-torch/apple_clang_17.patch @@ -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) diff --git a/var/spack/repos/builtin/packages/py-torch/package.py b/var/spack/repos/builtin/packages/py-torch/package.py index 65a13d23628..698bf2fe30f 100644 --- a/var/spack/repos/builtin/packages/py-torch/package.py +++ b/var/spack/repos/builtin/packages/py-torch/package.py @@ -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",