Make snapshot load position-independent (match libraries by basename)#1780
Open
dg1sbg wants to merge 1 commit into
Open
Make snapshot load position-independent (match libraries by basename)#1780dg1sbg wants to merge 1 commit into
dg1sbg wants to merge 1 commit into
Conversation
snapshot_load resolves the C++ libraries a snapshot references via
core::library_with_name, which matched a recorded library by requiring its
(save-time) name to be a path SUFFIX of a currently-loaded library's path.
Because the recorded name is the absolute path captured by dladdr at save time,
a snapshot whose libraries are later loaded from a different directory -- a
relocated or bundled install, or a different prefix than the build tree --
fails the suffix test and snapshot_load aborts ("Unable to find library").
Match by basename (SONAME) instead. The subsequent nm/dlsym step already uses
the matched, currently-loaded path, so the matcher was the only place bound to
the save-time path. Snapshots now load regardless of where their libraries sit,
making save-lisp-and-die executables and snapshot files relocatable across
prefixes/machines.
Verified on aarch64 Linux: a boehmprecise :executable snapshot whose libLLVM /
libstdc++ / libclasp were relocated into a bundle directory now boots from its
embedded snapshot and runs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
snapshot_loadre-resolves the C++ libraries a snapshot references viacore::library_with_name, which accepted a loaded library only if a recorded library name was a path suffix of the loaded library's path:The recorded name is the absolute path captured by
dladdrat save time. So if a snapshot's libraries are later loaded from a different directory than at save — a relocated or bundled install, a different install prefix, or a different machine — the suffix test fails andsnapshot_loadaborts insnapshotSaveLoad.ccwith "Unable to find library: …". On aarch64 Linux, asave-lisp-and-die :executable timageSIGABRTs before its banner once it (and its libraries) are moved.Fix
Match libraries by basename (SONAME) instead of by save-time path suffix. The
nm/dlsymload-address computation that follows already uses the matched, currently-loaded path, so the matcher was the only place bound to the save-time path.This makes
save-lisp-and-dieexecutables and snapshot files relocatable across prefixes/machines — useful for redistributing images and for embedded deployment. It is not aarch64-specific; it helps every platform.Testing
aarch64 Linux (Ubuntu 24.04, LLVM 18,
boehmprecise): a:executablesnapshot whoselibLLVM/libstdc++/libclaspwere relocated into a separate bundle directory and run viaLD_LIBRARY_PATHnow boots from its embedded snapshot and runs (*features*contains:clasp;fib,compile,funcallall work). Same-tree behavior is unchanged (the recorded path's basename equals the loaded basename).🤖 Generated with Claude Code