summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-03-30 16:15:46 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-17 12:45:25 -0400
commit85fc32f03a6df92ec8d4ec9accca3c11b31a1596 (patch)
treea2db6627f82783b3ef550cc8b4d4752050d2f3f0
parentec77b2f16a78b13f54794c954953d8878dea9db2 (diff)
downloadhaskell-85fc32f03a6df92ec8d4ec9accca3c11b31a1596.tar.gz
Hadrian: fix dyn_o/dyn_hi rule (#17534)
-rw-r--r--hadrian/src/Rules/Compile.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/hadrian/src/Rules/Compile.hs b/hadrian/src/Rules/Compile.hs
index ee395d4d75..12a8707f31 100644
--- a/hadrian/src/Rules/Compile.hs
+++ b/hadrian/src/Rules/Compile.hs
@@ -55,7 +55,22 @@ compilePackage rs = do
&%> \ [dyn_o, _dyn_hi] -> do
p <- platformSupportsSharedLibs
if p
- then need [dyn_o -<.> "o", dyn_o -<.> "hi"]
+ then do
+ -- We `need` ".o/.hi" because GHC is called with `-dynamic-too`
+ -- and builds ".dyn_o/.dyn_hi" too.
+ changed <- needHasChanged [dyn_o -<.> "o", dyn_o -<.> "hi"]
+
+ -- If for some reason a previous Hadrian execution has been
+ -- interrupted after the rule for .o/.hi generation has completed
+ -- but before the current rule for .dyn_o/.dyn_hi has completed,
+ -- or if some of the dynamic artifacts have been removed by the
+ -- user, "needing" the non dynamic artifacts is not enough as
+ -- Shake won't execute the associated action. Hence we detect
+ -- this case and we explictly build the dynamic artifacts here:
+ case changed of
+ [] -> compileHsObjectAndHi rs dyn_o
+ _ -> pure ()
+
else compileHsObjectAndHi rs dyn_o
forM_ ((,) <$> hsExts <*> wayPats) $ \ ((oExt, hiExt), wayPat) ->