Supporting the external interpreter with the stage1 GHC
Summary
Currently we don't support using the external interpreter with the stage1 compiler. Perhaps we do when cross compiling -- I'm not sure. Yet, as far as I can tell we should be able to use the external interpreter at this stage. Right now this is mostly just useful for testing, but in the future we want to run TH in all stages (#22069) and this is a necessary step to achieve that.
Proposal
I think this is something that would be relatively easy to support for the non-cross compiling case.
We just need to make a ghc-iserv
executable available to the stage1 GHC.
It might be tempting to say this should be stage0:exe:iserv
, but this won't work. stage0:exe:iserv
is compiled using the stage0 compiler. So it can only load dynamic libraries compiled with the stage0 compiler. But when running splices produced by the stage1 compiler, we may want to load libraries compiled by the stage1 compiler.
The correct iserv
to use is then stage1:exe:iserv
. This is built with the stage1 compiler against the template-haskell
that is used by the stage1 compiler to resolve TH quotes. So everything will align. I've tested this locally and this seems to work fine.
I think the only missing piece here is to teach Hadrian about this. I'm not sure about the best way to go about this. We could create a symlink from _build/stage0/bin/ghc-iserv*
to _build/stage1/bin/ghc-iserv*
. Or hadrian could pass options to the stage1 GHC to tell it to look for the iserv executable in stage1/bin
. What do others think?
This might complicate the cross compiling picture though. So maybe this needs to wait for !11444 or maybe we want to deal with cross and non-cross differently?