[commit: ghc] master: Fix #8180 (ae87e12)

git at git.haskell.org git at git.haskell.org
Sun Jan 12 20:45:48 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/ae87e122b1bc0f388d43d28fb9fc4886c72ba022/ghc

>---------------------------------------------------------------

commit ae87e122b1bc0f388d43d28fb9fc4886c72ba022
Author: Austin Seipp <austin at well-typed.com>
Date:   Sun Jan 12 13:40:51 2014 -0600

    Fix #8180
    
    When compiling a set of modules under --make, we need to check if the
    module graph has TemplateHaskell enabled. If it does, then we need to
    switch on -dynamic-too for GHCi, so that the linker can properly find
    the right dynamic object files.
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


>---------------------------------------------------------------

ae87e122b1bc0f388d43d28fb9fc4886c72ba022
 compiler/main/DriverPipeline.hs |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index f789d44..3cc176c 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -137,8 +137,16 @@ compileOne' m_tc_result mHscMessage
        location    = ms_location summary
        input_fn    = expectJust "compile:hs" (ml_hs_file location)
        input_fnpp  = ms_hspp_file summary
+       mod_graph   = hsc_mod_graph hsc_env0
+       needsTH     = any (xopt Opt_TemplateHaskell . ms_hspp_opts) mod_graph
 
-   debugTraceMsg dflags0 2 (text "compile: input file" <+> text input_fnpp)
+   -- #8180 - when using TemplateHaskell, switch on -dynamic-too so
+   -- the linker can correctly load the object files.
+   let dflags1 = if needsTH
+                  then gopt_set dflags0 Opt_BuildDynamicToo
+                  else dflags0
+
+   debugTraceMsg dflags1 2 (text "compile: input file" <+> text input_fnpp)
 
    let basename = dropExtension input_fn
 
@@ -146,8 +154,8 @@ compileOne' m_tc_result mHscMessage
   -- This is needed when we try to compile the .hc file later, if it
   -- imports a _stub.h file that we created here.
    let current_dir = takeDirectory basename
-       old_paths   = includePaths dflags0
-       dflags      = dflags0 { includePaths = current_dir : old_paths }
+       old_paths   = includePaths dflags1
+       dflags      = dflags1 { includePaths = current_dir : old_paths }
        hsc_env     = hsc_env0 {hsc_dflags = dflags}
 
    -- Figure out what lang we're generating
@@ -468,7 +476,7 @@ compileFile hsc_env stop_phase (src, mb_phase) = do
         throwGhcExceptionIO (CmdLineError ("does not exist: " ++ src))
 
    let
-        dflags = hsc_dflags hsc_env
+        dflags    = hsc_dflags hsc_env
         split     = gopt Opt_SplitObjs dflags
         mb_o_file = outputFile dflags
         ghc_link  = ghcLink dflags      -- Set by -c or -no-link



More information about the ghc-commits mailing list