Add `-fignore-export-list` flag for use in GHCi
Currently GHCi uses the mi_globals
field of ModIface
to provide the following features:
- Non exported names are visible and can be used from the repl
- The import environment of loaded modules is replicated in the repl, so that if you
import M
in a file and then load the file in GHCi, symbols fromM
will be available in the repl
Unfortunately using mi_globals
for this can leak a lot of memory: #22832
Instead I propose to introduce a new flag -fignore-export-list
that makes GHC behave as if the export list isn't present while compiling a module. This can be used by GHCi to provide feature 1.
For feature 2 I propose that we have special logic in GHCi to contruct an RdrEnv from the header of the currently loaded module(s).
This way, we can avoid keeping mi_globals
around for all the modules in a big GHCi session with a lot of files, and instead only construct the RdrEnv
for a module that is :load
ed into the repl, from its header, avoiding keeping the RdrEnv
around for its transitive dependencies.