Skip to content

bib: C and C++ feasibility plan (go-embedded-c, go-embedded-cpp) - #20

Merged
tannevaled merged 1 commit into
mainfrom
bib-c-cpp
Nov 1, 2026
Merged

tannevaled merged 1 commit into
mainfrom
bib-c-cpp

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Adds bib/c-cpp.md, the bibliography and feasibility plan for C and C++ notebook cells in pure Go (go-embedded-c, go-embedded-cpp), following bib/julia.md and bib/TEMPLATE.md.

Decisions:

  • C: reuse modernc.org/cc/v4 (BSD-3) as the front end. It runs with a hand-made Config and no host compiler, also as GOOS=wasip1 under wazero, and adds about 3.9 MB to a GOOS=js binary. Write a C → wasm32 code generator and a cell runtime (shared memory and table) on wazero, with the browser engine in the playground. libc is wasi-libc. ccgo is rejected because it needs go build at cell time and modernc libc has no js/wasip1 target. A tree interpreter is rejected because it would be slower than the reference.
  • C++: no front end of our own: clang/lib/Sema alone is 333 996 lines at llvmorg-23.1.4, and libc++ headers are 330 575 lines. The plan is clang-repl compiled to wasm (the CppInterOp build that xeus-cpp-lite uses) on the C runtime, behind a measured gate. Today, wazero v1.12.0 refuses the 71 256 623-byte clang module because it uses legacy exception handling (0x06). Native clang-repl delegation is rejected.

Also adds two measurement tools, both with 100 % coverage:

  • tools/srccount counts files, lines and bytes.
  • tools/wasmimports validates a module with wazero and lists what its host must provide.

The README index is updated. This change adds the github.com/tetratelabs/wazero v1.12.0 dependency for tools/wasmimports.

🤖 Generated with Claude Code

bib/c-cpp.md: sources pinned (N1570, N2310, llvmorg-23.1.4, cc/v4
v4.30.5, ccgo v4.38.0, libc v1.79.1, xeus-cpp 0.10.0, CppInterOp
v1.9.0, emscripten 4.0.9, wazero v1.12.0, wasi-libc, gcc 15.2.0,
c-testsuite, csmith), measured sizes, the decision for each language,
plan table and risks.

C: reuse modernc.org/cc/v4 (runs with a hand-made Config, also as
GOOS=wasip1 under wazero), write a C -> wasm32 code generator and a
cell runtime, libc = wasi-libc. C++: clang-repl compiled to wasm on
the same runtime, behind a measured gate (wazero v1.12.0 refuses the
71 MB clang module: legacy exception handling).

tools/srccount counts files, lines and bytes; tools/wasmimports
validates a module with wazero and lists what its host must provide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit b6fd6ec into main Nov 1, 2026
1 check passed
@tannevaled
tannevaled deleted the bib-c-cpp branch November 1, 2026 10:22
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