Skip to content

Spurious missing home modules warning in the present of hs-boot files

Summary

With -Werror=missing-home-modules, when .hs-boot files are involved, GHC fails the build even though all source files have been specified on the command-line.

Steps to reproduce

Consider the following source files:

-- src/A.hs
module A where
import {-# SOURCE #-} B

-- src/B.hs
module B where
import A

-- src/B.hs-boot
module B where

The following command fails, while it is expected to succeed with no warning:

$ ghc -Werror=missing-home-modules src/A.hs src/B.hs    

<no location info>: error: [-Wmissing-home-modules, -Werror=missing-home-modules]
    Modules are not listed in command line but needed for compilation: 
        B

There is no way to satisfy GHC here, except to use -isrc B rather than src/B.hs. But that workaround doesn't help when only the filename is known, not the module name (in general the latter cannot be derived from the former).

Environment

  • GHC version used: 8.6.4
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information