Skip to content

loader: find the runtime relative to our own module, not just by name - #23

Merged
jcelerier merged 1 commit into
mainfrom
release/sat-2026-09
Oct 7, 2026
Merged

jcelerier merged 1 commit into
mainfrom
release/sat-2026-09

Conversation

@jcelerier

Copy link
Copy Markdown
Owner

dylib_loader only ever called LoadLibraryA/dlopen with a bare name, so the OS
search path alone decided whether librediffusion was found. That works for a system
install, for LD_LIBRARY_PATH, and for score's AppImage (whose AppRun prepends every
<root>/support/* holding shared libs) — but nowhere else:

  • Loaded from a Max or TouchDesigner plugin, the host's folder is Max's or TD's, never
    the plugin's, so a runtime shipped inside the plugin package is unreachable.
    score-addon-onnx hit exactly this and solved it with ossia::get_module_folder(); we
    had no equivalent.
  • On Windows nothing put <root>/support/librediffusion on the DLL search path at all.
    (Root cause since found and fixed upstream: score's addSupportLibraries() called
    AddDllDirectory without SetDefaultDllDirectories, making the whole block a no-op —
    Fix five packaging/deployment defects found while building the SAT tool suite ossia/score#2281.)

So resolve the module containing this code (GetModuleHandleEx / dladdr) and also look
beside it, and in support/librediffusion next to it — the layout the release bundles
already use. The plain-name attempt stays first, so existing deployments resolve
exactly as before; the new paths are only a fallback.

Verified on Linux against a library present in neither ldconfig nor any system path:
found via <module>/support/librediffusion and its symbol called.

Note for consumers: the fix is consumer-side — this header compiles into whatever
uses librediffusion, so librediffusion.dll/.so itself carries none of it and the
consumers must be rebuilt.

🤖 Generated with Claude Code

https://claude.ai/code/session_019QYyvhRXvSMSRQPaq12Teq

dylib_loader only ever called LoadLibraryA/dlopen with a bare name, so the OS
search path alone decided whether librediffusion was found. That works for a
system install, for LD_LIBRARY_PATH, and for score's AppImage (AppRun prepends
every <root>/support/* that holds shared libs) -- but nowhere else:

  - Loaded from a Max or TouchDesigner plugin, the host's folder is Max's or
    TD's, never the plugin's, so a runtime shipped inside the plugin package is
    unreachable. score-addon-onnx hit exactly this and solved it with
    ossia::get_module_folder(); we had no equivalent.
  - On Windows nothing puts <root>/support/librediffusion on the DLL search
    path at all: score's launcher.cpp sets QML2_IMPORT_PATH and a baked-in
    SCORE_ENVIRONMENT but never touches PATH/SetDllDirectory, and
    create-app-windows.sh has no support/ handling. The Linux-only AppRun logic
    has no counterpart there.

So resolve the module that contains this code (GetModuleHandleEx / dladdr) and
also look beside it, and in "support/librediffusion" next to it -- the layout
the release bundles already use. The plain-name attempt stays FIRST so existing
deployments keep resolving exactly as before; the new paths are a fallback.

Verified on Linux with a library present in neither ldconfig nor any system
path: found via <module>/support/librediffusion and its symbol called.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QYyvhRXvSMSRQPaq12Teq
jcelerier added a commit to ossia/score-addon-librediffusion that referenced this pull request Oct 7, 2026
librediffusion's dylib_loader resolved the runtime by bare name only, so it was
found only when the OS search path already covered it. That is never the case for
the Max and TouchDesigner externals, whose plugin folder is not on the search
path, nor on Windows where nothing put {RootPath}/support on the DLL search path.

The fix is consumer-side: it lives in a header that compiles into whatever links
librediffusion, so librediffusion.dll/.so carries none of it and this addon only
picks it up via the submodule pointer.

jcelerier/librediffusion#23

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QYyvhRXvSMSRQPaq12Teq
@jcelerier
jcelerier merged commit 2ed00e7 into main Oct 7, 2026
3 checks passed
jcelerier added a commit to ossia/score-addon-librediffusion that referenced this pull request Oct 7, 2026
librediffusion's dylib_loader resolved the runtime by bare name only, so it was
found only when the OS search path already covered it. That is never the case for
the Max and TouchDesigner externals, whose plugin folder is not on the search
path, nor on Windows where nothing put {RootPath}/support on the DLL search path.

The fix is consumer-side: it lives in a header that compiles into whatever links
librediffusion, so librediffusion.dll/.so carries none of it and this addon only
picks it up via the submodule pointer.

jcelerier/librediffusion#23

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QYyvhRXvSMSRQPaq12Teq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant