-fno-code, ghci large space leak due to backpack hack
We take quite a bit of care to ensure that thunks in the EPS do not retain any reference to the HPT because thunks in the EPS live forever and the HPT is transient.
However, there is a hack in the function dontLeakTheHPT
which turns this crucial step off when NoBackend
is enabled.
-- wrinkle: when we're typechecking in --backpack mode, the
-- instantiation of a signature might reside in the HPT, so
-- this case breaks the assumption that EPS interfaces only
-- refer to other EPS interfaces. We can detect when we're in
-- typechecking-only mode by using backend==NoBackend, and
-- in that case we don't empty the HPT. (admittedly this is
-- a bit of a hack, better suggestions welcome). A number of
-- tests in testsuite/tests/backpack break without this
-- tweak.
old_unit_env = hsc_unit_env hsc_env
!unit_env
| NoBackend <- backend (hsc_dflags hsc_env)
= old_unit_env
| otherwise
= pprTrace "clearing old_unit_env" empty $
old_unit_env
{ ue_hpt = emptyHomePackageTable
Because the EPS now retains the HPT at the moment the interface was loaded, this leads to a space leak on a reload as the ModDetails
are retained forever