aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
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