Opened 6 years ago

Last modified 8 months ago

#4453 new feature request

Allow specifying .hi files of imports on command line in batch mode

Reported by: duncan Owned by:
Priority: low Milestone:
Component: Compiler Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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 (7)

comment:1 Changed 6 years ago by igloo

  • Milestone set to 7.2.1

comment:2 Changed 5 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1
  • Priority changed from normal to low

comment:3 Changed 4 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:4 Changed 2 years ago by thoughtpolice

  • Milestone changed from 7.6.2 to 7.10.1

Moving to 7.10.1.

comment:5 Changed 21 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:6 Changed 13 months ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

comment:7 Changed 8 months ago by thomie

  • Milestone 8.0.1 deleted
Note: See TracTickets for help on using tickets.