Permalink
Browse files

Fix the logic for building profiled executables with TemplateHaskell.

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...
1 parent 96c3f33 commit 51ba2b4d0b903f1c7604b2c4c3e951bf38f97dcd @int-e int-e committed Jul 29, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 Cabal/Distribution/Simple/GHC.hs
View
13 Cabal/Distribution/Simple/GHC.hs
@@ -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) }

0 comments on commit 51ba2b4

Please sign in to comment.