git: a62b2a87bbbd - main - misc/py-pytorch: unbreak on amd64
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 19 Sep 2026 09:39:28 UTC
The branch main has been updated by yuri:
URL: https://cgit.FreeBSD.org/ports/commit/?id=a62b2a87bbbdba16923cc9a663b02ffa5ca6dfde
commit a62b2a87bbbdba16923cc9a663b02ffa5ca6dfde
Author: Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-09-19 09:37:42 +0000
Commit: Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-09-19 09:39:25 +0000
misc/py-pytorch: unbreak on amd64
Add FreeBSD patches for FreeBSD.
Many patches were upstreamed.
---
misc/py-pytorch/Makefile | 2 +-
...Ten_native_quantized_cpu_qnnpack_CMakeLists.txt | 36 ++++++++++++++++++++++
.../files/patch-cmake_Dependencies.cmake | 12 ++++++--
.../patch-third__party_pthreadpool_src_pthreads.c | 24 +++++++++++++++
4 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/misc/py-pytorch/Makefile b/misc/py-pytorch/Makefile
index 20a580d0a863..0b8689c7c067 100644
--- a/misc/py-pytorch/Makefile
+++ b/misc/py-pytorch/Makefile
@@ -1,6 +1,7 @@
PORTNAME= pytorch
DISTVERSIONPREFIX= v
DISTVERSION= 2.14.0
+PORTREVISION= 1
CATEGORIES= misc # machine-learning
MASTER_SITES= https://github.com/pytorch/pytorch/releases/download/v${DISTVERSION}/
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
@@ -15,7 +16,6 @@ WWW= https://pytorch.org/ \
LICENSE= BSD3CLAUSE
LICENSE_FILE= ${WRKSRC}/LICENSE
-BROKEN_aarch64= build fails: CMake Error at third_party/QNNPACK/CMakeLists.txt:47 (MESSAGE): Unrecognized CMAKE_SYSTEM_NAME = FreeBSD, see https://github.com/pytorch/pytorch/issues/144608
BROKEN_armv7= build fails: CMake Error at third_party/QNNPACK/CMakeLists.txt:47 (MESSAGE): Unrecognized CMAKE_SYSTEM_NAME = FreeBSD, see https://github.com/pytorch/pytorch/issues/144608
BROKEN_i386= build fails: DispatchStub.cpp:162:29: [0m[0;1;31merror: [0m[1muse of undeclared identifier 'AVX2'[0m
diff --git a/misc/py-pytorch/files/patch-aten_src_ATen_native_quantized_cpu_qnnpack_CMakeLists.txt b/misc/py-pytorch/files/patch-aten_src_ATen_native_quantized_cpu_qnnpack_CMakeLists.txt
new file mode 100644
index 000000000000..687b69ac6b83
--- /dev/null
+++ b/misc/py-pytorch/files/patch-aten_src_ATen_native_quantized_cpu_qnnpack_CMakeLists.txt
@@ -0,0 +1,36 @@
+-- Allow QNNPACK's own CMakeLists.txt platform check to accept FreeBSD on
+-- aarch64. Upstream only allow-lists Darwin/Linux/Android for
+-- CMAKE_SYSTEM_NAME here, causing configure to abort with
+-- "Unrecognized CMAKE_SYSTEM_NAME = FreeBSD" (see
+-- https://github.com/pytorch/pytorch/issues/144608). QNNPACK itself builds
+-- and runs fine on FreeBSD/aarch64 once this check is relaxed, so only widen
+-- it for that specific target; other platforms keep upstream's original
+-- behavior unchanged.
+
+--- aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt.orig 2026-09-02 17:43:46 UTC
++++ aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
+@@ -54,13 +54,13 @@ if(NOT CMAKE_SYSTEM_PROCESSOR)
+ else()
+ message(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR is not defined")
+ endif()
+-elseif(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86_64|armv[5-8].*|aarch64|arm64)$")
++elseif(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86_64|AMD64|amd64|armv[5-8].*|aarch64|arm64)$")
+ message(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}")
+ endif()
+
+ if(NOT CMAKE_SYSTEM_NAME)
+ message(FATAL_ERROR "CMAKE_SYSTEM_NAME not defined")
+-elseif(NOT CMAKE_SYSTEM_NAME MATCHES "^(Darwin|Linux|Android)$")
++elseif(NOT CMAKE_SYSTEM_NAME MATCHES "^(Darwin|Linux|FreeBSD|Android)$")
+ message(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
+ endif()
+
+@@ -274,7 +274,7 @@ endif()
+ list(APPEND PYTORCH_QNNPACK_UKERNELS ${PYTORCH_QNNPACK_ARM_NEON_UKERNELS})
+ list(APPEND PYTORCH_QNNPACK_UKERNELS ${PYTORCH_QNNPACK_AARCH64_ASM_UKERNELS})
+ endif()
+-if(PYTORCH_QNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86_64)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$")
++if(PYTORCH_QNNPACK_TARGET_PROCESSOR MATCHES "^(i[3-6]86|x86_64|AMD64|amd64)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$")
+ list(APPEND PYTORCH_QNNPACK_UKERNELS ${PYTORCH_QNNPACK_X86_SSE2_UKERNELS})
+ endif()
+
diff --git a/misc/py-pytorch/files/patch-cmake_Dependencies.cmake b/misc/py-pytorch/files/patch-cmake_Dependencies.cmake
index f035ddb2eb8b..44fab43d4d32 100644
--- a/misc/py-pytorch/files/patch-cmake_Dependencies.cmake
+++ b/misc/py-pytorch/files/patch-cmake_Dependencies.cmake
@@ -1,6 +1,6 @@
---- cmake/Dependencies.cmake.orig 2026-07-08 17:44:27 UTC
+--- cmake/Dependencies.cmake.orig 2026-09-02 17:43:46 UTC
+++ cmake/Dependencies.cmake
-@@ -373,7 +373,7 @@ if(USE_NNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK)
+@@ -373,14 +373,14 @@ if(USE_NNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK)
set(DISABLE_NNPACK_AND_FAMILY ON)
endif()
else()
@@ -9,3 +9,11 @@
message(WARNING
"Target platform \"${CMAKE_SYSTEM_NAME}\" is not supported in {Q/X}NNPACK. "
"Supported platforms are Android, iOS, Linux, and macOS. "
+ "Turn this warning off by USE_{Q/X}NNPACK=OFF.")
+ set(DISABLE_NNPACK_AND_FAMILY ON)
+ endif()
+- if(NOT IOS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|AMD64|x86_64|armv[0-9].*|arm64|aarch64)$"))
++ if(NOT IOS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|AMD64|amd64|x86_64|armv[0-9].*|arm64|aarch64)$"))
+ message(WARNING
+ "Target architecture \"${CMAKE_SYSTEM_PROCESSOR}\" is not supported in {Q/X}NNPACK. "
+ "Supported architectures are x86, x86-64, ARM, and ARM64. "
diff --git a/misc/py-pytorch/files/patch-third__party_pthreadpool_src_pthreads.c b/misc/py-pytorch/files/patch-third__party_pthreadpool_src_pthreads.c
new file mode 100644
index 000000000000..f6eb43b3e520
--- /dev/null
+++ b/misc/py-pytorch/files/patch-third__party_pthreadpool_src_pthreads.c
@@ -0,0 +1,24 @@
+-- Avoid including the non-existent <alloca.h> on FreeBSD/aarch64.
+-- On FreeBSD/DragonFly, alloca() is declared as a macro in <stdlib.h> only
+-- for __GNUC__ >= 2, which clang on aarch64 does not satisfy in the way this
+-- file expects (it falls through past the __GNUC__ branch above), leading it
+-- to try '#include <alloca.h>', a header that does not exist on these
+-- systems. Add an explicit branch for FreeBSD/DragonFly aarch64 that relies
+-- on the declaration already brought in via <stdlib.h>. Scoped to aarch64
+-- only since other architectures build fine as-is.
+-- See https://github.com/pytorch/pytorch/issues/144608 (related upstream
+-- QNNPACK/FreeBSD tracking issue) for context on FreeBSD arm64 support gaps.
+
+--- third_party/pthreadpool/src/pthreads.c.orig 2026-09-02 17:44:00 UTC
++++ third_party/pthreadpool/src/pthreads.c
+@@ -79,6 +79,10 @@
+ #define alloca _alloca
+ #elif !defined(alloca) && defined(__GNUC__)
+ #define alloca(s) __builtin_alloca(s)
++#elif defined(__FreeBSD__) || defined(__DragonFly__)
++/* On FreeBSD/DragonFly aarch64, <stdlib.h> (included above) already defines
++ * alloca() as a macro for __GNUC__ >= 2, so the branch above is skipped, but
++ * there is no <alloca.h> to fall back to. */
+ #else
+ #include <alloca.h>
+ #endif