[PR #9430] feat(opencode): added portable static builds #13104

Open
opened 2026-02-16 18:17:58 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9430

State: open
Merged: No


What does this PR do?

This PR adds support for building a variant of opencode cli that runs on non glibc / old distros.

OpenCode uses Bun’s build feature that creates a single file executable, but Bun does not provide truly static binaries.

This solution tries to solve the problem by bundling the musl variant and its required shared libraries in a Rust based single static executable that unpacks and runs the cli on runtime.
I’m using patchel to set the elf interpreter after extraction to direct the cli to the right libs.

How did you verify your code works?

Existing opencode install on Ubuntu 16.04:
image

Using this method:
https://github.com/user-attachments/assets/0846d5ab-c4f7-42fa-ab57-145a0fbeab53

Notes

I've used Rust since it provides a static musl target and the repo already has Rust code (desktop, tauri)

TODOs

  • Support aarch64
  • Integrate into build.ts
  • Add documentation

Fixes #4908

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9430 **State:** open **Merged:** No --- ### What does this PR do? This PR adds support for building a variant of opencode cli that runs on non glibc / old distros. OpenCode uses Bun’s build feature that creates a single file executable, but Bun does not provide truly static binaries. This solution tries to solve the problem by bundling the musl variant and its required shared libraries in a Rust based single static executable that unpacks and runs the cli on runtime. I’m using patchel to set the elf interpreter after extraction to direct the cli to the right libs. ### How did you verify your code works? Existing opencode install on Ubuntu 16.04: ![image](https://github.com/user-attachments/assets/17fd779f-2d3a-4350-846d-c8739dbdb34b) Using this method: https://github.com/user-attachments/assets/0846d5ab-c4f7-42fa-ab57-145a0fbeab53 ### Notes I've used Rust since it provides a static musl target and the repo already has Rust code (desktop, tauri) ### TODOs - ~Support aarch64~ - Integrate into build.ts - Add documentation Fixes #4908
yindo added the pull-request label 2026-02-16 18:17:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13104