make docker-check, the scripts on BSD's tools, the budget at 18,000 PLAN.md 5, step 2. containers/check/Dockerfile and make docker-check run make check in a linux/amd64 container, for a Mac until raz runs there; under Rosetta, test/check.sh skips the 9 tests Rosetta breaks (its own descriptors 3 to 6, its mmap under ulimit -v, a stack fault's locals), each saying why. The Makefile and scripts run on BSD's tools: test/nanos.sh for date +%s%N, shasum where sha256sum isn't, getconf for nproc. The budget is 18,000 lines of code, by the owner's word.
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | |
| 11 | 11 | make raz # the compiler, ./raz, built from src/ by the release BOOT names; its library is lib/ |
| 12 | 12 | make check # every example and test against its expected output |
| 13 | + make docker-check # make check in a linux/amd64 container, on a Mac; under Rosetta it skips 9 tests, each saying why | |
| 13 | 14 | make bench # must report at least 400,000 lines a second |
| 14 | 15 | make prev-bench # the compiler's speed against BOOT's: more than a tenth slower fails |
| 15 | 16 | make kernels # test/bench's kernels against FPC -O2's twins (apt-get install -y fp-compiler) |
| @@ -60,8 +61,8 @@ | ||
| 60 | 61 | `Luis <42945842+ldiaz94@users.noreply.github.com>`, unsigned |
| 61 | 62 | (`--no-gpg-sign`), no attribution trailer. Push to `main`. No pull |
| 62 | 63 | requests unless asked. |
| 63 | -- Budget: never past 14,000 lines of code (raised from 8,500, then | |
| 64 | - from 11,000, by the owner's word, who dropped the soft limit; blank and | |
| 64 | +- Budget: never past 18,000 lines of code (raised from 8,500, then | |
| 65 | + from 11,000 and 14,000, the last for the arm64 macOS port, by the owner's word, who dropped the soft limit; blank and | |
| 65 | 66 | comment lines not counted), with the compiler documented and |
| 66 | 67 | commented throughout, most of all where it is obscure or needs a |
| 67 | 68 | compiler writer's knowledge; at least 400,000 lines of raz a second; |
| @@ -54,9 +54,9 @@ | ||
| 54 | 54 | # the best of three runs; fails below 400,000 lines a second |
| 55 | 55 | bench: raz | build |
| 56 | 56 | sh test/genbench.sh 12000 > build/Bench.raz |
| 57 | - @lines=$$(wc -l < build/Bench.raz); best=0; \ | |
| 57 | + @lines=$$(($$(wc -l < build/Bench.raz))); best=0; \ | |
| 58 | 58 | for i in 1 2 3; do \ |
| 59 | - start=$$(date +%s%N); ./raz build/Bench.raz || exit 1; end=$$(date +%s%N); \ | |
| 59 | + start=$$(sh test/nanos.sh); ./raz build/Bench.raz || exit 1; end=$$(sh test/nanos.sh); \ | |
| 60 | 60 | t=$$((end - start)); if [ $$best = 0 ] || [ $$t -lt $$best ]; then best=$$t; fi; \ |
| 61 | 61 | done; \ |
| 62 | 62 | rate=$$((lines * 1000000000 / best)); \ |
| @@ -207,4 +207,18 @@ | ||
| 207 | 207 | site-check: build/site/Verify |
| 208 | 208 | build/site/Verify |
| 209 | 209 | |
| 210 | -.PHONY: prev-bench fixpoint check gdb bench kernels stress alpine fmt loc man pdf dist site site-source site-check clean install uninstall | |
| 210 | +.PHONY: docker-image docker-check docker-shell prev-bench fixpoint check gdb bench kernels stress alpine fmt loc man pdf dist site site-source site-check clean install uninstall | |
| 211 | + | |
| 212 | +# `make check` in a linux/amd64 container, for a machine that isn't one | |
| 213 | +# (the repository is mounted at its own path, so git and the tests see | |
| 214 | +# the same names). DOCKERFLAGS is for what a host's runtime needs. | |
| 215 | +DOCKER = docker run --rm --platform linux/amd64 $(DOCKERFLAGS) -v $(CURDIR):$(CURDIR) -w $(CURDIR) | |
| 216 | +DOCKERIMAGE = raz-check | |
| 217 | +docker-image: | |
| 218 | + docker build --platform linux/amd64 -t $(DOCKERIMAGE) containers/check | |
| 219 | + | |
| 220 | +docker-check: docker-image | |
| 221 | + $(DOCKER) $(DOCKERIMAGE) sh -c "git config --global --add safe.directory '*' && make check" | |
| 222 | + | |
| 223 | +docker-shell: docker-image | |
| 224 | + $(DOCKER) -it $(DOCKERIMAGE) sh -c "git config --global --add safe.directory '*' && exec bash" |
| @@ -181,8 +181,8 @@ | ||
| 181 | 181 | a table of quadwords, as GLOB_DAT does now; every address in data |
| 182 | 182 | rebased, since the program is position-independent; its symbol table |
| 183 | 183 | for lldb's backtraces; and an ad-hoc code signature, SHA-256 hashes |
| 184 | - of its pages, without which arm64 macOS won't run it. No line | |
| 185 | - numbers for a debugger at first. | |
| 184 | + of its pages, without which arm64 macOS won't run it; and line | |
| 185 | + numbers for lldb, as DWARF in `__DWARF` (below). | |
| 186 | 186 | - `Host.darwin.raz`: the library beside the compiler by |
| 187 | 187 | `_NSGetExecutablePath`, C always, a program run from a file written |
| 188 | 188 | and made executable (no `memfd_create`). |
| @@ -213,7 +213,7 @@ | ||
| 213 | 213 | linux/amd64 container on the Mac until there is a Mac compiler): |
| 214 | 214 | |
| 215 | 215 | 1. Report 2026-11.0, for the owner's review. (This commit.) |
| 216 | -2. A container to build and check in on the Mac (`make docker-check`), | |
| 216 | +2. Done. A container to build and check in on the Mac (`make docker-check`), | |
| 217 | 217 | the budget raised to 18,000 in `CLAUDE.md` and `doc/compiler.md`, |
| 218 | 218 | and the Makefile and scripts made to run on BSD's tools as on GNU's |
| 219 | 219 | (`sed -i`, `stat`, `sha256sum`). |
| @@ -0,0 +1,8 @@ | ||
| 1 | +# What `make check` needs, on the one target raz makes: Linux x86-64. | |
| 2 | +# Used by `make docker-check` to run the checks on a machine of | |
| 3 | +# another kind (an Apple Silicon Mac, over Rosetta). | |
| 4 | +FROM debian:stable-slim | |
| 5 | +RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| 6 | + make curl ca-certificates gcc libc6-dev musl musl-tools \ | |
| 7 | + vim emacs-nox git \ | |
| 8 | + && rm -rf /var/lib/apt/lists/* |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | # Reading the raz compiler |
| 2 | 2 | |
| 3 | 3 | The compiler is twelve files of raz, about 13,100 lines of code (the |
| 4 | -budget is 14,000). It is its own compiler: a release of it, the one | |
| 4 | +budget is 18,000). It is its own compiler: a release of it, the one | |
| 5 | 5 | `BOOT` names, builds `src/`, and `make fixpoint` checks that what it |
| 6 | 6 | makes makes itself again, byte for byte. Each release was built by the |
| 7 | 7 | one before it, back to v0.19.0, which the Pascal compiler it was ported |
| @@ -8,12 +8,12 @@ | ||
| 8 | 8 | mkdir -p build/cmp/bench |
| 9 | 9 | ln -sfn ../../lib build/cmp/lib |
| 10 | 10 | sh test/genbench.sh 12000 >build/cmp/bench/Bench.raz |
| 11 | -echo "$(wc -l <build/cmp/bench/Bench.raz) lines" | |
| 11 | +echo "$(($(wc -l <build/cmp/bench/Bench.raz))) lines" | |
| 12 | 12 | for t in prev this; do |
| 13 | 13 | if [ $t = prev ]; then cp build/boot/raz build/cmp/raz; else cp raz build/cmp/raz; fi |
| 14 | 14 | best=0 |
| 15 | 15 | for i in 1 2 3 4 5; do |
| 16 | - s=$(date +%s%N); build/cmp/raz -o build/cmp/bench/Bench.$t build/cmp/bench/Bench.raz; e=$(date +%s%N) | |
| 16 | + s=$(sh test/nanos.sh); build/cmp/raz -o build/cmp/bench/Bench.$t build/cmp/bench/Bench.raz; e=$(sh test/nanos.sh) | |
| 17 | 17 | d=$(( (e - s) / 1000000 )); if [ $best = 0 ] || [ $d -lt $best ]; then best=$d; fi |
| 18 | 18 | done |
| 19 | 19 | echo "$t: $best ms" |
| @@ -34,7 +34,9 @@ | ||
| 34 | 34 | { rm -f $d/$t; echo "boot: can't fetch $t; put it in $d" >&2; exit 1; } |
| 35 | 35 | fi |
| 36 | 36 | fi |
| 37 | -if ! echo "$sum $d/$t" | sha256sum -c --quiet - >/dev/null 2>&1; then | |
| 37 | +# macOS has shasum, not sha256sum | |
| 38 | +if command -v sha256sum >/dev/null; then got=$(sha256sum < $d/$t); else got=$(shasum -a 256 < $d/$t); fi | |
| 39 | +if [ "${got%% *}" != "$sum" ]; then | |
| 38 | 40 | echo "boot: $d/$t isn't $tag's tarball: its SHA-256 isn't BOOT's" >&2 |
| 39 | 41 | exit 1 |
| 40 | 42 | fi |
| @@ -10,7 +10,7 @@ | ||
| 10 | 10 | best() { # best program: the fewest milliseconds of five runs |
| 11 | 11 | b=0 |
| 12 | 12 | for i in 1 2 3 4 5; do |
| 13 | - s=$(date +%s%N); $1 > /dev/null; e=$(date +%s%N) | |
| 13 | + s=$(sh test/nanos.sh); $1 > /dev/null; e=$(sh test/nanos.sh) | |
| 14 | 14 | t=$(( (e - s) / 1000000 )) |
| 15 | 15 | if [ $b = 0 ] || [ $t -lt $b ]; then b=$t; fi |
| 16 | 16 | done |
| @@ -30,6 +30,26 @@ | ||
| 30 | 30 | ulimit -s 8192 # Linux's usual stack: StackOverflow's depth depends on it, and CI's runner gives more |
| 31 | 31 | pass=0 |
| 32 | 32 | fail=0 |
| 33 | +skipped=0 | |
| 34 | + | |
| 35 | +# Rosetta, which runs x86 programs on an Apple Silicon Mac, differs from | |
| 36 | +# Linux in these ways; the tests that can't tell so are skipped there, | |
| 37 | +# each with its reason, until raz runs natively on the Mac. Elsewhere | |
| 38 | +# nothing is skipped. | |
| 39 | +rosetta= | |
| 40 | +grep -q VirtualApple /proc/cpuinfo 2>/dev/null && rosetta=1 | |
| 41 | +skip() { # skip name: whether to skip it, saying why | |
| 42 | + [ -n "$rosetta" ] || return 1 | |
| 43 | + case $1 in | |
| 44 | + test/run/ExecOpened|test/libc/ExecOpenedC) why='keeps descriptors 3 to 6 open' ;; | |
| 45 | + test/libc/SysTest|lib/Sys.linux-x86_64.raz) why='takes descriptor 9 in a child' ;; | |
| 46 | + test/run/StackOverflow|test/run/ThreadOverflow) why='reads a trap local as 0 after a stack fault' ;; | |
| 47 | + "Thread under a memory limit") why="aborts under ulimit -v" ;; | |
| 48 | + *) return 1 ;; | |
| 49 | + esac | |
| 50 | + echo "SKIP $1: Rosetta $why" | |
| 51 | + skipped=$((skipped + 1)) | |
| 52 | +} | |
| 33 | 53 | |
| 34 | 54 | conform/check.sh $raz test/msg > $out/conform.out |
| 35 | 55 | grep -v '^[0-9]* passed' $out/conform.out |
| @@ -38,6 +58,7 @@ | ||
| 38 | 58 | |
| 39 | 59 | run() { # run dir name |
| 40 | 60 | dir=$1; name=$2 |
| 61 | + skip $dir/$name && return | |
| 41 | 62 | flags= |
| 42 | 63 | [ $dir = examples ] || [ $dir = test/libc ] && flags=-Werror |
| 43 | 64 | if ! $raz $flags $libc -I $dir/mods -o $out/$name $dir/$name.raz 2>$out/$name.cerr; then |
| @@ -335,8 +356,12 @@ | ||
| 335 | 356 | # raztest, which says what it counted on its last line; Sys over C is |
| 336 | 357 | # tested in test/libc |
| 337 | 358 | if $raz -Werror -o $out/raztest tools/Test.raz 2>$out/raztest.cerr; then |
| 338 | - RAZ=$raz $out/raztest -j $(nproc 2>/dev/null || echo 1) -o $out/lib \ | |
| 339 | - $(for f in lib/*.raz; do [ $f != lib/Sys.raz ] && grep -q '^proc main\*' $f && echo $f; done) \ | |
| 359 | + libtests= | |
| 360 | + for f in lib/*.raz; do | |
| 361 | + [ $f != lib/Sys.raz ] && grep -q '^proc main\*' $f && ! skip $f && libtests="$libtests $f" | |
| 362 | + done | |
| 363 | + RAZ=$raz $out/raztest -j $(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1) -o $out/lib \ | |
| 364 | + $libtests \ | |
| 340 | 365 | > $out/raztest.out 2>&1 |
| 341 | 366 | set -- $(tail -1 $out/raztest.out) # N passed, F failed, T timed out, S |
| 342 | 367 | if [ "$2" = passed, ] && [ "$6" = timed ]; then |
| @@ -347,8 +372,8 @@ | ||
| 347 | 372 | fi |
| 348 | 373 | # and again with the debug heap, RAZ_HEAP=debug: guards after blocks, |
| 349 | 374 | # freed blocks filled and quarantined |
| 350 | - RAZ_HEAP=debug RAZ=$raz $out/raztest -j $(nproc 2>/dev/null || echo 1) -o $out/libdebug \ | |
| 351 | - $(for f in lib/*.raz; do [ $f != lib/Sys.raz ] && grep -q '^proc main\*' $f && echo $f; done) \ | |
| 375 | + RAZ_HEAP=debug RAZ=$raz $out/raztest -j $(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1) -o $out/libdebug \ | |
| 376 | + $libtests \ | |
| 352 | 377 | > $out/raztest-debug.out 2>&1 |
| 353 | 378 | set -- $(tail -1 $out/raztest-debug.out) |
| 354 | 379 | if [ "$2" = passed, ] && [ "$6" = timed ]; then |
| @@ -427,7 +452,8 @@ | ||
| 427 | 452 | |
| 428 | 453 | # Thread's test again, with too little memory for all its threads: |
| 429 | 454 | # spawn must fail, with Thread.Failed |
| 430 | -if (ulimit -v 60000; $out/lib/Thread.linux-x86_64 fail) > /dev/null 2>&1; then pass=$((pass + 1)) | |
| 455 | +if skip "Thread under a memory limit"; then : | |
| 456 | +elif (ulimit -v 60000; $out/lib/Thread.linux-x86_64 fail) > /dev/null 2>&1; then pass=$((pass + 1)) | |
| 431 | 457 | else echo "FAIL Thread under a memory limit"; fail=$((fail + 1)); fi |
| 432 | 458 | |
| 433 | 459 | # the compiler's way of going on after an error, in small: a parser |
| @@ -463,5 +489,7 @@ | ||
| 463 | 489 | # The compiler built with another host (test/host/Host.raz). |
| 464 | 490 | if test/compiler-host.sh "$raz"; then pass=$((pass + 1)); else fail=$((fail + 1)); fi |
| 465 | 491 | |
| 466 | -echo "$pass passed, $fail failed" | |
| 492 | +summary="$pass passed, $fail failed" | |
| 493 | +[ $skipped = 0 ] || summary="$summary, $skipped skipped" | |
| 494 | +echo "$summary" | |
| 467 | 495 | [ $fail = 0 ] |
| @@ -0,0 +1,9 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +# The time in nanoseconds, for the timing scripts: date +%s%N is GNU's; | |
| 3 | +# BSD's date prints a literal N there, and perl, which macOS has, then | |
| 4 | +# gives the time. | |
| 5 | +n=$(date +%s%N) | |
| 6 | +case $n in | |
| 7 | +*N) perl -MTime::HiRes=time -e 'printf "%.0f\n", time * 1e9' ;; | |
| 8 | +*) echo "$n" ;; | |
| 9 | +esac |