Skip to content

[AUTOMATED] Ship kuna as one self-contained binary - #1067

Merged
mahaloz merged 2 commits into
mainfrom
feat/single-binary
Oct 13, 2026
Merged

mahaloz merged 2 commits into
mainfrom
feat/single-binary

Conversation

@mahaloz

@mahaloz mahaloz commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

A release kuna cannot decompile by itself. It needs decomp_dbg beside it and the separate kuna-v<ver>-specs.tar.gz extracted next to it, so someone handed only the platform archive, or only the binary, fails on the first run. With v1.818's static Linux build:

$ tar xzf kuna-v1.818-linux-x86_64-musl.tar.gz
$ ./kuna-v1.818-linux-x86_64-musl/kuna decompile ./a.out main
error: no SLEIGH specs found in .../kuna-v1.818-linux-x86_64-musl/specs, .../specs -- set KUNA_SPECS to a specs/ directory (from the kuna-v<ver>-specs release archive), or run `make specs` in a checkout

$ cp kuna-v1.818-linux-x86_64-musl/kuna solo/ && ./solo/kuna decompile ./a.out main
error: decomp_dbg not found in .../solo -- set KUNA_DECOMP_DBG to point at it, or run `make binaries` (or `cargo build --release -p kuna-console`)

On Windows the same setup reports could not build an architecture ... No sleigh specification.

With this change, each release archive holds just kuna (plus LICENSE/NOTICE), and that one file works anywhere:

$ ./kuna decompile ./a.out main      # empty directory, no KUNA_SPECS
unsigned long main(void)
{
  return 0x2a;
}

Changes

  • decomp_dbg and slacomp are now library entry points (kuna_console::consolemain, kuna_slacomp::slacompmain). The standalone binaries are thin wrappers around them, and kuna runs them as the hidden subcommands kuna decomp_dbg / kuna slacomp. decompile, catalog and specs re-launch the running kuna, so the console stays a separate process, as before. KUNA_DECOMP_DBG, KUNA_SLACOMP and --decomp-dbg still select a separate binary.
  • New cargo feature embed-specs (release CI turns it on). It builds the compiled specs/ tree, without the SLEIGH sources, into kuna. The engine reads specs from disk, so on first use the tree is unpacked once to ~/.cache/kuna/specs-<content hash>/ (%LOCALAPPDATA%\kuna on Windows, ~/Library/Caches/kuna on macOS, the system temp directory as a fallback). Each unpack is staged and then renamed into place, so concurrent first runs are safe. KUNA_SPECS and KUNA_ROOT still take precedence.
  • Release CI builds kuna after the specs job and smoke-tests the binary alone in an empty directory. kuna-v<ver>-specs.tar.gz is still published.

Binary size: +15 MB uncompressed (the .sla files are already compressed). Unpacking costs about 45 ms, once. Decompile latency is unchanged: separate decomp_dbg vs self-launch on the same build were both 155–170 ms.

Tests

  • tests/single_binary_cli.rs copies kuna into an empty directory. It checks that kuna decompile works there with no decomp_dbg, and that kuna specs with no slacomp produces a toy_be.sla byte-identical to the one make specs builds. Both fail on main.
  • Unit tests for the unpack: layout, reuse of a finished tree, replacing a tree without its marker, and 8 concurrent first runs ending with one tree.

🤖 Generated with Claude Code

https://claude.ai/code/session_013GVEdwXAANr7pVSXo5czqb

mahaloz and others added 2 commits October 13, 2026 16:37
[AUTOMATED]

A release archive shipped kuna, decomp_dbg and slacomp, and the compiled
SLEIGH tree as a separate asset. Anyone handed only the platform archive got
"could not build an architecture ... No sleigh specification" on the first
decompile.

- The decomp_dbg and slacomp mains move into their libraries
  (kuna_console::consolemain, kuna_slacomp::slacompmain). The binaries are now
  thin wrappers, and kuna runs either one as a hidden subcommand. decompile,
  catalog and specs re-launch the running kuna instead of looking for
  siblings. KUNA_DECOMP_DBG / KUNA_SLACOMP / --decomp-dbg still pick a
  separate binary.
- The cargo feature embed-specs (build.rs) builds every file under specs/,
  except the SLEIGH sources, into kuna as an include_bytes! table with a
  content id. specs_dir() unpacks it once into the per-user cache directory
  (system temp as a fallback), staged and renamed into place. KUNA_SPECS and
  KUNA_ROOT still win.
- Release CI builds kuna after the specs job, with embed-specs, ships only
  kuna + LICENSE + NOTICE, and smoke-tests the binary alone in an empty
  directory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013GVEdwXAANr7pVSXo5czqb
@mahaloz
mahaloz merged commit edba009 into main Oct 13, 2026
9 checks passed
@mahaloz
mahaloz deleted the feat/single-binary branch October 13, 2026 17:10
mahaloz added a commit to TsingShui/kuna that referenced this pull request Oct 15, 2026
[AUTOMATED] Resolve conflicts with the single-binary console (Noelo-Lab#1067): the
explicit external route now runs the resolved decomp_dbg Program, and the
docs describe the in-process catalog beside the built-in console.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RVkhSR3PZKoRmKDbGHjfqH
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