F01, the driver is an interpreter - #77
Merged
Merged
Conversation
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
force-pushed
the
f01-the-spec-language
branch
from
September 6, 2026 09:06
314ff93 to
f44880e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first lesson of M3. T01 showed which programs
gccruns; this shows the language that decision is written in, and ends by changing it.What is new
gxray/specs.py, a reader forgcc -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:argumentcc1cc1, with-fverbose-asmassemblercc1,ascc1,my-own-assemblerguardcc1cc1,assuffixcc1,asThe
guardfile is theinvoke_asspec with its%{!S:wrapper removed, sogcc -Sruns the assembler.guardandassemblerare derived from the live localinvoke_asrather 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 comparesFORMSagainst thecase '...'labels ofdo_spec_1whenvendor/gccis checked out: a GCC that grows a%form now fails the build rather than having a lesson print it as text.blueprints/BP-DRIVER.mdgoes 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_FUNCTIONSas 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:
specrewritten, andspec function,compiler table,specs fileadded.Gates
pytest -q1504 passed,ruff check,ruff format --check,refcheck check507 citations,nbbuild build|check|claims|verify|index,nbbuild run18 lessons in a real kernel,prosecheck46 files,bpc check|pages --check,tier0 check|coverage|offline|online31 experiments,dumpparse check,matrix table --check,gxray.glossary92 terms.matrix digests --checkstill reports the two missingbootdigests, which is the open M2 gate and not from this branch.