1998ace
diff -u ghc-7.2.0.20110728/libraries/Cabal/cabal/Distribution/Simple/GHC.hs.orig ghc-7.2.0.20110728/libraries/Cabal/cabal/Distribution/Simple/GHC.hs
1998ace
--- ghc-7.2.0.20110728/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs.orig	2011-07-29 02:12:09.000000000 +0900
1998ace
+++ ghc-7.2.0.20110728/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs	2011-08-05 18:08:05.192042529 +0900
1998ace
@@ -778,7 +778,10 @@
1998ace
           ++ ["-L"++libDir | libDir <- extraLibDirs exeBi]
1998ace
           ++ concat [["-framework", f] | f <- PD.frameworks exeBi]
1998ace
           ++ if dynExe
1998ace
-                then ["-dynamic"]
1998ace
+                then ["-dynamic",
1998ace
+                      "-hisuf", "dyn_hi",
1998ace
+                      "-osuf", "dyn_o"
1998ace
+                     ]
1998ace
                 else []
1998ace
           ++ if profExe
1998ace
                 then ["-prof",
1998ace
@@ -787,13 +790,14 @@
1998ace
                      ] ++ ghcProfOptions exeBi
1998ace
                 else []
1998ace
 
1998ace
-  -- For building exe's for profiling that use TH we actually
1998ace
+  -- For building exe's for profiling or dynamic that use TH we actually
1998ace
   -- have to build twice, once without profiling and the again
1998ace
   -- with profiling. This is because the code that TH needs to
1998ace
   -- run at compile time needs to be the vanilla ABI so it can
1998ace
   -- be loaded up and run by the compiler.
1998ace
-  when (withProfExe lbi && EnableExtension TemplateHaskell `elem` allExtensions exeBi)
1998ace
-     (runGhcProg (binArgs False (withDynExe lbi) False))
1998ace
+  when ((withProfExe lbi || withDynExe lbi) &&
1998ace
+        EnableExtension TemplateHaskell `elem` allExtensions exeBi)
1998ace
+     (runGhcProg (binArgs False False False))
1998ace
 
1998ace
   runGhcProg (binArgs True (withDynExe lbi) (withProfExe lbi))
1998ace