Skip to content

Commit

Permalink
Fix logic for building dynamic executables with TemplateHaskell
Browse files Browse the repository at this point in the history
  • Loading branch information
int-e committed Aug 24, 2012
1 parent 51ba2b4 commit 207e6ae
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down

0 comments on commit 207e6ae

Please sign in to comment.