Skip to content

Commit

Permalink
Merge pull request #1003 from adinapoli/issue-997
Browse files Browse the repository at this point in the history
Fix #997 (pass --ghc-options -hpcdir) only on --coverage
  • Loading branch information
mgsloan committed Sep 17, 2015
2 parents 2bbf75c + f939504 commit 4e58783
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ singleBuild runInBase ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} in

() <- announce "build"
config <- asks getConfig
extraOpts <- extraBuildOptions
extraOpts <- extraBuildOptions eeBuildOpts
cabal (console && configHideTHLoading config) $
(case taskType of
TTLocal lp -> concat
Expand Down Expand Up @@ -1043,7 +1043,7 @@ singleTest runInBase topts lptb ac ee task installedMap = do
case taskType task of
TTLocal lp -> writeBuildCache pkgDir $ lpNewBuildCache lp
TTUpstream _ _ -> assert False $ return ()
extraOpts <- extraBuildOptions
extraOpts <- extraBuildOptions (eeBuildOpts ee)
cabal (console && configHideTHLoading config) $
"build" : (components ++ extraOpts)
setTestBuilt pkgDir
Expand Down Expand Up @@ -1187,7 +1187,7 @@ singleBench runInBase beopts _lptb ac ee task installedMap = do
TTLocal lp -> writeBuildCache pkgDir $ lpNewBuildCache lp
TTUpstream _ _ -> assert False $ return ()
config <- asks getConfig
extraOpts <- extraBuildOptions
extraOpts <- extraBuildOptions (eeBuildOpts ee)
cabal (console && configHideTHLoading config) ("build" : extraOpts)
setBenchBuilt pkgDir
let args = maybe []
Expand Down Expand Up @@ -1278,10 +1278,17 @@ getSetupHs dir = do
fp1 = dir </> $(mkRelFile "Setup.hs")
fp2 = dir </> $(mkRelFile "Setup.lhs")

extraBuildOptions :: M env m => m [String]
extraBuildOptions = do
hpcIndexDir <- toFilePath . (</> dotHpc) <$> hpcRelativeDir
return ["--ghc-options", "-hpcdir " ++ hpcIndexDir ++ " -ddump-hi -ddump-to-file"]
-- Do not pass `-hpcdir` as GHC option if the coverage is not enabled.
-- This helps running stack-compiled programs with dynamic interpreters like `hint`.
-- Cfr: https://github.com/commercialhaskell/stack/issues/997
extraBuildOptions :: M env m => BuildOpts -> m [String]
extraBuildOptions bopts = do
let ddumpOpts = " -ddump-hi -ddump-to-file"
case toCoverage (boptsTestOpts bopts) of
True -> do
hpcIndexDir <- toFilePath . (</> dotHpc) <$> hpcRelativeDir
return ["--ghc-options", "-hpcdir " ++ hpcIndexDir ++ ddumpOpts]
False -> return ["--ghc-options", ddumpOpts]

-- | Take the given list of package dependencies and the contents of the global
-- package database, and construct a set of installed package IDs that:
Expand Down

0 comments on commit 4e58783

Please sign in to comment.