Permalink
Browse files

Fix logic for building dynamic executables with TemplateHaskell

  • Loading branch information...
1 parent 51ba2b4 commit 207e6ae22888796345869694fde868c9d111b53b @int-e int-e committed Aug 24, 2012
Showing with 9 additions and 11 deletions.
  1. +9 −11 Cabal/Distribution/Simple/GHC.hs
View
20 Cabal/Distribution/Simple/GHC.hs
@@ -835,30 +835,28 @@ buildExe verbosity _pkg_descr lbi
ghcOptLinkFrameworks = PD.frameworks exeBi
}
- dynamicOpts = vanillaOpts `mappend` mempty {
- ghcOptDynamic = toFlag True,
- ghcOptExtra = ghcSharedOptions exeBi
- }
-
- exeNoProfOpts | withDynExe lbi = dynamicOpts
- | otherwise = vanillaOpts
-
exeOpts | withProfExe lbi = vanillaOpts `mappend` mempty {
ghcOptProfilingMode = toFlag True,
ghcOptHiSuffix = toFlag "p_hi",
ghcOptObjSuffix = toFlag "p_o",
ghcOptExtra = ghcProfOptions exeBi
}
- | otherwise = exeNoProfOpts
+ | withDynExe lbi = vanillaOpts `mappend` mempty {
+ ghcOptDynamic = toFlag True,
+ ghcOptHiSuffix = toFlag "dyn_hi",
+ ghcOptObjSuffix = toFlag "dyn_o",
+ ghcOptExtra = ghcSharedOptions exeBi
+ }
+ | otherwise = vanillaOpts
-- 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 &&
+ when ((withProfExe lbi || withDynExe lbi) &&
EnableExtension TemplateHaskell `elem` allExtensions exeBi) $
- runGhcProg exeNoProfOpts { ghcOptNoLink = toFlag True }
+ runGhcProg vanillaOpts { ghcOptNoLink = toFlag True }
runGhcProg exeOpts { ghcOptOutputFile = toFlag (targetDir </> exeNameReal) }

0 comments on commit 207e6ae

Please sign in to comment.