diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-01-22 18:20:15 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-29 04:04:12 -0500 |
commit | 18e106a8dfdae50c3078558382209f53794a8c97 (patch) | |
tree | 6f9e10dbfc50a977bbb82ecf31a75e1a12aa8d1c /compiler/GHC | |
parent | 6fc920847f65e9b9f347bde42b2f9ec624468cfd (diff) | |
download | haskell-18e106a8dfdae50c3078558382209f53794a8c97.tar.gz |
Add missing .hi-boot dependencies with ghc -M (#14482)
Diffstat (limited to 'compiler/GHC')
-rw-r--r-- | compiler/GHC/Driver/MakeFile.hs | 12 | ||||
-rw-r--r-- | compiler/GHC/Unit/Module/Location.hs | 8 |
2 files changed, 19 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/MakeFile.hs b/compiler/GHC/Driver/MakeFile.hs index 2328a32ec5..d513728036 100644 --- a/compiler/GHC/Driver/MakeFile.hs +++ b/compiler/GHC/Driver/MakeFile.hs @@ -47,7 +47,7 @@ import System.Directory import System.FilePath import System.IO import System.IO.Error ( isEOFError ) -import Control.Monad ( when ) +import Control.Monad ( when, forM_ ) import Data.Maybe ( isJust ) import Data.IORef import qualified Data.Set as Set @@ -241,6 +241,16 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode (ExtendedM -- Something like A.o : A.hs ; writeDependency root hdl obj_files src_file + -- add dependency between objects and their corresponding .hi-boot + -- files if the module has a corresponding .hs-boot file (#14482) + ; when (isBootSummary node == IsBoot) $ do + let hi_boot = msHiFilePath node + let obj = removeBootSuffix (msObjFilePath node) + forM_ extra_suffixes $ \suff -> do + let way_obj = insertSuffixes obj [suff] + let way_hi_boot = insertSuffixes hi_boot [suff] + mapM_ (writeDependency root hdl way_obj) way_hi_boot + -- Emit a dependency for each CPP import ; when (depIncludeCppDeps dflags) $ do -- CPP deps are descovered in the module parsing phase by parsing diff --git a/compiler/GHC/Unit/Module/Location.hs b/compiler/GHC/Unit/Module/Location.hs index 6f239227f0..ff5354bfdb 100644 --- a/compiler/GHC/Unit/Module/Location.hs +++ b/compiler/GHC/Unit/Module/Location.hs @@ -5,6 +5,7 @@ module GHC.Unit.Module.Location , addBootSuffix_maybe , addBootSuffixLocn , addBootSuffixLocnOut + , removeBootSuffix ) where @@ -54,6 +55,13 @@ instance Outputable ModLocation where addBootSuffix :: FilePath -> FilePath addBootSuffix path = path ++ "-boot" +-- | Remove the @-boot@ suffix to .hs, .hi and .o files +removeBootSuffix :: FilePath -> FilePath +removeBootSuffix "-boot" = [] +removeBootSuffix (x:xs) = x : removeBootSuffix xs +removeBootSuffix [] = error "removeBootSuffix: no -boot suffix" + + -- | Add the @-boot@ suffix if the @Bool@ argument is @True@ addBootSuffix_maybe :: IsBootInterface -> FilePath -> FilePath addBootSuffix_maybe is_boot path = case is_boot of |