-----------------------------------------------------------------------------
--- $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
--
import ErrUtils
import CmdLineOpts
import Config
+import Panic
import Util
import Time ( getClockTime )
-- 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
-- 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
-- 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)
-- 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
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
++ [ "-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
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)
-- 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.
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
])