summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-01-22 18:20:15 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-29 04:04:12 -0500
commit18e106a8dfdae50c3078558382209f53794a8c97 (patch)
tree6f9e10dbfc50a977bbb82ecf31a75e1a12aa8d1c /hadrian
parent6fc920847f65e9b9f347bde42b2f9ec624468cfd (diff)
downloadhaskell-18e106a8dfdae50c3078558382209f53794a8c97.tar.gz
Add missing .hi-boot dependencies with ghc -M (#14482)
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/src/Hadrian/Oracles/TextFile.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/hadrian/src/Hadrian/Oracles/TextFile.hs b/hadrian/src/Hadrian/Oracles/TextFile.hs
index d6fb78cc2f..ae8182e0dd 100644
--- a/hadrian/src/Hadrian/Oracles/TextFile.hs
+++ b/hadrian/src/Hadrian/Oracles/TextFile.hs
@@ -18,6 +18,7 @@ module Hadrian.Oracles.TextFile (
import Control.Monad
import qualified Data.HashMap.Strict as Map
import Data.Maybe
+import Data.List
import Development.Shake
import Development.Shake.Classes
import Development.Shake.Config
@@ -60,7 +61,14 @@ lookupValuesOrError file key = fromMaybe (error msg) <$> lookupValues file key
-- compiling @source@, which in turn also depends on a number of other @files@.
lookupDependencies :: FilePath -> FilePath -> Action (FilePath, [FilePath])
lookupDependencies depFile file = do
- deps <- lookupValues depFile file
+ let -- .hs needs to come before .hi-boot deps added to fix #14482.
+ -- This is still a bit fragile: we have no order guaranty from the input
+ -- file. Let's hope we don't have two different .hs source files (e.g.
+ -- one included into the other)...
+ weigh p
+ | ".hs" `isSuffixOf` p = 0 :: Int
+ | otherwise = 1
+ deps <- fmap (sortOn weigh) <$> lookupValues depFile file
case deps of
Nothing -> error $ "No dependencies found for file " ++ quote file
Just [] -> error $ "No source file found for file " ++ quote file