FIX #1650: ".boot modules interact badly with the ghci debugger"
[ghc-hetmet.git] / compiler / main / DriverPipeline.hs
index 4f19cfa..c0ea4fc 100644 (file)
@@ -6,6 +6,13 @@
 --
 -----------------------------------------------------------------------------
 
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
+
 module DriverPipeline (
        -- Run a series of compilation steps in a pipeline, for a
        -- collection of source files.
@@ -156,7 +163,8 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
              return (CompOK details iface maybe_old_linkable)
        handleBatch (HscRecomp hasStub, iface, details)
            | isHsBoot src_flavour
-               = do SysTools.touch dflags' "Touching object file"
+               = do when (isObjectTarget hsc_lang) $ -- interpreted reaches here too
+                       SysTools.touch dflags' "Touching object file"
                                    object_filename
                     return (CompOK details iface Nothing)
            | otherwise
@@ -181,9 +189,9 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
        handleInterpreted (InteractiveNoRecomp, iface, details)
            = ASSERT (isJust maybe_old_linkable)
              return (CompOK details iface maybe_old_linkable)
-       handleInterpreted (InteractiveRecomp hasStub comp_bc, iface, details)
+       handleInterpreted (InteractiveRecomp hasStub comp_bc modBreaks, iface, details)
            = do stub_unlinked <- getStubLinkable hasStub
-                let hs_unlinked = [BCOs comp_bc]
+                let hs_unlinked = [BCOs comp_bc modBreaks]
                     unlinked_time = ms_hs_date mod_summary
                   -- Why do we use the timestamp of the source file here,
                   -- rather than the current time?  This works better in
@@ -204,13 +212,11 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
                   Just result -> handle result
    -- run the compiler
    case hsc_lang of
-     HscInterpreted | not (isHsBoot src_flavour) -- We can't compile boot files to
-                                                 -- bytecode so don't even try.
-         -> runCompiler hscCompileInteractive handleInterpreted
-     HscNothing
-         -> runCompiler hscCompileNothing handleBatch
-     _other
-         -> runCompiler hscCompileBatch handleBatch
+     HscInterpreted
+      | isHsBoot src_flavour -> runCompiler hscCompileNothing handleBatch
+      | otherwise            -> runCompiler hscCompileInteractive handleInterpreted
+     HscNothing     -> runCompiler hscCompileNothing handleBatch
+     _other         -> runCompiler hscCompileBatch handleBatch
 
 -----------------------------------------------------------------------------
 -- stub .h and .c files (for foreign export support)
@@ -412,12 +418,16 @@ runPipeline
   -> Maybe ModLocation          -- A ModLocation, if this is a Haskell module
   -> IO (DynFlags, FilePath)   -- (final flags, output filename)
 
-runPipeline stop_phase dflags (input_fn, mb_phase) mb_basename output maybe_loc
+runPipeline stop_phase dflags0 (input_fn, mb_phase) mb_basename output maybe_loc
   = do
-  let (input_basename, suffix) = splitFilename input_fn
+  let
+      (input_basename, suffix) = splitFilename input_fn
       basename | Just b <- mb_basename = b
                | otherwise             = input_basename
 
+      -- Decide where dump files should go based on the pipeline output
+      dflags = dflags0 { dumpPrefix = Just (basename ++ ".") }
+
        -- If we were given a -x flag, then use that phase to start from
       start_phase = fromMaybe (startPhase suffix) mb_phase