165.1. onnxruntime-1.30.0
ONNX Runtime: inference for ONNX models on the CPU, as a C/C++ library and a Python module
| Version | 1.30.0, release 2 |
| Shelf | ai — Machine learning inference, speech recognition, computer vision and neural translation |
| Phase | 41_system (System), 56 of 1047 in build order |
| Licence | MIT |
| Homepage | https://onnxruntime.ai/ |
| Build time | 31.6 SBU |
| Installed size | 64.4 MiB in 658 files |
| Recipe | ports/core/ai/onnxruntime/kpkgbuild |
About
ONNX Runtime runs neural-network models saved in the ONNX format. This port builds its CPU execution provider only, as the C and C++ library libonnxruntime and the Python module onnxruntime. The Python module is what piper, the text-to-speech engine, imports to run its voice models; it is built against numpy.
Every third-party library ONNX Runtime uses is compiled into libonnxruntime at the version this release pins: abseil, protobuf, re2, flatbuffers, Eigen, the ONNX definitions and the rest. The installed library needs nothing but the C and C++ runtime libraries. Each of those sources is a further source = line of the recipe, named ort-, the dependency’s name in cmake/deps.txt, a hyphen, and the file name of its URL.
Sources
onnxruntime-1.30.0.tar.gz(265.7 MiB)
sha256f6681ecbddf53898adf0cc9e8e9e84657485b84d2eca3c8aa353de6d7dd417ef
upstream: https://github.com/microsoft/onnxruntime/archive/refs/tags/v1.30.0.tar.gz
archive copy: sources-1/ai--onnxruntime-1.30.0.tar.gzort-abseil_cpp-20250814.0.zip(3.0 MiB)
sha256b2bdcf6682d8cb53df365bcc5d6c318a22e55821d9978a10fdb61404c026daff
upstream: https://github.com/abseil/abseil-cpp/archive/refs/tags/20250814.0.zip
archive copy: sources-1/ai--ort-abseil_cpp-20250814.0.ziport-date-v3.0.1.zip(919.2 KiB)
sha256f4300b96f7a304d4ef9bf6e0fa3ded72159f7f2d0f605bdde3e030a0dba7cf9f
upstream: https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip
archive copy: sources-1/ai--ort-date-v3.0.1.ziport-dlpack-5c210da409e7f1e51ddf445134a4376fdbd70d7d.zip(223.0 KiB)
sha25614e8b3f03ab7461f56b3fa7ffd4acfb6e6a65f895dc4b50548cab259229afcbd
upstream: https://github.com/dmlc/dlpack/archive/5c210da409e7f1e51ddf445134a4376fdbd70d7d.zip
archive copy: sources-1/ai--ort-dlpack-5c210da409e7f1e51ddf445134a4376fdbd70d7d.ziport-eigen-eigen-1d8b82b0740839c0de7f1242a3585e3390ff5f33.zip(3.9 MiB)
sha2566a60d76351f97132669daeeb721d6bf14b008101883ad2d687a3201c5c461eb0
upstream: https://github.com/eigen-mirror/eigen/archive/1d8b82b0740839c0de7f1242a3585e3390ff5f33/eigen-1d8b82b0740839c0de7f1242a3585e3390ff5f33.zip
archive copy: sources-1/ai--ort-eigen-eigen-1d8b82b0740839c0de7f1242a3585e3390ff5f33.ziport-flatbuffers-v23.5.26.zip(3.1 MiB)
sha25657bd580c0772fd1a726c34ab8bf05325293bc5f9c165060a898afa1feeeb95e1
upstream: https://github.com/google/flatbuffers/archive/refs/tags/v23.5.26.zip
archive copy: sources-1/ai--ort-flatbuffers-v23.5.26.ziport-json-v3.11.3.zip(8.1 MiB)
sha25604022b05d806eb5ff73023c280b68697d12b93e1b7267a0b22a1a39ec7578069
upstream: https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.zip
archive copy: sources-1/ai--ort-json-v3.11.3.ziport-microsoft_gsl-v4.2.1.zip(82.2 KiB)
sha256c9291d95f5f6e5c561990d06a589b01d89e553d0f366f0ce723dd1788e7a6076
upstream: https://github.com/microsoft/GSL/archive/refs/tags/v4.2.1.zip
archive copy: sources-1/ai--ort-microsoft_gsl-v4.2.1.ziport-mp11-boost-1.82.0.zip(227.3 KiB)
sha25681431bdc44c439a324e02c07ed067f8f556419fd86f2d8b486ff568df6aac899
upstream: https://github.com/boostorg/mp11/archive/refs/tags/boost-1.82.0.zip
archive copy: sources-1/ai--ort-mp11-boost-1.82.0.ziport-onnx-v1.22.0.zip(18.0 MiB)
sha2568dc1181d33529a1249e031226126d0699ac9bdfc571ee530ee3a12f4656f2be3
upstream: https://github.com/onnx/onnx/archive/refs/tags/v1.22.0.zip
archive copy: sources-1/ai--ort-onnx-v1.22.0.ziport-protobuf-protobuf-33.6.tar.gz(6.6 MiB)
sha25616498d7dc7967e9b100632138babd4b86b61592beeccdd556f67539d9c231355
upstream: https://github.com/protocolbuffers/protobuf/releases/download/v33.6/protobuf-33.6.tar.gz
archive copy: sources-1/ai--ort-protobuf-protobuf-33.6.tar.gzort-pybind11-v3.0.2.zip(1.1 MiB)
sha256e3754d16ea536bdc968ce1464fa822e198a1217881d31bd9bf3d287fed2bbf4c
upstream: https://github.com/pybind/pybind11/archive/refs/tags/v3.0.2.zip
archive copy: sources-1/ai--ort-pybind11-v3.0.2.ziport-pytorch_cpuinfo-66ee79c038d70dad9f08705b2c9b3e58f6d8f512.zip(3.7 MiB)
sha256b93044263ee072e9be3577bda52f48d5a4dd9fcb80091529471c8d2bfe59219d
upstream: https://github.com/pytorch/cpuinfo/archive/66ee79c038d70dad9f08705b2c9b3e58f6d8f512.zip
archive copy: sources-1/ai--ort-pytorch_cpuinfo-66ee79c038d70dad9f08705b2c9b3e58f6d8f512.ziport-re2-2024-07-02.zip(441.0 KiB)
sha256a835fe55fbdcd8e80f38584ab22d0840662c67f2feb36bd679402da9641dc71e
upstream: https://github.com/google/re2/archive/refs/tags/2024-07-02.zip
archive copy: sources-1/ai--ort-re2-2024-07-02.ziport-safeint-3.0.28.zip(611.7 KiB)
sha2563ffbd9a2fdff45da77da3e7269e9aa512ea43bed5c38ce8fd8f3d1068a032c3f
upstream: https://github.com/dcleblanc/SafeInt/archive/refs/tags/3.0.28.zip
archive copy: sources-1/ai--ort-safeint-3.0.28.zip
Dependencies
Depends on: cmake, ninja, patch, python3, numpy, python3-setuptools, python3-wheel, python3-packaging, python3-pip, zlib.
Required by (1): piper.
Patches
build.sh applies these; kpkg applies nothing by itself.
gcc16-cstdint.patch— adds#include <cstdint>toinclude/onnxruntime/core/framework/tensor_shape.h, which uses the fixed-width integer types without including their header; GCC 16’s C++ headers do not bring it in on the way to their own, so the file does not compile without it (see A standard header the source never includes).
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install onnxruntime'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/ai/onnxruntime.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/ai/onnxruntime
echo 'f6681ecbddf53898adf0cc9e8e9e84657485b84d2eca3c8aa353de6d7dd417ef onnxruntime-1.30.0.tar.gz' | sha256sum -c -
echo 'b2bdcf6682d8cb53df365bcc5d6c318a22e55821d9978a10fdb61404c026daff ort-abseil_cpp-20250814.0.zip' | sha256sum -c -
echo 'f4300b96f7a304d4ef9bf6e0fa3ded72159f7f2d0f605bdde3e030a0dba7cf9f ort-date-v3.0.1.zip' | sha256sum -c -
echo '14e8b3f03ab7461f56b3fa7ffd4acfb6e6a65f895dc4b50548cab259229afcbd ort-dlpack-5c210da409e7f1e51ddf445134a4376fdbd70d7d.zip' | sha256sum -c -
echo '6a60d76351f97132669daeeb721d6bf14b008101883ad2d687a3201c5c461eb0 ort-eigen-eigen-1d8b82b0740839c0de7f1242a3585e3390ff5f33.zip' | sha256sum -c -
echo '57bd580c0772fd1a726c34ab8bf05325293bc5f9c165060a898afa1feeeb95e1 ort-flatbuffers-v23.5.26.zip' | sha256sum -c -
echo '04022b05d806eb5ff73023c280b68697d12b93e1b7267a0b22a1a39ec7578069 ort-json-v3.11.3.zip' | sha256sum -c -
echo 'c9291d95f5f6e5c561990d06a589b01d89e553d0f366f0ce723dd1788e7a6076 ort-microsoft_gsl-v4.2.1.zip' | sha256sum -c -
echo '81431bdc44c439a324e02c07ed067f8f556419fd86f2d8b486ff568df6aac899 ort-mp11-boost-1.82.0.zip' | sha256sum -c -
echo '8dc1181d33529a1249e031226126d0699ac9bdfc571ee530ee3a12f4656f2be3 ort-onnx-v1.22.0.zip' | sha256sum -c -
echo '16498d7dc7967e9b100632138babd4b86b61592beeccdd556f67539d9c231355 ort-protobuf-protobuf-33.6.tar.gz' | sha256sum -c -
echo 'e3754d16ea536bdc968ce1464fa822e198a1217881d31bd9bf3d287fed2bbf4c ort-pybind11-v3.0.2.zip' | sha256sum -c -
echo 'b93044263ee072e9be3577bda52f48d5a4dd9fcb80091529471c8d2bfe59219d ort-pytorch_cpuinfo-66ee79c038d70dad9f08705b2c9b3e58f6d8f512.zip' | sha256sum -c -
echo 'a835fe55fbdcd8e80f38584ab22d0840662c67f2feb36bd679402da9641dc71e ort-re2-2024-07-02.zip' | sha256sum -c -
echo '3ffbd9a2fdff45da77da3e7269e9aa512ea43bed5c38ce8fd8f3d1068a032c3f ort-safeint-3.0.28.zip' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/onnxruntime
SRC=$SRC_ROOT/onnxruntime-1.30.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf onnxruntime-1.30.0.tar.gz -C "$SRC" --strip-components=1
cp ort-abseil_cpp-20250814.0.zip "$SRC"
cp ort-re2-2024-07-02.zip "$SRC"
tar --no-same-permissions --warning=no-unknown-keyword -xf ort-protobuf-protobuf-33.6.tar.gz -C "$SRC_ROOT"
cp ort-date-v3.0.1.zip "$SRC"
cp ort-mp11-boost-1.82.0.zip "$SRC"
cp ort-json-v3.11.3.zip "$SRC"
cp ort-pytorch_cpuinfo-66ee79c038d70dad9f08705b2c9b3e58f6d8f512.zip "$SRC"
cp ort-microsoft_gsl-v4.2.1.zip "$SRC"
cp ort-safeint-3.0.28.zip "$SRC"
cp ort-flatbuffers-v23.5.26.zip "$SRC"
cp ort-onnx-v1.22.0.zip "$SRC"
cp ort-eigen-eigen-1d8b82b0740839c0de7f1242a3585e3390ff5f33.zip "$SRC"
cp ort-pybind11-v3.0.2.zip "$SRC"
cp ort-dlpack-5c210da409e7f1e51ddf445134a4376fdbd70d7d.zip "$SRC"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/gcc16-cstdint.patch"
export ASMFLAGS="-Wa,--noexecstack" LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
_mirror="$SRC/mirror"
for s in $source; do
case $s in ort-*::https://*) ;; *) continue ;; esac
f=${s%%::*}
u=${s#*::https://}
for d in "$SRC" "$PORT_SRC" "$SOURCE_DIR"; do
[ -f "$d/$f" ] && break
done
[ -f "$d/$f" ] || { echo "onnxruntime: $f is missing" >&2; exit 1; }
mkdir -p "$_mirror/${u%/*}"
ln -sf "$d/$f" "$_mirror/$u"
done
cmake -S cmake -B build -G Ninja \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DPython_EXECUTABLE=/usr/bin/python3 \
-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=NEVER \
-Donnxruntime_CMAKE_DEPS_MIRROR_DIR="$_mirror" \
-Donnxruntime_BUILD_SHARED_LIB=ON \
-Donnxruntime_BUILD_UNIT_TESTS=OFF \
-Donnxruntime_BUILD_BENCHMARKS=OFF \
-Donnxruntime_ENABLE_PYTHON=ON \
-Donnxruntime_USE_TELEMETRY=OFF \
-Donnxruntime_ENABLE_LTO=OFF \
-Donnxruntime_BUILD_FOR_NATIVE_MACHINE=OFF \
-Donnxruntime_USE_XNNPACK=OFF \
-Donnxruntime_USE_MIMALLOC=OFF \
-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
cd build
python3 ../setup.py bdist_wheel --dist-dir="$SRC_ROOT/ort-dist"
pip3 install --ignore-installed --no-deps --no-index --no-build-isolation \
--root="$PKG" --prefix=/usr "$SRC_ROOT"/ort-dist/onnxruntime-*.whl
_capi=$(echo "$PKG"/usr/lib/python3*/site-packages/onnxruntime/capi)
[ -f "$_capi/onnxruntime_pybind11_state.so" ] ||
{ echo "onnxruntime: the Python module was not installed" >&2; exit 1; }
if readelf -lW "$_capi/onnxruntime_pybind11_state.so" | grep GNU_STACK | grep -q RWE; then
echo "onnxruntime: the Python module asks for an executable stack" >&2
exit 1
fi
for lib in "$_capi"/libonnxruntime*.so*; do
[ -f "$lib" ] || continue
b=${lib##*/}
[ -e "$PKG/usr/lib/$b" ] && ln -sf "../../../../$b" "$lib"
done
The switches, and why each is set:
-Wa,--noexecstack— inASMFLAGS, and-Wl,-z,noexecstackinLDFLAGS: mark every object assembled from the project’s assembly sources, and every library linked, as needing no executable stack. The package lint refuses an ELF object that asks for one (see What the package lint refuses), andbuild.shchecks the Python module’sGNU_STACKheader itself after the install.-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=NEVER— make every dependency CMake’sFetchContentdeclares build from its pinned source, never from an installed package thatfind_packagewould find first. The tree has its own abseil-cpp, protobuf, re2, eigen and nlohmann-json; a system protobuf built against another abseil would put two abseils in one process.-Donnxruntime_CMAKE_DEPS_MIRROR_DIR— the directory ONNX Runtime looks in before downloading a dependency. Each dependency is named incmake/deps.txtby URL and SHA-1; a file at<mirror>/<URL without https://>is used in its place, still checked against that SHA-1 and still given upstream’s patches fromcmake/patches.build.shbuilds that layout from theort-*sources as symbolic links.-Donnxruntime_BUILD_SHARED_LIB=ON— buildlibonnxruntime.so, the shared library of the C and C++ API. Off by upstream’s default.-Donnxruntime_ENABLE_PYTHON=ON— build the Python module’s extension,onnxruntime_pybind11_state.so, with the pybind11 the release pins. Off by upstream’s default.-Donnxruntime_BUILD_UNIT_TESTS=OFF— skip the unit tests, which upstream builds by default. They need googletest, which is not among the recipe’s sources.-Donnxruntime_USE_TELEMETRY=OFF— no telemetry. It is upstream’s default, named so that it is the recipe’s own setting.-Donnxruntime_BUILD_FOR_NATIVE_MACHINE=OFF— no-march=native -mtune=native, which would tie the library to the processor of the machine that built it. Upstream’s default, named: the tree builds for the x86-64 baseline and leaves the feature level to each machine (see-marchmeasured per machine).-Donnxruntime_USE_XNNPACK=OFF— withonnxruntime_USE_MIMALLOCandonnxruntime_BUILD_BENCHMARKS: no XNNPACK execution provider, no mimalloc allocator (which upstream offers on Windows only) and no micro-benchmarks, each upstream’s default, so none of their sources is fetched.-Donnxruntime_ENABLE_LTO=OFF— no link-time optimisation, upstream’s default, named. LTO is kept to the short list of hot libraries the tree names (see Every port).
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/onnxruntime, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf onnxruntime-1.30.0-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/onnxruntime, and runs the triggers its paths call for.
Contents
Installed programs: onnxruntime_test.
Installed libraries: libonnxruntime.so, libonnxruntime_providers_shared.so.
Installed directories: /usr/include/onnxruntime, /usr/lib/cmake/onnxruntime, /usr/lib/python3.14/site-packages/onnxruntime, /usr/lib/python3.14/site-packages/onnxruntime-1.30.0.dist-info, /usr/share/licenses/onnxruntime.
Short descriptions
libonnxruntime.pc |
ONNX runtime |
Notes
patch is in depends because CMake applies upstream’s patches from cmake/patches to several fetched dependencies, protobuf, GSL and flatbuffers among them, with patch.
The mirror loop in build.sh looks for each ort-* file in $SRC, $PORT_SRC and $SOURCE_DIR, in that order, and stops the build naming the first one that is in none of them. The case that picks the files reads the recipe’s source lines, so a dependency added to the recipe needs no change to build.sh, but its name must keep the ort- prefix.
The Python module is built as a wheel by setup.py, run from the build directory, where the module and the two shared libraries were built, and installed with pip3. The wheel carries its own copies of libonnxruntime.so.<version> and libonnxruntime_providers_shared.so; build.sh replaces each with a link to the file already installed in /usr/lib, so the package holds one copy of each library.