[Git][ghc/ghc][wip/reinstallable-th] Update bootstrapping TH note

Teo Camarasu (@teo) gitlab at gitlab.haskell.org
Thu May 9 12:19:29 UTC 2024



Teo Camarasu pushed to branch wip/reinstallable-th at Glasgow Haskell Compiler / GHC


Commits:
ec8310b3 by Teo Camarasu at 2024-05-09T13:19:18+01:00
Update bootstrapping TH note

- - - - -


1 changed file:

- compiler/GHC/Tc/Gen/Splice.hs


Changes:

=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -2921,7 +2921,9 @@ tcGetInterp = do
 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 -- Staged Metaprogramming as implemented in Template Haskell introduces a whole
 -- new dimension of staging to the already staged bootstrapping process.
--- The `template-haskell` library plays a crucial role in this process.
+-- While users depend on the user-facing `template-haskell` library, the TH
+-- interface (all wired-in identifiers) is defined in `ghc-internal` and for
+-- bootstrapping purposes, re-exported from `ghc-boot-th`.
 --
 -- Nomenclature:
 --
@@ -2939,26 +2941,16 @@ tcGetInterp = do
 --       the stage1 compiler; thus the "boot" in boot library does not refer to a
 --       stage.
 --
--- Here is how we bootstrap `template-haskell` in tandem with GHC:
+-- Here is how we bootstrap TH in tandem with GHC:
 --
---  1. Link the stage1 compiler against the boot TH library.
+--  1. Link the stage1 compiler against the boot `template-haskell`/`ghc-boot-th` library.
 --  2. When building the stage1 compiler, build a CPP'd version of the in-tree
---     TH using the boot compiler under a different package-id,
---     `template-haskell-next`, and build stage1 GHC against that.
---  3. Build the in-tree TH with the stage1 compiler.
+--     TH (defined in `ghc-internal`) using the boot compiler under a different
+--     package-id, `ghc-boot-th-next`, and build stage1 GHC against that.
+--  3. Build the in-tree TH with the stage1 compiler. From here on `ghc-boot-th`
+--     re-exposes the TH modules from `ghc-internal`.
 --  4. Build and link the stage2 compiler against the in-tree TH.
 --
--- Observations:
---
---  A. The vendoring in (2) means that the fully qualified name of the in-tree TH
---     AST will be, e.g., `template-haskell-next:...VarE`, not `template-haskell:...VarE`.
---     That is OK, because we need it just for the `Binary` instance and to
---     convert TH ASTs returned by splices into the Hs AST, both of which do not
---     depend on the fully qualified name of the type to serialise! Importantly,
---     Note [Hard-wiring in-tree template-haskell for desugaring quotes] is
---     unaffected, because the desugaring refers to names in the in-tree TH
---     library, which is built in the next stage, stage1, and later.
---
 -- (Rejected) alternative designs:
 --
 --  1b. Build the in-tree TH with the stage0 compiler and link the stage1 compiler
@@ -3018,7 +3010,7 @@ tcGetInterp = do
 -- Note [Hard-wiring in-tree template-haskell for desugaring quotes]
 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 -- To desugar Template Haskell quotes, GHC needs to wire in a bunch of Names in the
--- `template-haskell` library as Note [Known-key names], in GHC.Builtin.Names.TH.
+-- `ghc-internal` library as Note [Known-key names], in GHC.Builtin.Names.TH.
 -- Consider
 -- > foo :: Q Exp
 -- > foo = [| unwords ["hello", "world"] |]
@@ -3026,6 +3018,6 @@ tcGetInterp = do
 -- > varE (mkNameS "unwords") `appE` listE [litE (stringE "hello"), litE (stringE "world")]
 -- And all these smart constructors are known-key.
 -- NB: Since the constructors are known-key, it is impossible to link this program
--- against another template-haskell library in which, e.g., `varE` was moved into a
+-- against another `ghc-internal` library in which, e.g., `varE` was moved into a
 -- different module. So effectively, GHC is hard-wired against the in-tree
--- template-haskell library.
+-- `ghc-internal` library.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec8310b371995fe1211068b96b8d358a09f6a8a6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec8310b371995fe1211068b96b8d358a09f6a8a6
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240509/24e70f3f/attachment-0001.html>


More information about the ghc-commits mailing list