git: b1d7ccf3436e - main - misc/onnx: Remove visibility restriction on symbols

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Tue, 11 Nov 2025 20:04:24 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b1d7ccf3436e3908ba76e37206b4127139495b33

commit b1d7ccf3436e3908ba76e37206b4127139495b33
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2025-11-11 20:02:46 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2025-11-11 20:04:19 +0000

    misc/onnx: Remove visibility restriction on symbols
    
    This fixes the PyTorch run-time crash due to missing onnx symbols.
---
 misc/onnx/Makefile                   |  1 +
 misc/onnx/files/patch-CMakeLists.txt | 28 ++++++++++++++++++++++++++++
 misc/py-pytorch/Makefile             |  1 -
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/misc/onnx/Makefile b/misc/onnx/Makefile
index 7788b1d24ef9..3087145e8f7d 100644
--- a/misc/onnx/Makefile
+++ b/misc/onnx/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	onnx
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1.19.1
+PORTREVISION=	1
 CATEGORIES=	misc # machine-learning
 
 MAINTAINER=	yuri@FreeBSD.org
diff --git a/misc/onnx/files/patch-CMakeLists.txt b/misc/onnx/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..f1e4a2c51f35
--- /dev/null
+++ b/misc/onnx/files/patch-CMakeLists.txt
@@ -0,0 +1,28 @@
+-- remove visibility settings to fix run-time of PyTorch with ONNX
+-- 'import torch' fails otherwise with undefined symbols from ONNX
+-- https://github.com/pytorch/pytorch/issues/167525
+
+--- CMakeLists.txt.orig	2025-11-11 00:00:00 UTC
++++ CMakeLists.txt
+@@ -419,8 +419,8 @@ foreach(_proto_src ${ONNX_PROTO_SRCS})
+ endforeach()
+ 
+ # Hide all symbols we don't need
+-set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
+-set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
++#set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
++#set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
+ 
+ set(LINKED_PROTOBUF_TARGET protobuf::libprotobuf)
+ if(ONNX_USE_LITE_PROTO)
+@@ -459,8 +459,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ else()
+   add_library(onnx ${ONNX_SRCS})
+ endif()
+-set_target_properties(onnx PROPERTIES CXX_VISIBILITY_PRESET hidden)
+-set_target_properties(onnx PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
++#set_target_properties(onnx PROPERTIES CXX_VISIBILITY_PRESET hidden)
++#set_target_properties(onnx PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
+ 
+ target_link_libraries(onnx PUBLIC onnx_proto)
+ add_onnx_global_defines(onnx)
diff --git a/misc/py-pytorch/Makefile b/misc/py-pytorch/Makefile
index 9831c6a8a593..9e4d09be2c50 100644
--- a/misc/py-pytorch/Makefile
+++ b/misc/py-pytorch/Makefile
@@ -16,7 +16,6 @@ WWW=		https://pytorch.org/ \
 LICENSE=	BSD3CLAUSE
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-IGNORE=		fails in the run-time after the latest onnx update, see https://github.com/pytorch/pytorch/issues/167525
 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