aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:02:46 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:02:46 +0330
commitdb89626d1be6f0c700d11134cac07e57d09315ba (patch)
tree860c51f8468f165087db6c9aa1e15de512096660 /src/tools
parentbuild: generate everything into build/, keep src/ free of generated files (diff)
docs: record the two ownership gaps that block the bootstrap
`make genome` cannot complete: the second bootstrap stage runs the lifetime checker over the compiler's own source, which reports 8 errors, and mkgenome then reads the diagnostics as an image. the two limits are that an owned value held in a local has no move into another local — every accepted move originates at a call, so the free-then-replace rule only applies when the replacement comes from a call result — and that a local cannot be lent to a global, so redirecting the output stream at a scratch buffer needs a module-level variable. neither limit accepts an unsafe program; both refuse correct ones, so this is a completeness gap rather than a soundness failure. document the affected code, the diagnostics, what was tried and how each attempt failed, and a proposal. add src/tools/bootstrap-check.sh, which rebuilds both bootstrap stages and prints the compiler's diagnostics on its own source instead of the word dump.
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/bootstrap-check.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tools/bootstrap-check.sh b/src/tools/bootstrap-check.sh
new file mode 100755
index 0000000..a5de341
--- /dev/null
+++ b/src/tools/bootstrap-check.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# rebuild the bootstrap one stage and report what the compiler says about itself.
+# zc0 (stage 0) compiles rt+core+compiler into build/s0, s0 becomes zy0, and zy0
+# runs build.zc over the same sources to produce the image. ownership diagnostics
+# come back in the image, so print them instead of the word dump.
+set -e
+cd "$(dirname "$0")/../.."
+mkdir -p bin build/s0 build/s1 build/core
+cc -O1 -w -fwrapv src/tools/zc0.c -Isrc/core -o bin/zc0
+cc -O1 -w -fwrapv src/tools/mkgenome.c -Isrc/core -o bin/mkgenome
+cp src/core/core.c src/core/io_linux.c src/core/memmap.h src/core/fops.h src/core/bops.h src/core/stack.h build/s0/
+cat src/runtime/rt.zc src/core/core.zc src/compiler/compiler.zc | bin/zc0 > build/s0/genome.h
+cc -O2 -w -fwrapv -pthread -DJTYPE=int build/s0/core.c build/s0/io_linux.c -o build/zy0
+(cat src/tools/build.zc; printf '`'; cat src/runtime/rt.zc src/core/core.zc src/compiler/compiler.zc) | build/zy0 > build/g1.bin
+if ! grep -q '^zc: ' build/g1.bin 2>/dev/null; then
+ echo "image ok: $(wc -c < build/g1.bin) bytes"
+else
+ echo "--- compiler diagnostics on its own source ---"
+ cat -v build/g1.bin
+fi \ No newline at end of file