Skip to content

F01, the driver is an interpreter - #77

Merged
tamnd merged 1 commit into
mainfrom
f01-the-spec-language
Sep 6, 2026
Merged

tamnd merged 1 commit into
mainfrom
f01-the-spec-language

Conversation

@tamnd

@tamnd tamnd commented Sep 6, 2026

Copy link
Copy Markdown
Owner

The first lesson of M3. T01 showed which programs gcc runs; this shows the language that decision is written in, and ends by changing it.

What is new

gxray/specs.py, a reader for gcc -dumpspecs. Forty five % forms in five families, the three compound forms (%{, %:, %(), where an argument ends, brace predicates in words, and the call graph. It is a reader and not a second interpreter: it substitutes nothing, because substituting would need a command line, a target, a filesystem and a temporary directory.

corpora/specs/f01.json, two whole spec tables of the same release (aarch64 Darwin, 56 blocks; x86-64 Linux through Compiler Explorer, 47 blocks), plus what the driver has compiled into it (static_specs, the spec functions, the compiler table's suffixes and language rows), plus four pairs of -### runs that differ by one text file:

file before after
argument cc1 cc1, with -fverbose-asm
assembler cc1, as cc1, my-own-assembler
guard cc1 cc1, as
suffix nothing, and a warning cc1, as

The guard file is the invoke_as spec with its %{!S: wrapper removed, so gcc -S runs the assembler. guard and assembler are derived from the live local invoke_as rather than written down, so re-recording on another target is still a fair test rather than an embedded Darwin string.

tests/test_specs.py, 51 tests. The one that matters compares FORMS against the case '...' labels of do_spec_1 when vendor/gcc is checked out: a GCC that grows a % form now fails the build rather than having a lesson print it as text.

blueprints/BP-DRIVER.md goes from stub to partial. The spec language in full with a table per family, the specs file format and its two kinds of entry, EXTRA_SPEC_FUNCTIONS as the reason 21 spec functions is a floor, two new invariants (every %(name) resolves; a name defined twice resolves to the last), and what the two recorded targets say about the cost of a port.

Four glossary terms: spec rewritten, and spec function, compiler table, specs file added.

Gates

pytest -q 1504 passed, ruff check, ruff format --check, refcheck check 507 citations, nbbuild build|check|claims|verify|index, nbbuild run 18 lessons in a real kernel, prosecheck 46 files, bpc check|pages --check, tier0 check|coverage|offline|online 31 experiments, dumpparse check, matrix table --check, gxray.glossary 92 terms.

matrix digests --check still reports the two missing boot digests, which is the open M2 gate and not from this branch.

The first lesson of M3, and a step back before the front end proper.
T01 showed which programs gcc runs. This shows the language that
decision is written in.

gxray.specs reads gcc -dumpspecs: forty five percent forms in five
families, the three compound ones, where an argument ends, and the call
graph that turns fifty six strings into a system. It substitutes
nothing, because substituting would need a command line, a target, a
filesystem and a temporary directory.

The corpus holds two whole spec tables of the same release, aarch64
Darwin and x86-64 Linux, and four pairs of -### runs that differ by one
text file. The four files are the point of the lesson: one appends an
argument, one renames the assembler, one removes the %{!S: wrapper from
invoke_as so that gcc -S runs the assembler, and one teaches the driver
a suffix it has never heard of. No compiler, no rebuild, three of them
move the chain.

The guard and assembler files are derived from the live local invoke_as
rather than written down, so re-recording on another target is still a
fair test.

tests/test_specs.py compares FORMS against the case labels of do_spec_1
with vendor/gcc checked out. A GCC that grows a percent form now fails
the build rather than having a lesson print it as text.

BP-DRIVER goes from stub to partial: the spec language in full, the
specs file format, two invariants about what always resolves and what
wins when a name is defined twice, and what the two recorded targets
say about the cost of a port.
@tamnd
tamnd force-pushed the f01-the-spec-language branch from 314ff93 to f44880e Compare September 6, 2026 09:06
@tamnd
tamnd merged commit a23bf74 into main Sep 6, 2026
9 checks passed
@tamnd
tamnd deleted the f01-the-spec-language branch September 6, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant