[PATCH] Fix building dynamic/profiling executables that use TH
Patrick Palka
patrick at parcs.ath.cx
Fri Jan 25 00:14:41 CET 2013
We need to build a _vanilla_ executable the first time.
The previous code was essentially a no-op as it did not change the
flags used to build the executable the first time.
---
Cabal/Distribution/Simple/GHC.hs | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs
index 5f2926a..84745d6 100644
--- a/Cabal/Distribution/Simple/GHC.hs
+++ b/Cabal/Distribution/Simple/GHC.hs
@@ -866,15 +866,14 @@ buildExe verbosity _pkg_descr lbi
ghcOptExtra = ["-no-hs-main" | not isHaskellMain ]
}
- -- 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.
+ -- For building profiling exe's or dynamic exe's that use TH
+ -- we actually have to build twice, once the vanilla way and
+ -- then the profiling/dynamic way. This is because GHC can only
+ -- use vanilla object files to link & run the appropriate
+ -- compile-time TH code.
when ((withProfExe lbi || withDynExe lbi) &&
EnableExtension TemplateHaskell `elem` allExtensions exeBi) $
- runGhcProg compileOpts { ghcOptNoLink = toFlag True }
- --TODO: do we also need to play the static vs dynamic games here?
+ runGhcProg staticOpts { ghcOptNoLink = toFlag True }
runGhcProg compileOpts { ghcOptNoLink = toFlag True }
--
1.7.10.4
More information about the cabal-devel
mailing list