Skip to content

Commit d791af6

Browse files
committed
Ignore changes to Paths_<pkg>.hs
This file is generated by cabal during the build and causes a recompile if the build cache captures a sha from the beginning of the build and then the file is changed by the end of it.
1 parent 979bf63 commit d791af6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Stack/Build/Source.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ loadLocalPackage pp = do
443443
componentFiles' <- runMemoizedWith componentFiles
444444
forM (Map.toList componentFiles') $ \(component, files) -> do
445445
mbuildCache <- tryGetBuildCache (ppRoot pp) component
446-
checkCacheResult <- checkBuildCache
446+
checkCacheResult <- checkBuildCache name
447447
(fromMaybe Map.empty mbuildCache)
448448
(Set.toList files)
449449
pure (component, checkCacheResult)
@@ -488,10 +488,11 @@ loadLocalPackage pp = do
488488
-- determine (1) if the files are dirty, and (2) the new cache values.
489489
checkBuildCache ::
490490
HasEnvConfig env
491-
=> FileCache -- ^ old cache
491+
=> PackageName
492+
-> FileCache -- ^ old cache
492493
-> [Path Abs File] -- ^ files in package
493494
-> RIO env (Set FilePath, FileCache)
494-
checkBuildCache oldCache files = do
495+
checkBuildCache pkgName oldCache files = do
495496
fileDigests <- fmap Map.fromList $ forM files $ \fp -> do
496497
mdigest <- getFileDigestMaybe (toFilePath fp)
497498
pure (toFilePath fp, mdigest)
@@ -510,6 +511,8 @@ checkBuildCache oldCache files = do
510511
-> RIO env (Set FilePath, FileCache)
511512
-- Filter out the cabal_macros file to avoid spurious recompilations
512513
go fp _ _ | takeFileName fp == "cabal_macros.h" = pure (Set.empty, Map.empty)
514+
-- Filter out the Paths_<pkg name> file to avoid spurious recompilations
515+
go fp _ _ | takeFileName fp == "Paths_" ++ packageNameString pkgName ++ ".hs" = pure (Set.empty, Map.empty)
513516
-- Common case where it's in the cache and on the filesystem.
514517
go fp (Just digest') (Just fci)
515518
| fci.hash == digest' = pure (Set.empty, Map.singleton fp fci)

0 commit comments

Comments
 (0)