git: 72a99dd00b86 - main - misc/onnxruntime: New port: Cross-platform, high performance ML inferencing & training accelerator

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 07 Oct 2024 08:55:46 UTC
The branch main has been updated by yuri:

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

commit 72a99dd00b863bb3173689fdd9b97adcca352acf
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-10-07 08:28:00 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-10-07 08:55:42 +0000

    misc/onnxruntime: New port: Cross-platform, high performance ML inferencing & training accelerator
---
 misc/Makefile                                      |  1 +
 misc/onnxruntime/Makefile                          | 49 +++++++++++
 misc/onnxruntime/Makefile.DISTFILES                | 41 ++++++++++
 misc/onnxruntime/Makefile.MASTER_SITES             | 41 ++++++++++
 misc/onnxruntime/distinfo                          | 89 ++++++++++++++++++++
 misc/onnxruntime/files/convert-deps.sh             | 32 ++++++++
 ...make_external_onnxruntime__external__deps.cmake | 11 +++
 .../patch-onnxruntime_core_platform_posix_env.cc   | 27 ++++++
 misc/onnxruntime/pkg-descr                         | 14 ++++
 misc/onnxruntime/pkg-plist                         | 95 ++++++++++++++++++++++
 10 files changed, 400 insertions(+)

diff --git a/misc/Makefile b/misc/Makefile
index 5935fdc554d8..4929d177041a 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -294,6 +294,7 @@
     SUBDIR += ompl
     SUBDIR += ondir
     SUBDIR += onnx
+    SUBDIR += onnxruntime
     SUBDIR += ooo
     SUBDIR += opencyc
     SUBDIR += openhab
diff --git a/misc/onnxruntime/Makefile b/misc/onnxruntime/Makefile
new file mode 100644
index 000000000000..b46bf44d1901
--- /dev/null
+++ b/misc/onnxruntime/Makefile
@@ -0,0 +1,49 @@
+PORTNAME=	onnxruntime
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.18.2
+CATEGORIES=	misc # machine-learning
+DIST_SUBDIR=	${PORTNAME}
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Cross-platform, high performance ML inferencing & training accelerator
+WWW=		https://onnxruntime.ai/
+
+LICENSE=	MIT
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	gpatch:devel/patch
+LIB_DEPENDS=	libabsl_base.so:devel/abseil
+
+USES=		cmake:testing compiler:c++11-lang python:build
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	microsoft
+GH_TUPLE=	emscripten-core:emsdk:d52c465:emsdk/cmake/external/emsdk \
+		google:libprotobuf-mutator:7a2ed51:libprotobuf_mutator/cmake/external/libprotobuf-mutator \
+		onnx:onnx:595228d:onnx/cmake/external/onnx
+
+CMAKE_SOURCE_PATH=	${WRKSRC}/cmake
+CMAKE_ON=	BUILD_SHARED_LIBS
+CMAKE_OFF=	FETCHCONTENT_FULLY_DISCONNECTED \
+		onnxruntime_BUILD_UNIT_TESTS
+CMAKE_TESTING_ON=	onnxruntime_BUILD_UNIT_TESTS
+
+BINARY_ALIAS=	patch=gpatch
+
+DEPS_FILE=	${WRKSRC}/cmake/deps.txt
+
+dev-update-deps-in-makefiles: extract # this should be run when the port is updated
+	@${FILEDIR} ${DEPS_FILE}
+
+pre-configure:
+	@${REINPLACE_CMD} -E 's|;(https://.*)/([^/]+\.zip);|;file://${DISTDIR}/${DIST_SUBDIR}/\2;|' ${DEPS_FILE}
+
+# there should be an EXTRACT_ONLY statement
+#
+# this port is broken at least in some ways: it has missing symbols due to excessive
+# and incorrect bundling, see https://github.com/microsoft/onnxruntime/issues/22331
+# it still might be useful for some purposes, hence static libraries are installed instead of shared ones
+
+.include <Makefile.MASTER_SITES>
+.include <Makefile.DISTFILES>
+.include <bsd.port.mk>
diff --git a/misc/onnxruntime/Makefile.DISTFILES b/misc/onnxruntime/Makefile.DISTFILES
new file mode 100644
index 000000000000..6ba6c0820ba5
--- /dev/null
+++ b/misc/onnxruntime/Makefile.DISTFILES
@@ -0,0 +1,41 @@
+DISTFILES=	\
+		f46495ea96f68fc3f6c394f099b2992743f6ff7f.zip:abseil_cpp \
+		7.1.zip:coremltools \
+		3c73d91c0b04e2b59462f0a741be8c07024c1bc0.zip:cxxopts \
+		v3.0.1.zip:date \
+		v0.6.zip:dlpack \
+		eigen-e7248b26a1ed53fa030c5c459f7ea095dfd276ac.zip:eigen \
+		v23.5.26.zip:flatbuffers \
+		0a92994d729ff76a58f692d3028ca1b64b145d91.zip:fp16 \
+		63058eff77e11aa15bf531df5dd34395ec3017c8.zip:fxdiv \
+		v1.8.3.zip:google_benchmark \
+		1.26.0.zip:google_nsync \
+		530d5c8c84abd2a46f38583ee817743c9b3a42b4.zip:googletest \
+		0da379fc4808f9601faef392352018c741c0f297.zip:googlexnnpack \
+		v3.10.5.zip:json \
+		v4.0.0.zip:microsoft_gsl \
+		v1.0.230629.1.zip:microsoft_wil \
+		v2.1.1.zip:mimalloc \
+		boost-1.82.0.zip:mp11 \
+		v0.3.zip:neural_speed \
+		v1.16.0.zip:onnx \
+		06adf4461ac84035bee658c6cf5df39f7ab6071d.zip:onnx_tensorrt \
+		v21.12.zip:protobuf \
+		protoc-21.12-win64.zip:protoc_win64 \
+		protoc-21.12-win32.zip:protoc_win32 \
+		protoc-21.12-linux-x86_64.zip:protoc_linux_x64 \
+		protoc-21.12-linux-x86_32.zip:protoc_linux_x86 \
+		protoc-21.12-linux-aarch_64.zip:protoc_linux_aarch64 \
+		protoc-21.12-osx-universal_binary.zip:protoc_mac_universal \
+		072586a71b55b7f8c584153d223e95687148a900.zip:psimd \
+		4fe0e1e183925bf8cfa6aae24237e724a96479b8.zip:pthreadpool \
+		v2.10.1.zip:pybind11 \
+		959002f82d7962a473d8bf301845f2af720e0aa4.zip:pytorch_cpuinfo \
+		2022-06-01.zip:re2 \
+		3.0.28.zip:safeint \
+		373eb09e4c5d2b3cc2493f0949dc4be6b6a45e81.zip:tensorboard \
+		v3.1.0.zip:cutlass \
+		72c943dea2b9240cd09efde15191e144bc7c7d38.zip:utf8_range \
+		94142d8391c9791ec71c38336436319a2d4ac7a0.zip:extensions \
+		5356c4a943a35e74d7cdc69486afcb8703b9a59a.zip:composable_kernel \
+		v1.613.1.zip:directx_headers \
diff --git a/misc/onnxruntime/Makefile.MASTER_SITES b/misc/onnxruntime/Makefile.MASTER_SITES
new file mode 100644
index 000000000000..62016e96340f
--- /dev/null
+++ b/misc/onnxruntime/Makefile.MASTER_SITES
@@ -0,0 +1,41 @@
+MASTER_SITES=	\
+		https://github.com/abseil/abseil-cpp/archive/:abseil_cpp \
+		https://github.com/apple/coremltools/archive/refs/tags/:coremltools \
+		https://github.com/jarro2783/cxxopts/archive/:cxxopts \
+		https://github.com/HowardHinnant/date/archive/refs/tags/:date \
+		https://github.com/dmlc/dlpack/archive/refs/tags/:dlpack \
+		https://gitlab.com/libeigen/eigen/-/archive/e7248b26a1ed53fa030c5c459f7ea095dfd276ac/:eigen \
+		https://github.com/google/flatbuffers/archive/refs/tags/:flatbuffers \
+		https://github.com/Maratyszcza/FP16/archive/:fp16 \
+		https://github.com/Maratyszcza/FXdiv/archive/:fxdiv \
+		https://github.com/google/benchmark/archive/refs/tags/:google_benchmark \
+		https://github.com/google/nsync/archive/refs/tags/:google_nsync \
+		https://github.com/google/googletest/archive/:googletest \
+		https://github.com/google/XNNPACK/archive/:googlexnnpack \
+		https://github.com/nlohmann/json/archive/refs/tags/:json \
+		https://github.com/microsoft/GSL/archive/refs/tags/:microsoft_gsl \
+		https://github.com/microsoft/wil/archive/refs/tags/:microsoft_wil \
+		https://github.com/microsoft/mimalloc/archive/refs/tags/:mimalloc \
+		https://github.com/boostorg/mp11/archive/refs/tags/:mp11 \
+		https://github.com/intel/neural-speed/archive/refs/tags/:neural_speed \
+		https://github.com/onnx/onnx/archive/refs/tags/:onnx \
+		https://github.com/onnx/onnx-tensorrt/archive/:onnx_tensorrt \
+		https://github.com/protocolbuffers/protobuf/archive/refs/tags/:protobuf \
+		https://github.com/protocolbuffers/protobuf/releases/download/v21.12/:protoc_win64 \
+		https://github.com/protocolbuffers/protobuf/releases/download/v21.12/:protoc_win32 \
+		https://github.com/protocolbuffers/protobuf/releases/download/v21.12/:protoc_linux_x64 \
+		https://github.com/protocolbuffers/protobuf/releases/download/v21.12/:protoc_linux_x86 \
+		https://github.com/protocolbuffers/protobuf/releases/download/v21.12/:protoc_linux_aarch64 \
+		https://github.com/protocolbuffers/protobuf/releases/download/v21.12/:protoc_mac_universal \
+		https://github.com/Maratyszcza/psimd/archive/:psimd \
+		https://github.com/Maratyszcza/pthreadpool/archive/:pthreadpool \
+		https://github.com/pybind/pybind11/archive/refs/tags/:pybind11 \
+		https://github.com/pytorch/cpuinfo/archive/:pytorch_cpuinfo \
+		https://github.com/google/re2/archive/refs/tags/:re2 \
+		https://github.com/dcleblanc/SafeInt/archive/refs/tags/:safeint \
+		https://github.com/tensorflow/tensorboard/archive/:tensorboard \
+		https://github.com/NVIDIA/cutlass/archive/refs/tags/:cutlass \
+		https://github.com/protocolbuffers/utf8_range/archive/:utf8_range \
+		https://github.com/microsoft/onnxruntime-extensions/archive/:extensions \
+		https://github.com/ROCmSoftwarePlatform/composable_kernel/archive/:composable_kernel \
+		https://github.com/microsoft/DirectX-Headers/archive/refs/tags/:directx_headers \
diff --git a/misc/onnxruntime/distinfo b/misc/onnxruntime/distinfo
new file mode 100644
index 000000000000..72fce57cac85
--- /dev/null
+++ b/misc/onnxruntime/distinfo
@@ -0,0 +1,89 @@
+TIMESTAMP = 1728269378
+SHA256 (onnxruntime/f46495ea96f68fc3f6c394f099b2992743f6ff7f.zip) = c66911f9b09c606fdfcbcc45b706da7297aac4c81c9bd5720c8b9985ef70f805
+SIZE (onnxruntime/f46495ea96f68fc3f6c394f099b2992743f6ff7f.zip) = 3293341
+SHA256 (onnxruntime/7.1.zip) = a9a95d3b3d1cbf9b9e00c145bcae4050f89042dc5b777635421dcdaf85010890
+SIZE (onnxruntime/7.1.zip) = 20043908
+SHA256 (onnxruntime/3c73d91c0b04e2b59462f0a741be8c07024c1bc0.zip) = 57b5f012372d4c0e0a975b2e534e9af647cd20530fc72f73a75a61e05e0f997e
+SIZE (onnxruntime/3c73d91c0b04e2b59462f0a741be8c07024c1bc0.zip) = 98330
+SHA256 (onnxruntime/v3.0.1.zip) = f4300b96f7a304d4ef9bf6e0fa3ded72159f7f2d0f605bdde3e030a0dba7cf9f
+SIZE (onnxruntime/v3.0.1.zip) = 941286
+SHA256 (onnxruntime/v0.6.zip) = cb296b25f1ad5d52aa0efd7553e1aab17ab4561d1068b291fbe14d543d22f381
+SIZE (onnxruntime/v0.6.zip) = 44987
+SHA256 (onnxruntime/eigen-e7248b26a1ed53fa030c5c459f7ea095dfd276ac.zip) = f09e0073a0e0d34229103e875e2c79b2a350abb382f5bda7f615554532f56687
+SIZE (onnxruntime/eigen-e7248b26a1ed53fa030c5c459f7ea095dfd276ac.zip) = 3836219
+SHA256 (onnxruntime/v23.5.26.zip) = 57bd580c0772fd1a726c34ab8bf05325293bc5f9c165060a898afa1feeeb95e1
+SIZE (onnxruntime/v23.5.26.zip) = 3209602
+SHA256 (onnxruntime/0a92994d729ff76a58f692d3028ca1b64b145d91.zip) = e66e65515fa09927b348d3d584c68be4215cfe664100d01c9dbc7655a5716d70
+SIZE (onnxruntime/0a92994d729ff76a58f692d3028ca1b64b145d91.zip) = 91373
+SHA256 (onnxruntime/63058eff77e11aa15bf531df5dd34395ec3017c8.zip) = 3d7b0e9c4c658a84376a1086126be02f9b7f753caa95e009d9ac38d11da444db
+SIZE (onnxruntime/63058eff77e11aa15bf531df5dd34395ec3017c8.zip) = 16646
+SHA256 (onnxruntime/v1.8.3.zip) = abfc22e33e3594d0edf8eaddaf4d84a2ffc491ad74b6a7edc6e7a608f690e691
+SIZE (onnxruntime/v1.8.3.zip) = 322763
+SHA256 (onnxruntime/1.26.0.zip) = a723c8d8e48f12d94d01dc6245552193f4ddb7009a687849d8cfcf8cdd86e89f
+SIZE (onnxruntime/1.26.0.zip) = 336679
+SHA256 (onnxruntime/530d5c8c84abd2a46f38583ee817743c9b3a42b4.zip) = 1a3fe3c0dfede7201e5b03f2a02e1abf54ab8da43e71f6973839b84497a31abd
+SIZE (onnxruntime/530d5c8c84abd2a46f38583ee817743c9b3a42b4.zip) = 1110835
+SHA256 (onnxruntime/0da379fc4808f9601faef392352018c741c0f297.zip) = 52aff6d3c445340cfabb5647ec2abc59039a2861b381977e3f8ffc26e1895cf7
+SIZE (onnxruntime/0da379fc4808f9601faef392352018c741c0f297.zip) = 27845900
+SHA256 (onnxruntime/v3.10.5.zip) = ea4b0084709fb934f92ca0a68669daa0fe6f2a2c6400bf353454993a834bb0bb
+SIZE (onnxruntime/v3.10.5.zip) = 7381040
+SHA256 (onnxruntime/v4.0.0.zip) = eb91fcb10a6aa5ccb1d224e07a56c8ecffe9a1bb601fa1848276ec46a2200bfb
+SIZE (onnxruntime/v4.0.0.zip) = 78670
+SHA256 (onnxruntime/v1.0.230629.1.zip) = f116af6cd96b8404d5e3cd6ef18853f7baa9c7d96930e741591fea8b5a3ef919
+SIZE (onnxruntime/v1.0.230629.1.zip) = 600066
+SHA256 (onnxruntime/v2.1.1.zip) = 23b1bffb2eff57b1e3cb8edc9410d448db2bb43400206a151e107dcabcad773a
+SIZE (onnxruntime/v2.1.1.zip) = 1301043
+SHA256 (onnxruntime/boost-1.82.0.zip) = 81431bdc44c439a324e02c07ed067f8f556419fd86f2d8b486ff568df6aac899
+SIZE (onnxruntime/boost-1.82.0.zip) = 232716
+SHA256 (onnxruntime/v0.3.zip) = 7279d60261acb5543aeac4b7d6115b6ffceaaf9953b49b880741b61df2bbdfe8
+SIZE (onnxruntime/v0.3.zip) = 3697487
+SHA256 (onnxruntime/v1.16.0.zip) = 00ce28981a28f305af156346037332ddefe185fff9b873c7b29990c3ec244d4c
+SIZE (onnxruntime/v1.16.0.zip) = 15697774
+SHA256 (onnxruntime/06adf4461ac84035bee658c6cf5df39f7ab6071d.zip) = 2d1fd464c26ad376ba43a26f261de965dafe163fbbb09b900987c65bd50db6c5
+SIZE (onnxruntime/06adf4461ac84035bee658c6cf5df39f7ab6071d.zip) = 232700
+SHA256 (onnxruntime/v21.12.zip) = 6a31b662deaeb0ac35e6287bda2f3369b19836e6c9f8828d4da444346f420298
+SIZE (onnxruntime/v21.12.zip) = 7180794
+SHA256 (onnxruntime/protoc-21.12-win64.zip) = 71852a30cf62975358edfcbbff93086e8857a079c8e4d6904881aa968d65c7f9
+SIZE (onnxruntime/protoc-21.12-win64.zip) = 2278456
+SHA256 (onnxruntime/protoc-21.12-win32.zip) = 6de4ef4e65c7edb834a2a9fca6d85388adc5dd71fc8bff8b60569717d01dabea
+SIZE (onnxruntime/protoc-21.12-win32.zip) = 2306903
+SHA256 (onnxruntime/protoc-21.12-linux-x86_64.zip) = 3a4c1e5f2516c639d3079b1586e703fc7bcfa2136d58bda24d1d54f949c315e8
+SIZE (onnxruntime/protoc-21.12-linux-x86_64.zip) = 1585982
+SHA256 (onnxruntime/protoc-21.12-linux-x86_32.zip) = dd4b5972cb3de92bfff9d7d3b361a7c281d27a010c8872d1e6efc43895253f71
+SIZE (onnxruntime/protoc-21.12-linux-x86_32.zip) = 1692297
+SHA256 (onnxruntime/protoc-21.12-linux-aarch_64.zip) = 2dd17f75d66a682640b136e31848da9fb2eefe68d55303baf8b32617374f6711
+SIZE (onnxruntime/protoc-21.12-linux-aarch_64.zip) = 1582596
+SHA256 (onnxruntime/protoc-21.12-osx-universal_binary.zip) = 1acab3d1f774d120d5a38bccb78fd379d35226b254dc258978bc45593478ca4c
+SIZE (onnxruntime/protoc-21.12-osx-universal_binary.zip) = 2822292
+SHA256 (onnxruntime/072586a71b55b7f8c584153d223e95687148a900.zip) = dc615342bcbe51ca885323e51b68b90ed9bb9fa7df0f4419dbfa0297d5e837b7
+SIZE (onnxruntime/072586a71b55b7f8c584153d223e95687148a900.zip) = 8327
+SHA256 (onnxruntime/4fe0e1e183925bf8cfa6aae24237e724a96479b8.zip) = a4cf06de57bfdf8d7b537c61f1c3071bce74e57524fe053e0bbd2332feca7f95
+SIZE (onnxruntime/4fe0e1e183925bf8cfa6aae24237e724a96479b8.zip) = 72209
+SHA256 (onnxruntime/v2.10.1.zip) = fcf94065efcfd0a7a828bacf118fa11c43f6390d0c805e3e6342ac119f2e9976
+SIZE (onnxruntime/v2.10.1.zip) = 832204
+SHA256 (onnxruntime/959002f82d7962a473d8bf301845f2af720e0aa4.zip) = a0f53ccfb477c57753c595df02bf79ed67bf092fd9a5c61ec5b8992b81bc1e65
+SIZE (onnxruntime/959002f82d7962a473d8bf301845f2af720e0aa4.zip) = 3813452
+SHA256 (onnxruntime/2022-06-01.zip) = 9f3b65f2e0c78253fcfdfce1754172b0f97ffdb643ee5fd67f0185acf91a3f28
+SIZE (onnxruntime/2022-06-01.zip) = 438194
+SHA256 (onnxruntime/3.0.28.zip) = 3ffbd9a2fdff45da77da3e7269e9aa512ea43bed5c38ce8fd8f3d1068a032c3f
+SIZE (onnxruntime/3.0.28.zip) = 626378
+SHA256 (onnxruntime/373eb09e4c5d2b3cc2493f0949dc4be6b6a45e81.zip) = c7c77b30e7056dc77c067ec70fce24e80a927522b973ebefac33888ba18b5a7d
+SIZE (onnxruntime/373eb09e4c5d2b3cc2493f0949dc4be6b6a45e81.zip) = 76560689
+SHA256 (onnxruntime/v3.1.0.zip) = 4eb56c75e7ae4a366ed4f83932949452b331f1043fa415efa4bf37a9b1fbede9
+SIZE (onnxruntime/v3.1.0.zip) = 27392822
+SHA256 (onnxruntime/72c943dea2b9240cd09efde15191e144bc7c7d38.zip) = dffb52973f0226fe5df6d9ed40b0d1af1bb89f54beec6a64b66d25e7db9c4152
+SIZE (onnxruntime/72c943dea2b9240cd09efde15191e144bc7c7d38.zip) = 71643
+SHA256 (onnxruntime/94142d8391c9791ec71c38336436319a2d4ac7a0.zip) = 9b2de3c9a9dd7bd36d267a0fc5f28086e2e09fb3e893d60f167fb22ebed3b209
+SIZE (onnxruntime/94142d8391c9791ec71c38336436319a2d4ac7a0.zip) = 54384193
+SHA256 (onnxruntime/5356c4a943a35e74d7cdc69486afcb8703b9a59a.zip) = 59d68fb332042e7c1ab68a596d93141e66dfc8495195a201c85c48a5fe6c508a
+SIZE (onnxruntime/5356c4a943a35e74d7cdc69486afcb8703b9a59a.zip) = 4398835
+SHA256 (onnxruntime/v1.613.1.zip) = c356d242e63f6c8e6fa8dec01f7d526b172621f0f6687611239f772095842e4c
+SIZE (onnxruntime/v1.613.1.zip) = 472978
+SHA256 (onnxruntime/microsoft-onnxruntime-v1.18.2_GH0.tar.gz) = f489a1febd9096b5d5ff54503b029aa1735489cb0308c6a7e1d0040c92a1d923
+SIZE (onnxruntime/microsoft-onnxruntime-v1.18.2_GH0.tar.gz) = 239521820
+SHA256 (onnxruntime/emscripten-core-emsdk-d52c465_GH0.tar.gz) = aa409c7263862d64e0c100201b5c5e157f2c52f25368bf8cf1d5c548b3fbe681
+SIZE (onnxruntime/emscripten-core-emsdk-d52c465_GH0.tar.gz) = 105204
+SHA256 (onnxruntime/google-libprotobuf-mutator-7a2ed51_GH0.tar.gz) = 7946d91f89f3a86a257f04061c87e12f4fba7472bc1aaed9098c3c389a31a143
+SIZE (onnxruntime/google-libprotobuf-mutator-7a2ed51_GH0.tar.gz) = 38335
+SHA256 (onnxruntime/onnx-onnx-595228d_GH0.tar.gz) = 131bf1af5c6e5ea08ce212124dd594316d9bf2c837e6c5be8319ea61faed1252
+SIZE (onnxruntime/onnx-onnx-595228d_GH0.tar.gz) = 12428055
diff --git a/misc/onnxruntime/files/convert-deps.sh b/misc/onnxruntime/files/convert-deps.sh
new file mode 100755
index 000000000000..48368219321c
--- /dev/null
+++ b/misc/onnxruntime/files/convert-deps.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+set -euo pipefail
+
+# args
+deps_file="$1"
+
+# initialize Makefile.xx files
+echo "MASTER_SITES=	\\" > Makefile.MASTER_SITES
+echo "DISTFILES=	\\" > Makefile.DISTFILES
+
+# loop
+cat $deps_file | grep -v "^#" | (while read -r line; do
+	line=$(echo $line | sed -e 's|;| |g')
+	#echo "LINE $line"
+
+	# extract fields
+	name=$(echo $line | sed -e 's| .*||')
+	url=$(echo $line | sed -e "s|$name ||; s| .*||")
+	#echo "... name=$name url=$url"
+
+	# split url
+	url_split=$(echo $url | sed -E 's|(.*)/([^/]+)|\1 \2|')
+	#echo "... url_split=$url_split"
+	url_dir=$(echo $url_split | sed -e 's| .*||')
+	url_file=$(echo $url_split | sed -e 's|.* ||')
+	#echo "... url_dir=$url_dir url_file=$url_file"
+
+	# write Makefile.xx files
+	echo "		$url_dir/:$name \\" >> Makefile.MASTER_SITES
+	echo "		$url_file:$name \\" >> Makefile.DISTFILES
+done)
diff --git a/misc/onnxruntime/files/patch-cmake_external_onnxruntime__external__deps.cmake b/misc/onnxruntime/files/patch-cmake_external_onnxruntime__external__deps.cmake
new file mode 100644
index 000000000000..fcbff2438b20
--- /dev/null
+++ b/misc/onnxruntime/files/patch-cmake_external_onnxruntime__external__deps.cmake
@@ -0,0 +1,11 @@
+--- cmake/external/onnxruntime_external_deps.cmake.orig	2024-06-24 02:23:28 UTC
++++ cmake/external/onnxruntime_external_deps.cmake
+@@ -85,7 +85,7 @@ if (NOT WIN32)
+     google_nsync
+     URL ${DEP_URL_google_nsync}
+     URL_HASH SHA1=${DEP_SHA1_google_nsync}
+-    FIND_PACKAGE_ARGS NAMES nsync
++    FIND_PACKAGE_ARGS NAMES nsync_cpp
+     )
+ endif()
+ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/external)
diff --git a/misc/onnxruntime/files/patch-onnxruntime_core_platform_posix_env.cc b/misc/onnxruntime/files/patch-onnxruntime_core_platform_posix_env.cc
new file mode 100644
index 000000000000..004a6b9f4a2a
--- /dev/null
+++ b/misc/onnxruntime/files/patch-onnxruntime_core_platform_posix_env.cc
@@ -0,0 +1,27 @@
+--- onnxruntime/core/platform/posix/env.cc.orig	2024-10-06 21:45:44 UTC
++++ onnxruntime/core/platform/posix/env.cc
+@@ -20,6 +20,7 @@ limitations under the License.
+ #include <dlfcn.h>
+ #include <fcntl.h>
+ #include <ftw.h>
++#include <pthread_np.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdio.h>
+@@ -218,14 +219,14 @@ class PosixThread : public EnvThread {
+         }
+         auto ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+         if (0 == ret) {
+-          LOGS_DEFAULT(VERBOSE) << "pthread_setaffinity_np succeed for thread: " << syscall(SYS_gettid)
++          LOGS_DEFAULT(VERBOSE) << "pthread_setaffinity_np succeed for thread: " << ::pthread_self()
+                                 << ", index: " << p->index
+                                 << ", mask: " << *p->affinity;
+         } else {
+           errno = ret;
+           auto [err_no, err_msg] = GetErrnoInfo();
+ #if !defined(USE_MIGRAPHX)
+-          LOGS_DEFAULT(ERROR) << "pthread_setaffinity_np failed for thread: " << syscall(SYS_gettid)
++          LOGS_DEFAULT(ERROR) << "pthread_setaffinity_np failed for thread: " << ::pthread_self()
+                               << ", index: " << p->index
+                               << ", mask: " << *p->affinity
+                               << ", error code: " << err_no << " error msg: " << err_msg
diff --git a/misc/onnxruntime/pkg-descr b/misc/onnxruntime/pkg-descr
new file mode 100644
index 000000000000..8674f6be2e8e
--- /dev/null
+++ b/misc/onnxruntime/pkg-descr
@@ -0,0 +1,14 @@
+ONNX Runtime is a cross-platform inference and training machine-learning
+accelerator.
+
+ONNX Runtime inference can enable faster customer experiences and lower costs,
+supporting models from deep learning frameworks such as PyTorch and
+TensorFlow/Keras as well as classical machine learning libraries such as
+scikit-learn, LightGBM, XGBoost, etc. ONNX Runtime is compatible with different
+hardware, drivers, and operating systems, and provides optimal performance by
+leveraging hardware accelerators where applicable alongside graph optimizations
+and transforms.
+
+ONNX Runtime training can accelerate the model training time on multi-node
+NVIDIA GPUs for transformer models with a one-line addition for existing PyTorch
+training scripts.
diff --git a/misc/onnxruntime/pkg-plist b/misc/onnxruntime/pkg-plist
new file mode 100644
index 000000000000..d661193c46ac
--- /dev/null
+++ b/misc/onnxruntime/pkg-plist
@@ -0,0 +1,95 @@
+include/onnxruntime/core/common/basic_types.h
+include/onnxruntime/core/common/code_location.h
+include/onnxruntime/core/common/common.h
+include/onnxruntime/core/common/const_pointer_container.h
+include/onnxruntime/core/common/denormal.h
+include/onnxruntime/core/common/eigen_common_wrapper.h
+include/onnxruntime/core/common/exceptions.h
+include/onnxruntime/core/common/gpu_profiler_common.h
+include/onnxruntime/core/common/gsl.h
+include/onnxruntime/core/common/hash_combine.h
+include/onnxruntime/core/common/inlined_containers.h
+include/onnxruntime/core/common/inlined_containers_fwd.h
+include/onnxruntime/core/common/logging/capture.h
+include/onnxruntime/core/common/logging/isink.h
+include/onnxruntime/core/common/logging/logging.h
+include/onnxruntime/core/common/logging/macros.h
+include/onnxruntime/core/common/logging/severity.h
+include/onnxruntime/core/common/make_string.h
+include/onnxruntime/core/common/narrow.h
+include/onnxruntime/core/common/optional.h
+include/onnxruntime/core/common/parse_string.h
+include/onnxruntime/core/common/profiler_common.h
+include/onnxruntime/core/common/span_utils.h
+include/onnxruntime/core/common/spin_pause.h
+include/onnxruntime/core/common/status.h
+include/onnxruntime/core/common/string_helper.h
+include/onnxruntime/core/framework/alloc_kind.h
+include/onnxruntime/core/framework/allocator.h
+include/onnxruntime/core/framework/buffer_deleter.h
+include/onnxruntime/core/framework/customregistry.h
+include/onnxruntime/core/framework/data_types.h
+include/onnxruntime/core/framework/data_types_internal.h
+include/onnxruntime/core/framework/endian.h
+include/onnxruntime/core/framework/execution_provider.h
+include/onnxruntime/core/framework/float16.h
+include/onnxruntime/core/framework/float8.h
+include/onnxruntime/core/framework/framework_common.h
+include/onnxruntime/core/framework/framework_provider_common.h
+include/onnxruntime/core/framework/func_api.h
+include/onnxruntime/core/framework/kernel_def_builder.h
+include/onnxruntime/core/framework/kernel_registry.h
+include/onnxruntime/core/framework/op_kernel.h
+include/onnxruntime/core/framework/op_kernel_context.h
+include/onnxruntime/core/framework/op_kernel_info.h
+include/onnxruntime/core/framework/op_node_proto_helper.h
+include/onnxruntime/core/framework/ort_value.h
+include/onnxruntime/core/framework/ortdevice.h
+include/onnxruntime/core/framework/ortmemoryinfo.h
+include/onnxruntime/core/framework/provider_options.h
+include/onnxruntime/core/framework/provider_options_utils.h
+include/onnxruntime/core/framework/provider_shutdown.h
+include/onnxruntime/core/framework/run_options.h
+include/onnxruntime/core/framework/sparse_tensor.h
+include/onnxruntime/core/framework/stream_handles.h
+include/onnxruntime/core/framework/tensor.h
+include/onnxruntime/core/framework/tensor_shape.h
+include/onnxruntime/core/framework/to_tensor_proto_element_type.h
+include/onnxruntime/core/graph/basic_types.h
+include/onnxruntime/core/graph/constants.h
+include/onnxruntime/core/graph/function.h
+include/onnxruntime/core/graph/graph.h
+include/onnxruntime/core/graph/graph_nodes.h
+include/onnxruntime/core/graph/graph_viewer.h
+include/onnxruntime/core/graph/indexed_sub_graph.h
+include/onnxruntime/core/graph/node_arg.h
+include/onnxruntime/core/graph/schema_registry.h
+include/onnxruntime/core/optimizer/graph_transformer.h
+include/onnxruntime/core/optimizer/graph_transformer_config.h
+include/onnxruntime/core/optimizer/graph_transformer_level.h
+include/onnxruntime/core/optimizer/graph_transformer_utils.h
+include/onnxruntime/core/optimizer/rewrite_rule.h
+include/onnxruntime/core/optimizer/rule_based_graph_transformer.h
+include/onnxruntime/core/session/environment.h
+include/onnxruntime/core/session/experimental_onnxruntime_cxx_api.h
+include/onnxruntime/core/session/experimental_onnxruntime_cxx_inline.h
+include/onnxruntime/core/session/onnxruntime_c_api.h
+include/onnxruntime/core/session/onnxruntime_cxx_api.h
+include/onnxruntime/core/session/onnxruntime_cxx_inline.h
+include/onnxruntime/core/session/onnxruntime_float16.h
+include/onnxruntime/core/session/onnxruntime_lite_custom_op.h
+include/onnxruntime/core/session/onnxruntime_run_options_config_keys.h
+include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h
+include/onnxruntime/core/session/snippets.dox
+include/onnxruntime/cpu_provider_factory.h
+lib/libonnxruntime_common.a
+lib/libonnxruntime_flatbuffers.a
+lib/libonnxruntime_framework.a
+lib/libonnxruntime_graph.a
+lib/libonnxruntime_mlas.a
+lib/libonnxruntime_optimizer.a
+lib/libonnxruntime_providers.a
+lib/libonnxruntime_providers_shared.so
+lib/libonnxruntime_session.a
+lib/libonnxruntime_util.a
+libdata/pkgconfig/libonnxruntime.pc