Repository navigation
Conversation
`--analyzed-ir` prints the analyzed program to a file. This flag calls a user procedure with the same value instead, so a consumer chooses the encoding its own tools want. The hook takes the datum and the target directory as arguments. The datum is ordinary data: symbols, strings, exact integers, bytevectors, booleans and lists. So the loaded file imports nothing from the compiler, and the binary keeps its libraries pruned. A hook that reads the live intermediate representation cannot do this, because `nanopass-case` needs `(langs)` at expansion time, and `(langs)` is over half of all library objects. Measured on this machine: 3,014,486 bytes, against 3,012,931 for the branch this builds on. Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
The same three fixes as the sibling flag. The checked-in `--help` fixture gains the paragraph. `load-hook` moves inside `handle-exceptions`, since a `parameterize` initializer runs before the body and a missing file printed a raw Chez exception. And the hook call moves to the end of the successful path, because the compiler does not track the files a hook writes and so cannot roll them back. Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
RomarQ
added a commit
that referenced
this pull request
Aug 17, 2026
`passes.ss` binds four intermediate representations in one `let*`: `lsrc-ir`, `frontend-ir`, `analyzed-ir` and `circuit-ir`. The hook receives the third, so the flag says which one. This is the name #17 uses for its own hook. The two are alternatives, so only one can land, and naming them alike keeps the choice about the contract rather than the spelling. Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Owner
Author
|
Closing in favour of #18. Both hand a consumer's Scheme file the analyzed IR, and both keep the binary pruned. #18 hands over the analyzed program itself rather than the datum printed from it, so the emitter moves out of the compiler entirely instead of the compiler keeping the 391-line pass and the consumer owning only the rendering. #18 reproduces this route's artifact byte for byte across all 215 example contracts that compile, so nothing here is lost. The three review fixes this PR received (the checked-in The branch stays for reference. |
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.
Stacked on #16. Only the last commit belongs to this PR.
--analyzed-irwrites the analyzed program tocompiler/analyzed-ir.sexp. This flag calls a user procedure with the same value instead, and writes no file. A consumer then renders the datum in the encoding its own tools want.Why this costs nothing
The hook takes the datum and the target directory as arguments. The datum is ordinary data: symbols, strings, exact integers, bytevectors, booleans and lists. So the loaded file imports nothing from the compiler, and
compile-whole-programkeeps its libraries pruned.A hook that reads the live intermediate representation cannot do that. To take a nanopass record apart you write
nanopass-case, which is a macro, so the file mustimport (langs)and the whole program has to keep its libraries visible.langs.sois 6,906,038 bytes, over half of all library objects, which is where the binary growth in #13 comes from.Measured on this machine:
--analyzed-ironly--run-hookThe startup cost that comes with visible libraries, about 110 ms per invocation, is likewise absent.
The contract
(hook sexp target-directory).sexpis the datum--analyzed-irprints, before printing.target-directoryis a string, so the hook writes files without importing(pass-helpers).hook.Two mistakes report themselves:
The second is the point: the libraries stay invisible, so a hook cannot reach into the compiler.
Verification
nix build .#compactcis green, including the full unit suite in thecheckPhase.--analyzed-irwrites.--analyzed-iroutput is unchanged: bboard is byte-identical to the reference consumer's committed fixture.contract-info.jsonis byte-identical to a build of the base branch.analyzed-ir.sexpis created; only what the hook writes.Relation to #13
#13 also runs a user Scheme file, but it hands over the live records after every pass, and pays for that with visible libraries. Its own PR reports the cost. This PR gives a consumer the same ability to own the output format, with none of the cost, because the compiler serializes first.
It does not answer the other half of #13's argument, that the project should carry no format at all. It cannot: the datum has to come from somewhere, and here it comes from the pass in #16. That is the trade. If the project accepts owning the pass, this flag makes the output format a consumer's choice.