diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 35 |
1 files changed, 28 insertions, 7 deletions
@@ -58,7 +58,7 @@ WEB := $(B)/web MAP := $(B)/core/map # hand-written core headers, the generated map, and where #embed finds the genome image COREINC := -Isrc/core -I$(MAP) --embed-dir=$(B)/core -CORE_H := src/core/genome.h src/core/fops.h src/core/bops.h src/core/stack.h $(MAP)/memmap.h +CORE_H := src/core/genome.h src/core/fops.h src/core/bops.h src/core/stack.h src/core/hold.h $(MAP)/memmap.h # the sources the compiler genome is built from, and the files it embeds # the compiler is the files named in src/compiler/parts, in that order ZC_PARTS := $(addprefix src/compiler/,$(shell cat src/compiler/parts)) @@ -84,11 +84,32 @@ $(BIN)/zc0$(EXE): src/tools/zc0.c src/core/fops.h src/core/bops.h $(MAP)/memmap. $(BIN)/mkgenome$(EXE): src/tools/mkgenome.c $(MAP)/memmap.h | $(BIN) $(CC) -O1 -w -fwrapv src/tools/mkgenome.c -I$(MAP) -o $@ -# bootstrap: zc0 compiles the compiler to g0, g0 compiles it to g1, g1 to g2. +# bootstrap: the compiler is built from the pinned wasm seed (seed/zc.wasm, the +# microcore with a compiler genome inside, as a WASI module) under node or wasmtime. +# src/boot/boot.sh checks the seed against seed/MANIFEST, then the seed compiles the +# sources to g1, g1 compiles them to g2 (and g2 to g3 unless g1 and g2 already agree); +# the last two must be identical (the fixpoint), so the seed is proven, not trusted. +# no c compiler is involved in compiling the compiler. +SEED_DEPS := seed/zc.wasm seed/MANIFEST src/boot/boot.sh src/boot/run.mjs +genome: $(B)/core/genome.bin +$(B)/core/genome.bin: $(ZC_DEPS) $(SEED_DEPS) $(BIN)/mkgenome$(EXE) $(MAP)/memmap.h + mkdir -p $(B)/boot $(B)/core + sh src/boot/boot.sh $(B)/boot + $(BIN)/mkgenome$(EXE) < $(B)/boot/genome.bin > $(B)/boot/checked.bin + cp $(B)/boot/checked.bin $@ + @echo "fixpoint: $$(( $$(wc -c < $@) / 8 )) words, $@ updated" + +# regenerates the seed from the current genome and rewrites seed/MANIFEST: the seed's +# sha256 and size, the size before wasm-opt, and the sha256 of the image the seed +# reaches at the fixpoint. needs clang with wasm32 and wasm-ld; wasm-opt when found. +seed: $(B)/core/genome.bin + sh src/boot/mkseed.sh --manifest $(B)/core seed/zc.wasm + +# the legacy bootstrap through the c core, kept so nothing is lost: make genome-c. +# zc0 compiles the compiler to g0, g0 compiles it to g1, g1 to g2. # g1 and g2 must be identical (the fixpoint), and g1 becomes build/core/genome.bin. # each stage's core embeds the image beside it, so no stage reads another's. -genome: $(B)/core/genome.bin -$(B)/core/genome.bin: $(ZC_DEPS) $(BIN)/zc0$(EXE) $(BIN)/mkgenome$(EXE) src/core/core.c $(IO) $(CORE_H) +genome-c: $(ZC_DEPS) $(BIN)/zc0$(EXE) $(BIN)/mkgenome$(EXE) src/core/core.c $(IO) $(CORE_H) mkdir -p $(B)/s0 $(B)/s1 $(B)/core cat $(ZC_SRC) | $(BIN)/zc0$(EXE) > $(B)/s0/g0.bin $(BIN)/mkgenome$(EXE) < $(B)/s0/g0.bin > $(B)/s0/genome.bin @@ -98,8 +119,8 @@ $(B)/core/genome.bin: $(ZC_DEPS) $(BIN)/zc0$(EXE) $(BIN)/mkgenome$(EXE) src/core $(CC) $(CFLAGS) -DJTYPE=int src/core/core.c $(IO) -Isrc/core -I$(MAP) --embed-dir=$(B)/s1 -o $(B)/s1/zy1$(EXE) (cat src/tools/build.zc; printf '`'; cat $(ZC_SRC)) | $(B)/s1/zy1$(EXE) > $(B)/s1/g2.bin cmp $(B)/s1/g1.bin $(B)/s1/g2.bin - cp $(B)/s1/genome.bin $@ - @echo "fixpoint: $$(( $$(wc -c < $@) / 8 )) words, $@ updated" + cp $(B)/s1/genome.bin $(B)/core/genome.bin + @echo "fixpoint: $$(( $$(wc -c < $(B)/core/genome.bin) / 8 )) words, $(B)/core/genome.bin updated" # the llvm backend (-DZYLLVM) in zy. -DZYLLVM replaces the x86-64 jit, so on x86_64 hosts # (uname -m) it is built only when LLVM=1 is given; on other hosts it is in whenever an llvm @@ -241,4 +262,4 @@ check: clean: rm -rf $(B) -.PHONY: bench bench-save bench-selftest bench-check all lsp genome js lspimage vsix web run parity xref test check clean +.PHONY: seed genome-c bench bench-save bench-selftest bench-check all lsp genome js lspimage vsix web run parity xref test check clean |
