[project @ 2000-12-18 15:17:46 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverPipeline.hs
index 16db45d..74d0b0a 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverPipeline.hs,v 1.34 2000/11/21 14:34:50 simonmar Exp $
+-- $Id: DriverPipeline.hs,v 1.43 2000/12/18 15:17:46 simonmar Exp $
 --
 -- GHC Driver
 --
@@ -38,6 +38,7 @@ import Module
 import ErrUtils
 import CmdLineOpts
 import Config
+import Panic
 import Util
 
 import Time            ( getClockTime )
@@ -95,7 +96,7 @@ getGhcMode flags
 -- what the suffix of the intermediate files should be, etc.
 
 -- The following compilation pipeline algorithm is fairly hacky.  A
--- better way to do this would be to express the whole comilation as a
+-- better way to do this would be to express the whole compilation as a
 -- data flow DAG, where the nodes are the intermediate files and the
 -- edges are the compilation phases.  This framework would also work
 -- nicely if a haskell dependency generator was included in the
@@ -111,8 +112,8 @@ getGhcMode flags
 -- concurrently, automatically taking advantage of extra processors on
 -- the host machine.  For example, when compiling two Haskell files
 -- where one depends on the other, the data flow graph would determine
--- that the C compiler from the first comilation can be overlapped
--- with the hsc comilation for the second file.
+-- that the C compiler from the first compilation can be overlapped
+-- with the hsc compilation for the second file.
 
 data IntermediateFileType
   = Temporary
@@ -229,9 +230,11 @@ genPipeline todo stop_flag persistent_output lang filename
        -- the suffix on an output file is determined by the next phase
        -- in the pipeline, so we add linking to the end of the pipeline
        -- to force the output from the final phase to be a .o file.
-      stop_phase = case todo of StopBefore phase -> phase
-                               DoMkDependHS     -> Ln
-                               DoLink           -> Ln
+      stop_phase = case todo of 
+                       StopBefore As | split -> SplitAs
+                       StopBefore phase      -> phase
+                       DoMkDependHS          -> Ln
+                       DoLink                -> Ln
       annotated_pipeline = annotatePipeline (pipeline ++ [ Ln ]) stop_phase
 
       phase_ne p (p1,_,_) = (p1 /= p)
@@ -430,7 +433,8 @@ run_phase Hsc basename suff input_fn output_fn
   -- date wrt M.hs (or M.o doesn't exist) so we must recompile regardless.
        do_recomp <- readIORef v_Recomp
        todo <- readIORef v_GhcMode
-        o_file <- odir_ify (basename ++ '.':phaseInputExt Ln)
+        o_file' <- odir_ify (basename ++ '.':phaseInputExt Ln)
+        o_file <- osuf_ify o_file'
        source_unchanged <- 
           if not (do_recomp && ( todo == DoLink || todo == StopBefore Ln ))
             then return False
@@ -469,7 +473,11 @@ run_phase Hsc basename suff input_fn output_fn
 
            HscFail pcs -> throwDyn (PhaseFailed "hsc" (ExitFailure 1));
 
-            HscNoRecomp pcs details iface -> return False;
+            HscNoRecomp pcs details iface -> 
+               do {
+                 runSomething "Touching object file" ("touch " ++ o_file);
+                 return False;
+               };
 
            HscRecomp pcs details iface maybe_stub_h maybe_stub_c 
                      _maybe_interpreted_code -> do
@@ -551,9 +559,6 @@ run_phase cc_phase _basename _suff input_fn output_fn
                   ++ [ "-D__GLASGOW_HASKELL__="++cProjectVersionInt ]
                   ++ cc_opts
                   ++ split_opt
-#ifdef mingw32_TARGET_OS
-                   ++ [" -mno-cygwin"]
-#endif
                   ++ (if excessPrecision then [] else [ "-ffloat-store" ])
                   ++ include_paths
                   ++ pkg_extra_cc_opts
@@ -777,11 +782,11 @@ compile ghci_mode summary source_unchanged old_iface hst hit pcs = do
    init_driver_state <- readIORef v_InitDriverState
    writeIORef v_Driver_state init_driver_state
 
-   showPass init_dyn_flags (showSDoc (text "*** Compiling: " 
-                           <+> ppr (name_of_summary summary)))
+   showPass init_dyn_flags 
+       (showSDoc (text "Compiling" <+> ppr (name_of_summary summary)))
 
    let verb = verbosity init_dyn_flags
-   let location   = ms_location summary   
+   let location   = ms_location summary
    let input_fn   = unJust "compile:hs" (ml_hs_file location) 
    let input_fnpp = unJust "compile:hspp" (ml_hspp_file location)
 
@@ -824,8 +829,8 @@ compile ghci_mode summary source_unchanged old_iface hst hit pcs = do
                -- as our "unlinked" object.
                HscInterpreted -> 
                    case maybe_interpreted_code of
-                      Just (code,itbl_env) -> do tm <- getClockTime 
-                                                  return ([Trees code itbl_env], tm)
+                      Just (bcos,itbl_env) -> do tm <- getClockTime 
+                                                  return ([BCOs bcos itbl_env], tm)
                       Nothing -> panic "compile: no interpreted code"
 
                -- we're in batch mode: finish the compilation pipeline.
@@ -871,7 +876,7 @@ dealWithStubs basename maybe_stub_h maybe_stub_c
                runSomething "Copy stub .c file" 
                    (unwords [ 
                        "rm -f", stub_c, "&&",
-                       "echo \'#include \""++stub_h++"\"\' >"++stub_c, " &&",
+                       "echo \'#include \"Stg.h\"\n#include \""++stub_h++"\"\' >"++stub_c, " &&",
                        "cat", tmp_stub_c, ">> ", stub_c
                        ])