Skip to content

fix(nix): preserve baseline executable layout - #14

Open
firatoezcan wants to merge 2 commits into
session-resume-apifrom
baseline-elf-layout
Open

firatoezcan wants to merge 2 commits into
session-resume-apifrom
baseline-elf-layout

Conversation

@firatoezcan

@firatoezcan firatoezcan commented Aug 29, 2026 •

Copy link
Copy Markdown
Owner

Issue for this PR

Fork-local packaging regression; no linked issue.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Keep standard Nix Bun as the build runtime. On Linux x86_64, stage the pinned upstream Bun 1.3.13 baseline executable under Bun’s compile-target lookup name, patch only the completed standalone output, and keep Nix stripping from deleting Bun’s appended footer.

The previous override made Nix auto-patch baseline Bun before compilation. Bun then reused that changed ELF as its standalone template, producing an OpenCode binary whose appended payload LOAD preceded its offset-zero LOAD. Bun aborted in ELF mapping before OpenCode started.

How did you verify your code works?

  • Reproduced opencode --version on the exact shipped amd64 image with all capabilities dropped: ElfMapper.cpp:399, exit 133.
  • Evaluated the Linux x86_64 and Darwin aarch64 OpenCode derivations.
  • In a network-disconnected amd64 Nix sandbox, standard Nix Bun 1.3.13 resolved the staged raw baseline target without downloading it. The post-fixup executable retained its bundled program, ran successfully, and had an offset-zero first LOAD.
  • Started the exact-revision full x86_64 flake build. ARM-host emulation stopped in the unchanged models-dev dependency because the emulator exposes no AVX; this happened before the OpenCode derivation ran. The full native amd64 runtime gate remains pending.

Screenshots / recordings

Not applicable.

Checklist

  • I have tested the complete package on native amd64
  • I have not included unrelated changes in this PR

Keep the standard Nix Bun package as the build runtime, and stage the pinned upstream baseline binary only as Bun compile target. This prevents autoPatchelf changes to the compiler from becoming the standalone executable template.
Run autoPatchelf only after Bun appends the standalone payload, and keep Nix stripping from removing its footer. Scope both operations to Linux x86_64.
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