Allow specifying .hi files of imports on command line in batch mode
|Reported by:||duncan||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Revisions:|
It is useful for a build agent (e.g. cabal, or makefile) to have full control over the search path. Reasons you might want to do this are below.
The way a build agent can do this is to instruct ghc not to do any searching at all, using the flag -i which sets the search path to empty. Then the build agent has to supply ghc with all the .hs files that are needed, e.g.:
ghc --make -i Foo.hs Bar.hs
(any imports outside of these modules, or the package modules will fail)
This no-search scheme works in --make mode but not in batch mode. For that we need to be able to say:
ghc -i -c Foo.hs ghc -i -c Bar.hs Foo.hi
That is, we need to be able to specify the .hi files of imported modules on the command line.
A build agent may want to do this so that it is insulated from the particular choices of ghc's search path semantics and/or have different choices. For example, ghc prefers modules in local .hs/.hi files to package modules while the build agent may want the reverse in some circumstances.
Apart from search path policy, it makes sense for a build agent to take this approach simply for correctness and simplicity. A correct build agent must track dependencies absolutely precisely, so it has to know which specific .hi files ghc will pick anyway. It is simpler for the build agent to tell ghc those .hi files rather than trying to precisely arrange things to match ghc's search behaviour.
Change History (5)
comment:2 Changed 4 years ago by igloo
- Milestone changed from 7.4.1 to 7.6.1
- Priority changed from normal to low