X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Fcompiler%2Fmain%2FDriverPipeline.hs;h=0db9de7d40f26d25d83a6c3aac764c72233529bd;hb=b4623557bb3c8bec7232e4e68a8be8cf28fbbda6;hp=99e34dbf5d84f25bed5a46904782fb6114816cde;hpb=215dad7be238d00c90b3b11b5278ffd4659425d2;p=ghc-hetmet.git diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs index 99e34db..0db9de7 100644 --- a/ghc/compiler/main/DriverPipeline.hs +++ b/ghc/compiler/main/DriverPipeline.hs @@ -1,5 +1,4 @@ ----------------------------------------------------------------------------- --- $Id: DriverPipeline.hs,v 1.96 2001/08/10 23:08:25 sof Exp $ -- -- GHC Driver -- @@ -34,7 +33,7 @@ import DriverUtil import DriverMkDepend import DriverPhases import DriverFlags -import SysTools ( newTempName, addFilesToClean, getSysMan, unDosifyPath ) +import SysTools ( newTempName, addFilesToClean, getSysMan ) import qualified SysTools import HscMain import Finder @@ -136,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 @@ -174,8 +174,11 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix) HscJava | split -> not_valid | otherwise -> error "not implemented: compiling via Java" +#ifdef ILX HscILX | split -> not_valid - | otherwise -> [ Unlit, Cpp, Hsc ] + | otherwise -> [ Unlit, Cpp, Hsc, Ilx2Il, Ilasm ] +#endif + HscNothing -> [ Unlit, Cpp, Hsc ] | cish = [ Cc, As ] @@ -186,6 +189,9 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix) stop_phase = case todo of StopBefore As | split -> SplitAs +#ifdef ILX + | real_lang == HscILX -> Ilasm +#endif StopBefore phase -> phase DoMkDependHS -> Ln DoLink -> Ln @@ -233,6 +239,9 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix) Mangle | keep_raw_s -> Persistent As | keep_s -> Persistent HCc | keep_hc -> Persistent +#ifdef ILX + Ilasm | keep_il -> Persistent +#endif _other -> Temporary -- add information about output files to the pipeline @@ -264,7 +273,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 @@ -275,7 +284,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 ... @@ -324,14 +333,12 @@ run_phase :: Phase run_phase Unlit _basename _suff input_fn output_fn = do unlit_flags <- getOpts opt_L - -- The -h option passes the file name for unlit to put in a #line directive; - -- we undosify it so that it doesn't contain backslashes in Windows, which - -- would disappear in error messages + -- The -h option passes the file name for unlit to put in a #line directive SysTools.runUnlit (map SysTools.Option unlit_flags ++ [ SysTools.Option "-h" , SysTools.Option input_fn - , SysTools.FileOption input_fn - , SysTools.FileOption output_fn + , SysTools.FileOption "" input_fn + , SysTools.FileOption "" output_fn ]) return (Just output_fn) @@ -365,10 +372,11 @@ run_phase Cpp basename suff input_fn output_fn ++ map SysTools.Option hs_src_cpp_opts ++ map SysTools.Option hscpp_opts ++ map SysTools.Option md_c_flags - ++ [ SysTools.Option "-x c" - , SysTools.FileOption input_fn + ++ [ SysTools.Option "-x" + , SysTools.Option "c" + , SysTools.FileOption "" input_fn , SysTools.Option "-o" - , SysTools.FileOption output_fn + , SysTools.FileOption "" output_fn ]) return (Just output_fn) @@ -468,7 +476,7 @@ run_phase Hsc basename suff input_fn output_fn -- build a ModuleLocation to pass to hscMain. (mod, location') - <- mkHomeModuleLocn mod_name basename (Just (basename ++ '.':suff)) + <- mkHomeModuleLocn mod_name basename (basename ++ '.':suff) -- take -ohi into account if present ohi <- readIORef v_Output_hi @@ -509,7 +517,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 @@ -533,13 +541,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) } ----------------------------------------------------------------------------- @@ -578,10 +587,10 @@ run_phase cc_phase basename suff input_fn output_fn | otherwise = [ ] excessPrecision <- readIORef v_Excess_precision - SysTools.runCc ([ SysTools.Option "-x c" - , SysTools.FileOption input_fn + SysTools.runCc ([ SysTools.Option "-x", SysTools.Option "c" + , SysTools.FileOption "" input_fn , SysTools.Option "-o" - , SysTools.FileOption output_fn + , SysTools.FileOption "" output_fn ] ++ map SysTools.Option ( md_c_flags @@ -611,8 +620,8 @@ run_phase Mangle _basename _suff input_fn output_fn else return [] SysTools.runMangle (map SysTools.Option mangler_opts - ++ [ SysTools.FileOption input_fn - , SysTools.FileOption output_fn + ++ [ SysTools.FileOption "" input_fn + , SysTools.FileOption "" output_fn ] ++ map SysTools.Option machdep_opts) return (Just output_fn) @@ -626,9 +635,9 @@ run_phase SplitMangle _basename _suff input_fn output_fn split_s_prefix <- SysTools.newTempName "split" let n_files_fn = split_s_prefix - SysTools.runSplit [ SysTools.FileOption input_fn - , SysTools.FileOption split_s_prefix - , SysTools.FileOption n_files_fn + SysTools.runSplit [ SysTools.FileOption "" input_fn + , SysTools.FileOption "" split_s_prefix + , SysTools.FileOption "" n_files_fn ] -- Save the number of split files for future references @@ -652,9 +661,9 @@ run_phase As _basename _suff input_fn output_fn SysTools.runAs (map SysTools.Option as_opts ++ [ SysTools.Option ("-I" ++ p) | p <- cmdline_include_paths ] ++ [ SysTools.Option "-c" - , SysTools.FileOption input_fn + , SysTools.FileOption "" input_fn , SysTools.Option "-o" - , SysTools.FileOption output_fn + , SysTools.FileOption "" output_fn ]) return (Just output_fn) @@ -676,13 +685,43 @@ run_phase SplitAs basename _suff _input_fn output_fn SysTools.runAs (map SysTools.Option as_opts ++ [ SysTools.Option "-c" , SysTools.Option "-o" - , SysTools.FileOption real_o - , SysTools.FileOption input_s + , SysTools.FileOption "" real_o + , SysTools.FileOption "" input_s ]) mapM_ assemble_file [1..n] return (Just output_fn) +#ifdef ILX +----------------------------------------------------------------------------- +-- Ilx2Il phase +-- Run ilx2il over the ILX output, getting an IL file + +run_phase Ilx2Il _basename _suff input_fn output_fn + = do ilx2il_opts <- getOpts opt_I + SysTools.runIlx2il (map SysTools.Option ilx2il_opts + ++ [ SysTools.Option "--no-add-suffix-to-assembly", + SysTools.Option "mscorlib", + SysTools.Option "-o", + SysTools.FileOption "" output_fn, + SysTools.FileOption "" input_fn ]) + return (Just output_fn) + +----------------------------------------------------------------------------- +-- Ilasm phase +-- Run ilasm over the IL, getting a DLL + +run_phase Ilasm _basename _suff input_fn output_fn + = do ilasm_opts <- getOpts opt_i + SysTools.runIlasm (map SysTools.Option ilasm_opts + ++ [ SysTools.Option "/QUIET", + SysTools.Option "/DLL", + SysTools.FileOption "/OUT=" output_fn, + SysTools.FileOption "" input_fn ]) + return (Just output_fn) + +#endif -- ILX + ----------------------------------------------------------------------------- -- MoveBinary sort-of-phase -- After having produced a binary, move it somewhere else and generate a @@ -820,7 +859,7 @@ doLink o_files = do (md_c_flags, _) <- machdepCCOpts SysTools.runLink ( [ SysTools.Option verb , SysTools.Option "-o" - , SysTools.FileOption output_fn + , SysTools.FileOption "" output_fn ] ++ map SysTools.Option ( md_c_flags @@ -834,13 +873,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 @@ -896,7 +930,7 @@ doMkDLL o_files = do SysTools.runMkDLL ([ SysTools.Option verb , SysTools.Option "-o" - , SysTools.FileOption output_fn + , SysTools.FileOption "" output_fn ] ++ map SysTools.Option ( md_c_flags @@ -989,6 +1023,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 <- @@ -998,14 +1033,17 @@ compile ghci_mode summary source_unchanged have_object HscC | keep_hc -> return (basename ++ '.':phaseInputExt HCc) | otherwise -> newTempName (phaseInputExt HCc) HscJava -> newTempName "java" -- ToDo - HscILX -> return (basename ++ ".ilx") - -- newTempName "ilx" -- ToDo +#ifdef ILX + 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 @@ -1021,10 +1059,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)