Skip to content

Commit

Permalink
Fix the logic for building profiled executables with TemplateHaskell.
Browse files Browse the repository at this point in the history
This was broken in 5f50fb1: Instead of a vanilla version, the code would
build a profiling version of the objects for TH.
  • Loading branch information
int-e committed Aug 23, 2012
1 parent 96c3f33 commit 51ba2b4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Cabal/Distribution/Simple/GHC.hs
Expand Up @@ -840,24 +840,25 @@ buildExe verbosity _pkg_descr lbi
ghcOptExtra = ghcSharedOptions exeBi
}

exeOpts | withDynExe lbi = dynamicOpts
| otherwise = vanillaOpts
exeNoProfOpts | withDynExe lbi = dynamicOpts
| otherwise = vanillaOpts

exeProfOpts = exeOpts `mappend` mempty {
exeOpts | withProfExe lbi = vanillaOpts `mappend` mempty {
ghcOptProfilingMode = toFlag True,
ghcOptHiSuffix = toFlag "p_hi",
ghcOptObjSuffix = toFlag "p_o",
ghcOptExtra = ghcProfOptions exeBi,
ghcOptNoLink = toFlag True
ghcOptExtra = ghcProfOptions exeBi
}
| otherwise = exeNoProfOpts

-- For building exe's for profiling that use TH we actually
-- have to build twice, once without profiling and the again
-- with profiling. This is because the code that TH needs to
-- run at compile time needs to be the vanilla ABI so it can
-- be loaded up and run by the compiler.
when (withProfExe lbi &&
EnableExtension TemplateHaskell `elem` allExtensions exeBi) $
runGhcProg exeProfOpts { ghcOptNoLink = toFlag True }
runGhcProg exeNoProfOpts { ghcOptNoLink = toFlag True }

runGhcProg exeOpts { ghcOptOutputFile = toFlag (targetDir </> exeNameReal) }

Expand Down

0 comments on commit 51ba2b4

Please sign in to comment.