Hi all,
Today I verified that with Luite's recent work on the interpreter it is
now possible to run GHC entirely within GHCi (when bootstrapping from
GHC 9.2). Behold:
```
$ # First we must remove -fno-code from hadrian/ghci
$ git apply <https://www.haskell.org/ghc/ :? for help
[ 1 of 668] Compiling GHC.Iface.Type[boot] ( /opt/exp/ghc/ghc-landing/compiler/GHC/Iface/Type.hs-boot, interpreted )
[ 2 of 668] Compiling GHC.Platform.Constants ( /opt/exp/ghc/ghc-landing/.hadrian_ghci/stage0/compiler/build/GHC/Platform/Constants.hs, interpreted )
.
.
.
[668 of 668] Compiling Main ( ghc/Main.hs, interpreted )
Ok, 668 modules loaded.
λ> import Main
λ> :set args -B/opt/exp/ghc/ghc-landing/_build/stage1/lib --version
λ> :trace main
The Glorious Glasgow Haskell Compilation System, version 9.3.20211027
λ> :set args -B/opt/exp/ghc/ghc-landing/_build/stage1/lib HelloWorld.hs
λ> main
[1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o )
Linking HelloWorld ...
λ> :! ./HelloWorld
"Hello World!"
```
Surprisingly, performance isn't even horrible, taking only a few seconds
to compile "hello world".
Sadly, `:trace` doesn't quite work yet on `main`:
```
λ> :trace main
*** Exception: ModBreaks.modBreaks_array not initialised
CallStack (from HasCallStack):
error, called at compiler/GHC/ByteCode/Types.hs:231:24 in ghc:GHC.ByteCode.Types
```
I've opened #20570 to track this issue. Fixing it would allow
breakpoints and the like to be used on GHC.
Anyways, I found this quite exciting. Perhaps this will spur more
contributors to take an interest in GHCi.
Cheers,
- Ben