Skip to content

Add HomeUnit type

Sylvain Henry requested to merge hsyl20/ghc:hsyl20/plugins/homeunit into master

Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with -this-unit-id). Now it is used in conjunction with -component-id and -instantiated-with to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one.

This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful.

Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit in DynFlags. Having a dedicated type will make this easier.

Edited by Sylvain Henry

Merge request reports