aboutsummaryrefslogtreecommitdiff
path: root/src/tools/bootstrap-check.sh
blob: a5de3417cb0aefe89f9171ea66f81f1984423acb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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