From 581f02d6f88fe3951a03eb182e0f6df9f632ab36 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 6 Aug 2020 14:09:53 -0600 Subject: [PATCH] expander: fix `make` for generating BC source Also, update "README.txt" to explain both CS and BC setup. --- racket/src/cs/schemified/expander.scm | 106 +++++++++++++------------- racket/src/expander/README.txt | 69 ++++++++++------- racket/src/expander/run.rkt | 2 +- 3 files changed, 97 insertions(+), 80 deletions(-) diff --git a/racket/src/cs/schemified/expander.scm b/racket/src/cs/schemified/expander.scm index c4e1ca5ed2..7a4794d1e5 100644 --- a/racket/src/cs/schemified/expander.scm +++ b/racket/src/cs/schemified/expander.scm @@ -125,72 +125,72 @@ (define kw2194 (string->keyword "set-hash!")) (define hash2936 (hasheq - kw2755 - '25 - kw2641 - '4 - kw2129 - '16 - kw2821 - '11 - kw2607 - '3 - kw3245 - '13 - kw2582 - '13 - kw2099 - '5 - kw2201 - '20 - kw2226 - '6 - kw2535 - '17 kw3163 '9 - kw2600 - '23 - kw2333 - '14 - kw2626 - '8 - kw2603 - '1 - kw2931 - '15 - kw2802 - '12 - kw2525 - '10 - kw2967 - '12 - kw2677 - '26 - kw2804 - '24 - kw2762 - '27 - kw2473 - '14 - kw1932 - '2 - kw2496 - '7 - kw2169 - '21 kw2707 '22 + kw2600 + '23 kw2241 '18 + kw2333 + '14 kw2645 '19 + kw2626 + '8 kw3357 '14 + kw2603 + '1 kw2796 '13 + kw2755 + '25 + kw2931 + '15 kw2897 - '28)) + '28 + kw2641 + '4 + kw2802 + '12 + kw2129 + '16 + kw2525 + '10 + kw2821 + '11 + kw2967 + '12 + kw2607 + '3 + kw2677 + '26 + kw3245 + '13 + kw2804 + '24 + kw2582 + '13 + kw2762 + '27 + kw2099 + '5 + kw2473 + '14 + kw2201 + '20 + kw1932 + '2 + kw2226 + '6 + kw2496 + '7 + kw2535 + '17 + kw2169 + '21)) (define kw2162 (string->keyword "not-recorded")) (define hash2430 (hasheq diff --git a/racket/src/expander/README.txt b/racket/src/expander/README.txt index 6fa7d23671..e43dab5c76 100644 --- a/racket/src/expander/README.txt +++ b/racket/src/expander/README.txt @@ -1,4 +1,4 @@ -This package contains the implementation of Racket's front-end: macro +This package contains the implementation of Racket's front end: macro expander, reader, and module systems. A copy of this implementation is extracted and built into the Racket executable, so normally this package's modules are not run directly. The expander or reader can be @@ -92,31 +92,6 @@ Running: Expands and extracts as a single linklet, compiles it and then writes the bytecode into . - % racket bootstrap-run.rkt -c -O /racket - - Compiles the expander to source files in --- note that - "bootstrap-run.rkt" must be used to get source compiles --- and - writes the flattened linklet to "startup.inc" in a Git checkout of - a linklet-based Racket. Be sure to increment the target Racket - version if you change the serialization of syntax objects or the - linklet protocol. - - When you `make`, then "startup.inc" will be automatically compiled - to bytecode for for embedding into the Racket executable. If you - change the expander in a way that makes existing compiled files - invalid, be sure to update "schvers.h". (Updating "schvers.h" is - important both for bytecode files and the makefile/preprocessor - dance that generates the bytecode version of the expander itself.) - - % make - - A shortcut for the above: When this package resides in an existing - in-place build from the main Racket repo, then the makefile uses - that copy of Racket to build the expander and drop a replacement - into the "src" directory. Re-making the Racket tree will then use - the updated expander. You may have to manually discard - "compiled/cache-src" when things change. - % make demo % make run ARGS=" ..." @@ -127,6 +102,48 @@ Running: ---------------------------------------- +Building Racket to use this expander: + +After you change the expander, you must perform an explicit build step +to use it when making Racket CS or Racket BC. Normally, for that case, +the expander would be modified as part of a Racket repo checkout. +Then: + + * For Racket CS, go to "racket/src/cs" in the repo and run `make`. + That will update files in "racket/src/cs/schemified", including + using the new expander to rebuild the Racket-implemented parts of + Racket CS that are in "../thread", "../io", etc. + + After this step, a `make cs` in the top level of the Racket repo + will build Racket CS using the new expander. + + * For Racket BC, run `make` here, which will update the file + "racket/src/bc/src/startup.inc". Then, when you build Racket BC, + "startup.inc" will be automatically compiled to bytecode for + embedding into the Racket BC executable. + + After this step, a `make bc` in the top level of the Racket repo + will build Racket CS using the new expander. + +For either of these steps, the makefile will assume that Racket is +already built in the surrounding checkout, so Racket can be run as +`../../bin/racket`. Use `make RACKET=....` to use a different Racket +build, but beware that the version of Racket must be essentially the +same version as the target build. + +Before building new CS and BC executables, increment the target Racket +version in "../version/racket_version.h" if you change the +serialization of syntax objects or the linklet protocol. Updating +"racket_version.h" is important both for bytecode files and the +makefile/preprocessor dance that generates the bytecode version of the +expander itself. + +The `make` step for Racket BC generates source files in +"compiled/cache-src". In come cases (hopefully rare), you may have to +manually discard "compiled/cache-src" when things change. + +---------------------------------------- + Roadmap to the implementation: read/ - the readers diff --git a/racket/src/expander/run.rkt b/racket/src/expander/run.rkt index 55ffc3e2e3..e661127299 100644 --- a/racket/src/expander/run.rkt +++ b/racket/src/expander/run.rkt @@ -77,7 +77,7 @@ (set! extract? #t) (set! extract-to-c? #t) (linklet-compile-to-s-expr #t) - (set! print-extracted-to (build-path checkout-directory "src" "racket" "src" "startup.inc"))] + (set! print-extracted-to (build-path checkout-directory "src" "bc" "src" "startup.inc"))] #:once-each [("-k") dir "Use Racket checkout at " (set! checkout-directory (path->complete-path dir))]