Skip to content

Conversation

@goniz
Copy link
Contributor

@goniz goniz commented Jan 19, 2026

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

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@goniz goniz force-pushed the feature/portable-musl-dist branch from 580e2e4 to 88a05a9 Compare January 21, 2026 11:20
@goniz goniz marked this pull request as ready for review January 21, 2026 11:21
@goniz goniz changed the title feat(opencode): added linux-x64-musl-portable build feat(opencode): added portable static builds Jan 21, 2026
@goniz goniz force-pushed the feature/portable-musl-dist branch 3 times, most recently from c456a91 to 9e0e2aa Compare January 21, 2026 13:53
- Portable builds are multi arch, supporting linux-x64 and linux-aarch64
- Files in dist/ are called "opencode-linux-*-musl-portable"
- build using: `bun run build && bun run build:portable`
- build requires `docker` to be installed
@goniz goniz force-pushed the feature/portable-musl-dist branch from 9e0e2aa to e2dd9f7 Compare January 21, 2026 17:04
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.

GLIBC_2.18' not found (required by opencode)

1 participant