diff options
| author | 2026-10-14 07:28:39 +0000 | |
|---|---|---|
| committer | 2026-10-14 07:28:39 +0000 | |
| commit | 7451eb090d890fb5ea5e4d40627a1b4df15a49de (patch) | |
| tree | 357bdf4b528e860bffa688865306f656b788d2c2 /src/tools/genmap.c | |
| parent | analyzer: close the ownership gaps that stopped the compiler compiling itself (diff) | |
build: embed images with #embed, keep everything generated in build/
the cores take their genome in with c23 #embed through src/core/genome.h,
so images are plain little-endian word files (genome.bin) instead of
generated c headers. zc0 writes that format, mkgenome checks an image
against its map and shows a compiler's diagnostics when it gets them,
and the javascript vm and the editor's vm host read the same files.
src/tools/findcc.sh picks a compiler with #embed (clang 19 or gcc 15).
zc gets an embed declaration, embed "file" as [type] name, for globals
and locals: a byte string by default, char*, numbers read little-endian,
and arrays of numbers. the compiler and language server carry their
library and source texts through it, so embed.sh and the text it
spliced into compiler.zc are gone.
make writes executables to build/bin, the default map to build/core/map,
the web page to build/web and the extension staging to build/vsix, and
the genome now rebuilds when its sources change. the test suite lays
out its own map and bootstrap and reads nothing from build/.
also: rt.put_s of a byte string in zc0 images, retained function
sources no longer count as live objects, a missing include no longer
cascades into undefined-name errors, consecutive comment lines join
into one hover paragraph, and stale test fixtures follow the include
format.
Diffstat (limited to 'src/tools/genmap.c')
| -rw-r--r-- | src/tools/genmap.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tools/genmap.c b/src/tools/genmap.c index 8a258e1..d063d36 100644 --- a/src/tools/genmap.c +++ b/src/tools/genmap.c @@ -609,9 +609,11 @@ static void expect_hex(const char *text, const char *where, const char *name, in static void check_sources(const Map *m) { char lfa_old[64]; + /* a memmap.h in the working directory is compared too, when there is one: the + default map's header is generated into build/core and never kept in the tree */ FILE *mf = fopen("memmap.h", "rb"); - const char *mm_path = mf ? (fclose(mf), "memmap.h") : "src/core/memmap.h"; - char *rt = slurp("src/runtime/rt.zc"), *cc = slurp("src/compiler/compiler.zc"), *mm = slurp(mm_path); + const char *mm_path = mf ? (fclose(mf), "memmap.h") : 0; + char *rt = slurp("src/runtime/rt.zc"), *cc = slurp("src/compiler/compiler.zc"), *mm = mm_path ? slurp(mm_path) : 0; char *rtb = between(rt, "// @map-rt", "// @end-map"); char *ccb = between(cc, "// @map-cc", "// @end-map"); static const char *rt_names[] = { @@ -644,7 +646,7 @@ static void check_sources(const Map *m) if (!strstr(rt, lfa_old)) die("src/runtime/rt.zc no longer has the default lfa immediate"); if (!strstr(cc, "ZFP - 16384")) die("src/compiler/compiler.zc lost its initial type-area formula"); for (i = 0; rt_names[i]; i++) expect_hex(rtb, "src/runtime/rt.zc", rt_names[i], rt_vals[i]); - for (i = 0; rt_names[i]; i++) { + for (i = 0; mm && rt_names[i]; i++) { if (!strcmp(rt_names[i], "MAGIC") || !strcmp(rt_names[i], "HEAP_GROW")) continue; expect_hex(mm, mm_path, !strcmp(rt_names[i], "MW") ? "PW" : rt_names[i], rt_vals[i]); } @@ -700,7 +702,7 @@ static void usage_status(int status) "--preset default has a growing heap above the stacks; fixed is the old 1,081,344-word map.\n" "--grow lets a map with a fixed size get bigger when its genome needs more room.\n" "--mode packs a compiler or a run-only image; spare words go to the data stack.\n" - "--check compares that layout to memmap.h and the checked-in const blocks.\n"); + "--check compares that layout to the checked-in const blocks (and to ./memmap.h if present).\n"); exit(status); } |
