-----------------------------------------------------------------------------
--- $Id: DriverPipeline.hs,v 1.48 2001/01/16 21:05:51 qrczak Exp $
+-- $Id: DriverPipeline.hs,v 1.53 2001/03/06 15:00:25 rrt Exp $
--
-- GHC Driver
--
import DriverFlags
import HscMain
import TmpFiles
+import Finder
import HscTypes
import Outputable
import Module
-- genPipeline
--
-- Herein is all the magic about which phases to run in which order, whether
--- the intermediate files should be in /tmp or in the current directory,
+-- the intermediate files should be in TMPDIR or in the current directory,
-- what the suffix of the intermediate files should be, etc.
-- The following compilation pipeline algorithm is fairly hacky. A
HscJava | split -> not_valid
| otherwise -> error "not implemented: compiling via Java"
+#ifdef ILX
+ HscILX | split -> not_valid
+ | otherwise -> [ Unlit, Cpp, Hsc ]
+#endif
| cish = [ Cc, As ]
++ ": static flags are not allowed in {-# OPTIONS #-} pragmas:\n\t"
++ unwords unhandled_flags)) (ExitFailure 1))
- do_cpp <- readState cpp_flag
+ do_cpp <- dynFlag cppFlag
if do_cpp
then do
cpp <- readIORef v_Pgm_P
++ pkg_include_dirs)
verb <- getVerbFlag
+ (md_c_flags, _) <- machdepCCOpts
runSomething "C pre-processor"
(unwords
++ include_paths
++ hs_src_cpp_opts
++ hscpp_opts
+ ++ md_c_flags
++ [ "-x", "c", input_fn, ">>", output_fn ]
))
else do
then return True
else return False
- -- build a ModuleLocation to pass to hscMain.
- let location = ModuleLocation {
- ml_hs_file = Nothing,
- ml_hspp_file = Just input_fn,
- ml_hi_file = Just hifile,
- ml_obj_file = Just o_file
- }
+ -- build a ModuleLocation to pass to hscMain.
+ modsrc <- readFile input_fn
+ let (srcimps,imps,mod_name) = getImports modsrc
+
+ Just (mod, location)
+ <- mkHomeModuleLocn mod_name basename (basename ++ '.':suff)
-- get the DynFlags
dyn_flags <- readIORef v_DynFlags
pcs <- initPersistentCompilerState
result <- hscMain OneShot
dyn_flags{ hscOutName = output_fn }
+ mod
+ location{ ml_hspp_file=Just input_fn }
source_unchanged
- location
Nothing -- no iface
emptyModuleEnv -- HomeSymbolTable
emptyModuleEnv -- HomeIfaceTable
++ pkg_include_dirs)
c_includes <- getPackageCIncludes
- cmdline_includes <- readState cmdline_hc_includes -- -#include options
+ cmdline_includes <- dynFlag cmdlineHcIncludes -- -#include options
let cc_injects | hcc = unlines (map mk_include
(c_includes ++ reverse cmdline_includes))
mangler_opts <- getOpts opt_m
machdep_opts <-
if (prefixMatch "i386" cTARGETPLATFORM)
- then do n_regs <- readState stolen_x86_regs
+ then do n_regs <- dynFlag stolen_x86_regs
return [ show n_regs ]
else return []
runSomething "Assembly Mangler"
preprocess :: FilePath -> IO FilePath
preprocess filename =
ASSERT(haskellish_file filename)
- do init_driver_state <- readIORef v_InitDriverState
- writeIORef v_Driver_state init_driver_state
-
+ do init_dyn_flags <- readIORef v_InitDynFlags
+ writeIORef v_DynFlags init_dyn_flags
pipeline <- genPipeline (StopBefore Hsc) ("preprocess") False
defaultHscLang filename
runPipeline pipeline filename False{-no linking-} False{-no -o flag-}
-
-----------------------------------------------------------------------------
-- Compile a single module, under the control of the compilation manager.
--
compile ghci_mode summary source_unchanged old_iface hst hit pcs = do
init_dyn_flags <- readIORef v_InitDynFlags
writeIORef v_DynFlags init_dyn_flags
- 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)))
HscAsm -> newTempName (phaseInputExt As)
HscC -> newTempName (phaseInputExt HCc)
HscJava -> newTempName "java" -- ToDo
+#ifdef ILX
+ HscILX -> newTempName (phaseInputExt Ilx)
+#endif
HscInterpreted -> return (error "no output file")
-- run the compiler
hsc_result <- hscMain ghci_mode dyn_flags{ hscOutName = output_fn }
- source_unchanged
- location old_iface hst hit pcs
+ (ms_mod summary) location
+ source_unchanged old_iface hst hit pcs
case hsc_result of
HscFail pcs -> return (CompErrs pcs)