[project @ 2001-10-01 14:01:42 by rrt]
[ghc-hetmet.git] / ghc / compiler / main / DriverPipeline.hs
index 2c06c1b..2e5902b 100644 (file)
@@ -135,6 +135,7 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix)
    split      <- readIORef v_Split_object_files
    mangle     <- readIORef v_Do_asm_mangling
    keep_hc    <- readIORef v_Keep_hc_files
+   keep_il    <- readIORef v_Keep_il_files
    keep_raw_s <- readIORef v_Keep_raw_s_files
    keep_s     <- readIORef v_Keep_s_files
    osuf       <- readIORef v_Object_suf
@@ -177,6 +178,7 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix)
        HscILX  | split           -> not_valid
                | otherwise       -> [ Unlit, Cpp, Hsc, Ilx2Il, Ilasm ]
 #endif
+       HscNothing                -> [ Unlit, Cpp, Hsc ]
 
       | cish      = [ Cc, As ]
 
@@ -187,6 +189,7 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix)
 
     stop_phase = case todo of 
                        StopBefore As | split -> SplitAs
+                                      | real_lang == HscILX -> Ilasm
                        StopBefore phase      -> phase
                        DoMkDependHS          -> Ln
                        DoLink                -> Ln
@@ -234,6 +237,7 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix)
                             Mangle | keep_raw_s -> Persistent
                             As     | keep_s     -> Persistent
                             HCc    | keep_hc    -> Persistent
+                            Ilasm  | keep_il    -> Persistent
                             _other              -> Temporary
 
        -- add information about output files to the pipeline
@@ -265,7 +269,7 @@ runPipeline pipeline (input_fn,suffix) do_linking use_ofile
   where (basename, _) = splitFilename input_fn
 
 pipeLoop [] input_fn _ _ _ _ = return input_fn
-pipeLoop ((phase, keep, o_suffix):phases) 
+pipeLoop (all_phases@((phase, keep, o_suffix):phases))
        (input_fn,real_suff) do_linking use_ofile orig_basename orig_suffix
   = do
 
@@ -276,7 +280,7 @@ pipeLoop ((phase, keep, o_suffix):phases)
        -- checker has determined that recompilation isn't necessary.
      case mbCarryOn of
        Nothing -> do
-             let (_,keep,final_suffix) = last phases
+             let (_,keep,final_suffix) = last all_phases
              ofile <- outputFileName True keep final_suffix
              return (ofile, final_suffix)
           -- carry on ...
@@ -511,7 +515,7 @@ run_phase Hsc basename suff input_fn output_fn
         let dyn_flags' = dyn_flags { hscOutName = output_fn,
                                     hscStubCOutName = basename ++ "_stub.c",
                                     hscStubHOutName = basename ++ "_stub.h",
-                                    extCoreName = basename ++ ".core" }
+                                    extCoreName = basename ++ ".hcr" }
 
   -- run the compiler!
         pcs <- initPersistentCompilerState
@@ -535,13 +539,14 @@ run_phase Hsc basename suff input_fn output_fn
            HscRecomp pcs details iface stub_h_exists stub_c_exists
                      _maybe_interpreted_code -> do
 
-           -- deal with stubs
-       maybe_stub_o <- compileStub dyn_flags' stub_c_exists
-       case maybe_stub_o of
-               Nothing -> return ()
-               Just stub_o -> add v_Ld_inputs stub_o
-
-       return (Just output_fn)
+                           -- deal with stubs
+                           maybe_stub_o <- compileStub dyn_flags' stub_c_exists
+                           case maybe_stub_o of
+                             Nothing -> return ()
+                             Just stub_o -> add v_Ld_inputs stub_o
+                           case hscLang dyn_flags of
+                              HscNothing -> return Nothing
+                             _ -> return (Just output_fn)
     }
 
 -----------------------------------------------------------------------------
@@ -866,13 +871,8 @@ doLink o_files = do
                      ++ pkg_extra_ld_opts
                      ++ extra_ld_opts
                      ++ if static && not no_hs_main then
-#ifdef LEADING_UNDERSCORE
-                           [ "-u", "_PrelMain_mainIO_closure" ,
-                             "-u", "___init_PrelMain"] 
-#else
-                           [ "-u", prefixUnderscore "PrelMain_mainIO_closure" ,
-                             "-u", prefixUnderscore "__init_PrelMain"] 
-#endif
+                           [ "-u", prefixUnderscore "PrelMain_mainIO_closure",
+                             "-u", prefixUnderscore "__stginit_PrelMain"] 
                         else []))
 
     -- parallel only: move binary to another dir -- HWL
@@ -1021,6 +1021,7 @@ compile ghci_mode summary source_unchanged have_object
        (basename, _) = splitFilename input_fn
        
    keep_hc <- readIORef v_Keep_hc_files
+   keep_il <- readIORef v_Keep_il_files
    keep_s  <- readIORef v_Keep_s_files
 
    output_fn <- 
@@ -1031,14 +1032,16 @@ compile ghci_mode summary source_unchanged have_object
                   | otherwise -> newTempName (phaseInputExt HCc)
            HscJava             -> newTempName "java" -- ToDo
 #ifdef ILX
-          HscILX              -> return (phaseInputExt Ilx2Il)         
+          HscILX  | keep_il   -> return (basename ++ '.':phaseInputExt Ilasm)
+                   | otherwise -> newTempName (phaseInputExt Ilx2Il)   
 #endif
           HscInterpreted      -> return (error "no output file")
+           HscNothing         -> return (error "no output file")
 
    let dyn_flags' = dyn_flags { hscOutName = output_fn,
                                hscStubCOutName = basename ++ "_stub.c",
                                hscStubHOutName = basename ++ "_stub.h",
-                               extCoreName = basename ++ ".core" }
+                               extCoreName = basename ++ ".hcr" }
 
    -- figure out which header files to #include in a generated .hc file
    c_includes <- getPackageCIncludes
@@ -1054,10 +1057,14 @@ compile ghci_mode summary source_unchanged have_object
 
    writeIORef v_HCHeader cc_injects
 
+   -- -no-recomp should also work with --make
+   do_recomp <- readIORef v_Recomp
+   let source_unchanged' = source_unchanged && do_recomp
+
    -- run the compiler
    hsc_result <- hscMain ghci_mode dyn_flags'
                         (ms_mod summary) location
-                        source_unchanged have_object old_iface hst hit pcs
+                        source_unchanged' have_object old_iface hst hit pcs
 
    case hsc_result of
       HscFail pcs -> return (CompErrs pcs)