Skip to content

Engine-folder preload helper for Linux: b2LoadNativeLibHere() (no sudo)#47

Merged
SethMorrowSoftware merged 2 commits into
mainfrom
claude/beautiful-cray-lwlsgr
Jun 15, 2026
Merged

Engine-folder preload helper for Linux: b2LoadNativeLibHere() (no sudo)#47
SethMorrowSoftware merged 2 commits into
mainfrom
claude/beautiful-cray-lwlsgr

Conversation

@SethMorrowSoftware

@SethMorrowSoftware SethMorrowSoftware commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Goal

Let Box2Dxt load on Linux with no /usr/lib, no sudo, no LD_LIBRARY_PATH — drop box2dxt.so in the OXT engine's own folder (or bundle it in a standalone) and a one-call helper preloads it. Builds on the merged loader-assist (b2LoadNativeLib, #46).

What it adds

b2LoadNativeLibHere() (in src/box2dxt.lcb): reads the running engine's own path via realpath("/proc/self/exe"), strips to its folder, and preloads <folder>/box2dxt.so by absolute path. The engine's later bare-name dlopen then finds the already-resident copy. For a standalone, /proc/self/exe is the standalone binary, so this covers shipping self-contained too.

Important: it is an explicit, Linux-only helper — NOT auto-fired

realpath/dlopen are POSIX. An earlier revision of this PR auto-called the preload from b2Version/checkABI, which run on every platform — that would make those bindings fail to resolve on Windows and throw. Backed out. b2Version/checkABI are now back to their original cross-platform-safe form, and the preload is an explicit call you make only when the platform is "Linux" (the Kit will gate it that way once the mechanism is confirmed). On Windows/macOS nothing here is touched — they already load the library from beside the stack/app.

Requirements / caveats

Verified locally

  • Bare-soname build still emits box2dxt.so with soname box2dxt.so.
  • tools/check-livecodescript.py passes; no _ensureLib/auto-call references remain.

Needs an OXT pass (the gate)

The .lcb can't be compiled headless. Two separate things to confirm in OXT:

  1. Windows (safe-now check): load this branch's .lcb, put b2Version() → expect 4, and run a demo — confirms the new bindings compile/load and nothing fires on Windows.
  2. Linux (the mechanism): with box2dxt.so (bare-soname) on no search path, put b2LoadNativeLibHere()1, then put b2Version()4. If green, the no-sudo engine-folder install works and the Kit gating + finalization follow.

https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku

claude added 2 commits June 15, 2026 19:59
Builds on the merged loader-assist (b2LoadNativeLib): the extension now locates
the running engine's own folder (realpath /proc/self/exe), strips to its
directory, and preloads <dir>/box2dxt.so by absolute path before any c:box2dxt>
binding resolves -- run from the first-call gateways (b2Version, checkABI). The
engine's later bare-name load then finds the already-resident copy, so a user
just drops box2dxt.so beside the OXT engine (or bundles it in a standalone) --
no /usr/lib, no sudo, no LD_LIBRARY_PATH, no script calls.

Off Linux realpath('/proc/self/exe') returns nothing and _ensureLib no-ops, so
Windows/macOS keep loading the library from beside the stack/app as before.

Requires the library soname to be box2dxt.so (build -DBOX2DXT_BARE_SONAME=ON).
No new C ABI symbol; b2Version() stays 4. Verified locally: bare-soname build
still emits box2dxt.so with soname box2dxt.so; .livecodescript gates pass. The
.lcb cannot be compiled headless -- needs an OXT load to confirm the
realpath/dlopen bindings resolve and the engine reuses the preloaded copy.

https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
The previous commit auto-called _ensureLib from b2Version/checkABI, which run
on every platform -- but _ensureLib calls realpath (POSIX), so on Windows that
binding would fail to resolve and make b2Version()/b2NewWorld() throw. Back out
the auto-fire and expose the engine-folder preload as an explicit, Linux-only
public handler b2LoadNativeLibHere(): it locates the engine via realpath
/proc/self/exe and preloads <dir>/box2dxt.so. Callers gate it on
the platform is Linux (the Kit will, once the preload is confirmed on Linux);
b2Version/checkABI are back to their original cross-platform-safe form.

No new C ABI symbol; b2Version() stays 4. .livecodescript gates pass; the .lcb
still needs an OXT load to confirm the bindings compile and resolve.

https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
@SethMorrowSoftware SethMorrowSoftware changed the title Auto-load box2dxt.so from the engine folder on Linux (no sudo) Engine-folder preload helper for Linux: b2LoadNativeLibHere() (no sudo) Jun 15, 2026
@SethMorrowSoftware SethMorrowSoftware marked this pull request as ready for review June 15, 2026 22:19
@SethMorrowSoftware SethMorrowSoftware merged commit baf3d1c into main Jun 15, 2026
7 checks passed
SethMorrowSoftware pushed a commit that referenced this pull request Jun 15, 2026
b2kSetup now calls b2LoadNativeLibHere() when (and only when) the platform is
Linux, so Kit/demo users get the no-sudo engine-folder load automatically while
Windows/macOS never touch the POSIX path. The breakage that forced the helper
to be a manual call in #47 was Windows-only -- realpath is absent there, but
present and harmless on macOS -- so a single platform gate is enough. Drop
box2dxt.so beside the engine (or bundle it in a standalone) and the demos run
on Linux with no /usr/lib, no sudo, no LD_LIBRARY_PATH.

- src/box2dxt-kit.livecodescript: gated preload at the top of b2kSetup.
- examples/*: re-synced embedded Kit.
- examples/box2dxt-selftest: bump kStHarnessV 18->19 + add stTestLoaderHelper
  (Linux-gated; on Linux it also proves the realpath/dlopen bindings resolve).

https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
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.

2 participants