Open and answer this issue on GitHub.
decision · opened 2026-10-24 · updated 2026-10-24 · 0 comments
The owner asked (2026-10-24) whether the compiler can be modularised, perhaps with dynamic linking, so that prebuilt parts stay while others change, and so that builders can later run in parallel. The architect checked the code and wrote the decision basis: docs/modular-compiler.md.
crates/nikaia-std/src/tools/package.rs (73 k lines, all 213 .nika files) is one Rust module, so one codegen unit: in the fast profile’s incremental session it is one 7.4 MB object with 1 832 of the tools functions; codegen-units = 256 only merges modules, never splits one. Any .nika change re-optimises it on one core.crates/nikaia (48 k lines Rust) has cycles between all its large modules (parser -> check -> emit -> parser, contracts <-> emit): no crate split without breaking them, on code that is moving to Nikaia (68.8 % moved)..nika files form one strongly connected component of about 143 files (name-level approximation): no crates per file yet.cdylib boundary needs a serialised interface the shared types do not have.Do: one module per .nika (#667 step 4), one generated file per .nika, one integration-test binary; then stage 2 with a worktree and CARGO_TARGET_DIR per builder, on disjoint files. Not: a crate split of crates/nikaia, dylib, cdylib plugins. Later: a nikaia-tools crate, nextest/sccache in CI.
lower-std writes each .nika’s body as mod <file>_body { use super::*; ... } plus pub use <file>_body::*; (private items lower pub(super)). Test: the sysroot test; the count of changed .o bytes in target/fast/incremental/nikaia_std-*/s-* after a one-line .nika change, before and after (method in the doc). Keep only if it falls..nika (tools/lowered/<file>.rs, include!d by step 1’s modules); CI’s freshness check and scripts/self_hosting.py follow. Test: the sysroot test, scripts/self_hosting.py unchanged share.crates/nikaia/tests/it/main.rs, one module per former file, common once); CLAUDE.md and .claude/agents/builder.md: --test a becomes --test it a::. Test: the same number of tests pass as before (count from cargo test -- --list); bytes in target/fast after --no-run, before and after.docs/architect.md: stage 2 conditions (worktree + own CARGO_TARGET_DIR, disjoint .nika files and adapters, one builder at a time on emit/mod.rs, check/mod.rs, project.rs).Step 1 is ready (it is #667’s); steps 2-4 wait for the owner’s yes to the direction.