Skip to content

infra: dev container + cross-arch toolchains - #12

Merged
mahaloz merged 1 commit into
mainfrom
infra/devcontainer
Jun 23, 2026
Merged

mahaloz merged 1 commit into
mainfrom
infra/devcontainer

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

First PR of the analysis-port fan-out: a fully reproducible dev container for (a) building & testing kuna and (b) building cross-architecture ELF test fixtures including their linkers, plus Go and a pinned Rust toolchain. Env-only image (the repo is mounted at runtime, not COPYed); base ubuntu:22.04 to keep the vendored cross-arch fixtures reproducible.

The unblock (before → after)

The build host has no ARM linker, which blocked the documented ARM decode end-to-end test (see docs/analysis-port-log.md, Increment 17). The container fixes this.

  • Host, before: which arm-linux-gnueabihf-gcc → empty (no ARM gcc/ld; aarch64/riscv linkers also absent).
  • Container, after: links a PT_LOAD, Type EXEC, Machine ARM Thumb executable.
$ printf 'int f(int x){return x+1;} void _start(){f(41);}' > /tmp/thumb.c
$ arm-linux-gnueabihf-gcc -mthumb -static -nostdlib -e _start /tmp/thumb.c -o /tmp/arm_thumb_linked
$ readelf -h /tmp/arm_thumb_linked
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Entry point address:               0x100d1          # odd => Thumb bit set
$ readelf -l /tmp/arm_thumb_linked
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x00010000 0x00010000 0x000de 0x000de R E 0x10000
  NOTE           0x000094 0x00010094 0x00010094 0x00024 0x00024 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10

A LINKED ARM Thumb ELF with an executable LOAD segment — the previously-blocked e2e fixture is now buildable in-env.

Toolchain inventory

Category Packages → commands
Core build build-essential make cmake pkg-config gcc g++ clang lld (ld.lld)
Rust rustup, toolchain 1.90.0 (default; matches decompiler/Cargo.toml), rustfmt+clippy, on the dev PATH
ARM32/Thumb gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf → arm-linux-gnueabihf-{gcc,g++,ld} (GCC 11.4.0)
AArch64 gcc-aarch64-linux-gnu g++-aarch64-linux-gnu → aarch64-linux-gnu-{gcc,g++,ld} (11.4.0)
RISC-V64 gcc-riscv64-linux-gnu → riscv64-linux-gnu-{gcc,ld} (11.4.0)
MIPS gcc-mips-linux-gnu gcc-mipsel-linux-gnu gcc-mips64el-linux-gnuabi64 → mips[/el/64el]-…-{gcc,ld} (10.3.0)
PPC64le gcc-powerpc64le-linux-gnu → powerpc64le-linux-gnu-{gcc,ld} (11.4.0)
SPARC64 gcc-sparc64-linux-gnu → sparc64-linux-gnu-{gcc,ld} (11.4.0)
Binary inspection binutils-multiarch file
Languages/tools golang-go (Go 1.18) python3 python3-pip git curl wget ca-certificates gnupg unzip xz-utils gdb sudo less vim

Every gcc-<triple> pulls binutils-<triple>, so all 8 cross linkers are present (verified /usr/bin/<triple>-ld for each). Non-ELF toolchains (mingw-w64 / osxcross) are intentionally out of scope; the container is privileged with passwordless sudo so an agent can apt-get install them later. No package-name substitutions were needed — every requested gcc-<triple> exists under its exact name on 22.04 (only note: the MIPS cross GCCs ship at 10.3.0 vs 11.4.0 for the others; stock packaging).

Container policy

devcontainer.json sets privileged: true + runArgs: ["--privileged"], remoteUser: dev, workspaceFolder: /workspaces/kuna; the dev user (uid 1000) has passwordless sudo. Privileged + sudo are intentional per project policy (always able to run privileged / install anything without rebuilding the image), noted inline in both files.

Verification run + results

# Command Result
1 docker build -t kuna-dev -f .devcontainer/Dockerfile .devcontainer PASS — image built; baked sanity gate confirmed rustc 1.90.0, cargo 1.90.0, arm-linux-gnueabihf-gcc 11.4.0.
2 docker run --rm -v "$(pwd)":/workspaces/kuna -w /workspaces/kuna kuna-dev bash -lc 'make binaries' PASS — full workspace (kuna-console, kuna-harness, kuna-slacomp, kuna-cli + deps) built in 28.9s, exit 0; kuna --help runs. (Ran the full make binaries, not just kuna-cli.)
3 ARM link proof (above) PASS — Type EXEC, Machine ARM, LOAD segment (R E), Thumb-bit entry 0x100d1.

make test / make rust-test were not run here (this is infra+docs only; no engine code changed) — they remain the gates later analysis-port PRs will run inside this container.

Docs

Scope: only .devcontainer/ + docs/; no code touched; no build artifacts committed (decompiler/target/ is gitignored).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb

…n-out

Reproducible environment for building/testing kuna and for building
cross-architecture ELF test fixtures (with their linkers). Env-only image
(repo mounted at runtime); base ubuntu:22.04 to keep vendored fixtures
reproducible. The headline unblock: the host had no ARM linker, which blocked
the documented ARM decode e2e — the container now links PT_LOAD ARM ELFs.

Provided:
- .devcontainer/Dockerfile — ubuntu:22.04; core build (build-essential, cmake,
  clang, lld); every cross toolchain WITH its binutils/linker (ARM32/Thumb,
  AArch64, RISC-V64, MIPS/MIPSel/MIPS64el, PPC64le, SPARC64); binutils-multiarch
  + file; Go/python3/git/etc; non-root `dev` (uid 1000) + passwordless sudo;
  Rust pinned to 1.90.0 via rustup as `dev`. Baked-in sanity gate (rustc 1.90.0
  + arm-linux-gnueabihf-gcc).
- .devcontainer/devcontainer.json — name kuna-dev, privileged + --privileged,
  remoteUser dev, workspaceFolder /workspaces/kuna, postCreate prints versions.
- docs/devcontainer.md — build/use, gates, cross-arch fixture how-to, inventory.
- docs/analysis-port-frontier.md — the live work-list / progress tracker for the
  analysis-port fan-out (this is item #1).

Verified: image builds; `make binaries` builds the full workspace in-container
(exit 0); linked ARM Thumb ELF readelf shows Type EXEC, Machine ARM, a LOAD
segment (Thumb-bit entry 0x100d1).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
@mahaloz
mahaloz merged commit 7e0937e into main Jun 23, 2026
@mahaloz
mahaloz deleted the infra/devcontainer branch July 29, 2026 08:01
mahaloz added a commit that referenced this pull request Sep 17, 2026
…e SUB41 intrinsic

Review round 2 on boolbyte.  `CastStrategyC::isSubpieceCast` (cast.cc:411-432)
lists the destination metatypes a SUBPIECE may print as a cast and TYPE_BOOL is
not among them, because upstream never puts one there.  Once `boolbyte` does, a
truncation into that byte fell to the functional arm and printed the raw
`SUB41(x,0)` p-code intrinsic -- an undeclared identifier, and the class
`subright` exists to keep out of the emitted C.

`kuna_boolbyte::truncation_prints_as_cast`, consulted from
`printc::subpiece_is_cast`, supplies the missing arm.  It is part of the option,
so `boolbyte off` is byte-for-byte what it was.  Whole-binary counts of the
intrinsic now go DOWN with the option on, never up: 7 -> 0 over the sixteen
sweep binaries (tar -O2 4 -> 1, ls -O2 1 -> 0, du -O0 1 -> 0, find -O0 1 -> 0);
three of those are cases a comparison alone had already made bool without this
rule.

Also in this commit:
- tests/stages/kuna-boolbyte.xml gains `truncjoin` and assertions #11/#12: pass 1
  (off) is the SUB41 the printer emits without the arm, pass 2 (on) is the cast.
- docs/spec/05-types.md replaces the false "the declaration is all that changes;
  the body is untouched" with the measured surface: constant re-rendering,
  truncation re-rendering, and the speculative-merge splits that move a
  declaration count or which variable an expression names.
- the three count ladders in kuna_phases/tests.rs get their missing
  "+1 for `boolbyte`" comment lines.
- plan.md's change_kind corrected to type-inference; record.json's corpus block
  re-measured (100 functions change: 89 declaration-and-literal only, 6
  declaration-count, 1 merge-shape, 4 SUBnn -> cast).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz added a commit that referenced this pull request Sep 17, 2026
…ation assertions

Adds boolbyte #11/#12 and the reworded #3, and drops the stray trailing newline
so the file is byte-for-byte what `kuna test --save-baseline` writes (main's copy
has none either).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MAeimyWm5oSewpeCgAwY29
mahaloz added a commit that referenced this pull request Sep 18, 2026
A call argument narrower than int that the caller zero-extends kept no
truncation in the printed C, so C's integer promotion handed the callee a
different value than the binary passes (f: sink(a0 * 3) for a movzx'd
16-bit product). When subvariable flow trims a call argument and every
dropped bit is known zero, the trim is recorded on the call, and emission
casts that argument to the unsigned type of its width unless promotion
already zero-extends it or the value provably fits. clang-forwarded narrow
parameters (no zero-extension evidence) stay uncast. C output only; no
option, since it restores a conversion the binary performed.

Tests: tests/stages/kuna-truncarg.xml (12 assertions; #1-#4 and #8 fail on
main, #11/#12 are clang forwarding guards). Round trip over 719 values:
main 309 wrong, this change 0 new wrong under gcc and clang.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
mahaloz added a commit that referenced this pull request Sep 25, 2026
… buffer; castternary reads a typed global's element; a stored counter keeps its sign

- A negation (p * -1, the right-hand side of a pointer difference) is not a
  number use, and an add partner dereferenced through copies or a small
  literal offset is the base: put1(char *buf, size_t len, ...) keeps len a
  number (libedit keymacro__decode_str too).
- A later type pass that finds a parameter or call return an earlier pass
  typed indexing another base blocks it and restarts the function.
- castimplied reads the element type of dat_X[i] from the header declaration
  of an unnamed global typed a pointer, so castternary drops the (int) the
  conditional performs.
- A value stored through a pointer elemptr typed keeps its own sign (an int
  counter stored into an unsigned table stays int).
- Fixture gains w_put and w_ctr (stage test #12-#16, round trip line 3).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01V6bguCkPS65cu9ejj1fbpy
mahaloz added a commit that referenced this pull request Sep 27, 2026
…tion only for an integer operand

The store and other-signedness destinations now require an operand that
prints as a C integer (not bool, not a 6-byte undefined or a CONCAT) which C
extends the way the widening does.  DWARFVARIANTS #12 returns to main's
dst->tag = (uint8)(x < 0xb).  semhunks.py: a ring op (+ - * & | ^) at 64 bits
is checked by the type its chain ends with; a destination of the cast's own
type is verified; wide character literals parse.  The spec prose states the
shared, parenthesized and regrouped rules and the 8-byte destination scope.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01V6bguCkPS65cu9ejj1fbpy
mahaloz added a commit to thotypous/kuna that referenced this pull request Oct 14, 2026
… at the global alias level only

Below `option indexaliasguard global` nothing keeps a load's own variable
when it is live across a store to a global (kuna_loadorder runs only at that
level), so the kept COPY printed its single-use LOAD after such a store:
d_mv in the globalloadguard fixture went from `gi = *a0; gj = 0;` to
`gj = 0; gi = *a0;` at `load` and `off`, while the binary loads *p before the
gj store and main() aims p at gj. The refusal now runs only at `global`.

Keeping the COPY also moves correct output (storage comments drop the global,
a stored value can print as its own variable, independent stores swap), so
it is a named option, `globalcallstore`, default on: 0/675 datatest
assertions move. `off` is byte-identical to main. The stage test gains an
off pass that prints the write before the getter, and globalloadguard Noelo-Lab#12
pins the `load` output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015sdZpNU5odw5dVyaxeSvvz
mahaloz added a commit that referenced this pull request Nov 18, 2026
…gains nothing

Adds `outer` to the sharedpush fixture: `if (sel) free(p); else
pair(guard_nop(), p);`, where p is pushed once for free and for pair's
second argument, so guard_nop runs on the slot pair reads afterwards.
The only-reader condition keeps guard_nop from taking p; without it
guard_nop(p) is printed (stage assertion #12). The spec and module
header now also say the rule does not read the undeclared callee's own
arity. No code change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz added a commit that referenced this pull request Nov 18, 2026
Two of the push-run readings for the frame a declared call leaves misread
GCC/MinGW code, found on held-out builds:
- The `mov [esp],x` local test took a push for a mov when the push landed
  on the stack pointer the declared call left after a raise (GCC's
  `call [Sleep]; add esp,12; push; push; push; push; call [f]` around a
  padded call): the run stopped at the third push and f was guessed to pop
  12 bytes too few. The simplifier has already removed such a push's
  stack-pointer write, so the store's instruction bytes say whether it is a
  push; only a mov ends the run.
- The entry-value test counted ECX's entry value written with MinGW's fixed
  frame `mov [esp],ebx` as an argument push, so a __cdecl callee was
  guessed to pop it and the function gained a phantom parameter. Only a
  pushed entry value counts now.
The fixture gains land_push and acc_entry; stage asserts #12 and #13
fail without this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz added a commit that referenced this pull request Nov 22, 2026
Indexed stack-pointer discovery runs once, on the stack space's first
heritage pass, and stopped where a stack-pointer value was written to a
frame slot: the slot's reads are not linked to the write until that pass
renames the space. gcc -O0 keeps `p = &st[0]` in a local and reloads it for
each p[i]; Tigress pushes &locals[k] on its virtual stack for every access.
The LOAD through the reloaded pointer got no guard, a slot written directly
and read only through it had no reader, and ActionDeadCode deleted the
store, then redundbranch the branch around it. Tigress script_0_57 lost
`if (...) { swap halves of state[1]; state[1] |= (state[4] & 15) << 3; }`
before its `state[local1]` loop; native f_spill lost `if (a > 5) st[1] |= 0x78`.

Discovery now continues from the unlinked reads of a slot a path value was
spilled to and guards the LOADs it reaches (LoadGuard::through_spill);
STOREs stay with the rerun after renaming, as upstream. In the pass that
found it, an unbounded spill guard forces writes only below the lowest
pointer-spill slot above its base, so the spilled pointers themselves are
not kept as variables (dupptr #3/#5); later passes force the full window.

Tests: tests/stages/kuna-spillptr-loadguard.xml (native, one pass);
kuna-pushan-interp.xml #11/#12 on a new Tigress-style tg_indexed in the
pushan_interp_x86_64 fixture (both fail before, pass after). Stage
baseline re-recorded: 5032 -> 5037 passing keys, the five new assertions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQR2hseBprKvbvZRUv
mahaloz added a commit to sjkim1127/kuna that referenced this pull request Nov 24, 2026
The alignment-pad exception read a store of the last argument register
beneath a higher register anywhere in the entry as proof the function is not
variadic. clang -Oz reserves stack by pushing dead registers and then saves
the variadic registers: `sub sp, Noelo-Lab#12; push {r3, r4, lr}; stm r0!, {r1, r2,
r3}` (or `str r3, [sp, Noelo-Lab#20]`). Its sqlite3_mprintf then handed
sqlite3_vmprintf its save area and took r1-r3 as three more parameters.

The entry walk now also records the register bytes a multi-register store
writes as its highest register, and the pad counts only when the register is
stored no other way (not alone, not as the highest of a store). The check is
only ever narrower than before, so every call it changes returns to the
output it had before the pad exception.

Stage gh1922-pushpad-caller-readarg-thumb.xml gains #4, a clang -Oz shaped
variadic caller (pad push plus stm save) that must still decline.

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