The ONNX plugin dlopen()ed ONNX Runtime from directories next to the
plugin first and only then from a few system prefixes, with no notion of
which copy it got or why, and the shipped packages contained no copy at
all, so on most hosts the plugin could only report "runtime not found".
The runtime resolution moves into plugins/ort_runtime/, built as a
hidden-visibility static library both ONNX-using plugins link (their
export maps still expose only the plugin C ABI). The policy is split out
as pure code (ort_runtime_resolution.{h,cpp}) so it is testable without a
runtime. Candidates are tried in this order and the first compatible one
wins:
1. YAMS_ONNX_RUNTIME_LIB / YAMS_ONNX_RUNTIME_DIR (existing pin, kept),
then the plugin config key runtime_library ([plugins.onnx] /
[plugins.glint], a file or directory)
2. a system copy: the loader search by soname, then the usual library
directories (multiarch dir, /usr/lib64, /usr/lib, /usr/local/lib,
/opt/onnxruntime, Homebrew) for versioned names such as Debian's
libonnxruntime.so.1.23
3. the private copy in <libdir>/yams/onnxruntime/
4. legacy locations next to the plugin (build trees)
A candidate is accepted only if it exports OrtGetApiBase, GetApi() returns
an API table for the ORT_API_VERSION the plugins are compiled against, and
it meets the 1.23 minimum; otherwise it is skipped with a reason. A soname
lookup that returns a copy another plugin already loaded from the bundled
directory is reported as that copy. The choice ("Using system|bundled ONNX
Runtime <ver> from <path> (<why>)") and every skipped candidate go to the
plugin log and, through the libyams_onnx_resource host sink (new
OnnxConcurrencyRegistry::emitHostLog), to the daemon log; plugin health
reports runtime_source. With no compatible copy the plugin reports "ONNX
Runtime unavailable: ..." instead of failing.
Tests: tests/unit/plugins/ort_runtime_resolution_catch2_test.cpp covers
the order, the override pin, configured directories, system-over-bundled
preference, skipping an incompatible system copy, the not-found result
and the already-loaded classification.
Signed-off-by: trvon <me@trevon.dev>
55 lines
2.1 KiB
Meson
55 lines
2.1 KiB
Meson
plugins_dir = get_option('libdir') / 'yams' / 'plugins'
|
|
|
|
# Every plugin builds with hidden visibility and links with an export list that
|
|
# keeps only the yams_plugin_* C ABI (nothing from statically linked deps).
|
|
plugin_export_link_args = []
|
|
plugin_export_link_depends = []
|
|
if host_machine.system() == 'darwin'
|
|
plugin_export_link_depends = files('exports/yams_plugin.exp')
|
|
plugin_export_link_args = ['-Wl,-exported_symbols_list,' + meson.current_source_dir() / 'exports' / 'yams_plugin.exp']
|
|
elif host_machine.system() != 'windows'
|
|
plugin_export_link_depends = files('exports/yams_plugin.map')
|
|
plugin_export_link_args = meson.get_compiler('cpp').get_supported_link_arguments(
|
|
'-Wl,--version-script=' + meson.current_source_dir() / 'exports' / 'yams_plugin.map',
|
|
'-Wl,--exclude-libs,ALL',
|
|
)
|
|
endif
|
|
|
|
# Shared ONNX Runtime loader for the ONNX and Glint plugins. Neither plugin links
|
|
# ONNX Runtime: the loader dlopen()s a compatible copy at runtime (override,
|
|
# configured path, system copy, then the private copy in <libdir>/yams/onnxruntime).
|
|
# Only the ONNX Runtime headers are needed at build time.
|
|
yams_ort_loader_dep = dependency('', required: false)
|
|
if onnxruntime_resolved_dep.found() and (get_option('plugin-onnx') or get_option('plugin-glint'))
|
|
_ort_headers_dep = onnxruntime_resolved_dep.partial_dependency(compile_args: true, includes: true)
|
|
_yams_ort_loader_lib = static_library('yams_ort_loader',
|
|
['ort_runtime/ort_runtime_loader.cpp', 'ort_runtime/ort_runtime_resolution.cpp'],
|
|
include_directories: include_directories('../include'),
|
|
dependencies: [_ort_headers_dep, dependency('spdlog'), dependency('yams_onnx_resource')],
|
|
gnu_symbol_visibility: 'hidden',
|
|
pic: true,
|
|
install: false,
|
|
)
|
|
yams_ort_loader_dep = declare_dependency(
|
|
link_with: _yams_ort_loader_lib,
|
|
include_directories: include_directories('ort_runtime'),
|
|
dependencies: [_ort_headers_dep, dependency('yams_onnx_resource')],
|
|
)
|
|
endif
|
|
|
|
if get_option('plugin-s3')
|
|
subdir('object_storage_s3')
|
|
endif
|
|
|
|
if get_option('plugin-onnx')
|
|
subdir('onnx')
|
|
endif
|
|
|
|
if get_option('plugin-zyp')
|
|
subdir('zyp')
|
|
endif
|
|
|
|
if get_option('plugin-glint')
|
|
subdir('glint')
|
|
endif
|
|
|