-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix recomp bug by invalidating cache on build exception
Be sure to invalidate the cache if building throws an exception! If not, we'll abort execution with a stale recompilation cache. See ghc#24926 for an example of how this can go wrong.
- Loading branch information
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Process (a) | ||
import Internal (Unused) | ||
|
||
main :: IO () | ||
main = a | ||
|
36 changes: 36 additions & 0 deletions
36
cabal-testsuite/PackageTests/Recompilation/GHC24926/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Test.Cabal.Prelude | ||
|
||
-- See ghc#24926 | ||
main = cabalTest $ do | ||
recordMode DoNotRecord $ do | ||
|
||
root <- testTmpDir <$> getTestEnv | ||
|
||
writeInternalOrig root | ||
cabal "test" [] | ||
|
||
liftIO $ writeFile (root ++ "/src/Internal.hs") | ||
" module Internal where;\ | ||
\ data Unused = Unused;" | ||
fails $ cabal "test" [] -- broken module on purpose | ||
|
||
writeInternalOrig root | ||
out <- cabal' "test" [] -- shouldn't fail! | ||
|
||
assertOutputDoesNotContain | ||
"<no location info>: error:" out | ||
assertOutputDoesNotContain | ||
"Cannot continue after interface file error" out | ||
|
||
where | ||
|
||
writeInternalOrig r = liftIO $ do | ||
writeFile (r ++ "/src/Internal.hs") | ||
" module Internal where;\ | ||
\ data Unused = Unused;\ | ||
\ b :: IO (); \ | ||
\ b = pure ();" | ||
|
19 changes: 19 additions & 0 deletions
19
cabal-testsuite/PackageTests/Recompilation/GHC24926/repro.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cabal-version: 3.0 | ||
name: repro | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
|
||
library | ||
default-language: Haskell2010 | ||
exposed-modules: | ||
Internal | ||
Process | ||
build-depends: base | ||
hs-source-dirs: src | ||
|
||
test-suite repro | ||
default-language: Haskell2010 | ||
type: exitcode-stdio-1.0 | ||
main-is: Repro.hs | ||
build-depends: base, repro | ||
|
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/Recompilation/GHC24926/src/Process.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Process where | ||
|
||
import Internal | ||
|
||
a :: IO () | ||
a = b | ||
|