Skip to content

feat: Script for making the SDK self contained - #20

Closed
lurtz wants to merge 1 commit into
Elektrobit:mainfrom
lurtz:add-make-self-contained-script
Closed

lurtz wants to merge 1 commit into
Elektrobit:mainfrom
lurtz:add-make-self-contained-script

Conversation

@lurtz

@lurtz lurtz commented Aug 28, 2026

Copy link
Copy Markdown

At ELF files interpreter and libc have to be compatible. This is achieved by either calling relocate-sdk.sh, which sets the interpreter, using the host interpreter and libc or wrapping all executables so that the interpreter from the SDK is used.

This wraps the executables so that the SDK is usable without extra setup steps.

At ELF files interpreter and libc have to be compatible.
This is achieved by either calling `relocate-sdk.sh`,
which sets the interpreter, using the host interpreter and
libc or wrapping all executables so that the interpreter
from the SDK is used.

This wraps the executables so that the SDK is usable
without extra setup steps.
@lurtz
lurtz requested review from a team and a lite review from Copilot August 28, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new helper script to make extracted SDK trees usable “as-is” (without running relocate-sdk.sh) by wrapping SDK-provided host executables with a shell launcher that invokes the SDK’s dynamic loader with an explicit --library-path.

Changes:

  • Introduces scripts/make-self-contained.sh to rename ELF host executables to *.real and replace them with loader-based wrappers.
  • Scans the same SDK executable directories as the existing relocation tooling to decide what to wrap.
Suppressed comments (1)

scripts/make-self-contained.sh:86

  • The wrapper currently hard-codes the loader path ($sdk/usr/lib/.../ld-linux-x86-64.so.2) instead of using the loader that was validated earlier. If the loader is found in a different location (e.g., /lib64/...), the script may pass the initial check but produce wrappers that fail at runtime. Embed the validated loader path (relative to sdk_root) into the wrapper.
here=\$(dirname "\$(readlink -f "\$0")")
sdk=\$here/$rel_to_root
exec "\$sdk/usr/lib/$arch-linux-gnu/ld-linux-x86-64.so.2" \\
    --argv0 "\$0" \\
    --library-path "\$sdk/usr/lib/$arch-linux-gnu:\$sdk/lib/$arch-linux-gnu" \\

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +37 to +42
search_dirs=()
for pattern in "$sdk_root"/usr/bin "$sdk_root"/usr/sbin \
"$sdk_root"/usr/lib/gcc* "$sdk_root"/usr/libexec/gcc* \
"$sdk_root"/usr/lib/llvm*/bin; do
[ -d "$pattern" ] && search_dirs+=("$pattern")
done
Comment on lines +27 to +33
arch=$(uname -m)

loader="$sdk_root/usr/lib/$arch-linux-gnu/ld-linux-x86-64.so.2"
if [ ! -x "$loader" ]; then
echo "error: SDK loader not found at $loader" >&2
exit 1
fi
# Snapshot the file list up front: renaming files while `find` is still
# walking the tree would let it re-discover freshly created "*.real" files
# as if they were new binaries, and wrap them a second time.
mapfile -d '' -t binaries < <(find "${search_dirs[@]}" -type f -perm -u+x -print0 2>/dev/null)
@lurtz

lurtz commented Aug 28, 2026

Copy link
Copy Markdown
Author

Further testing in S-CORE reference_integration revealed that this broke the Rust build. Since patching INTERP seems to be accepted, I abandon this.

@lurtz lurtz closed this Aug 28, 2026
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