X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FDriverPipeline.hs;h=9e33f517e5e69dc72bd1cc19103b1fe9a25fbfd9;hb=311b1cdfc9b1c311cc53482c461c18cba8885b2a;hp=e8f64e81a699cb14d71480b68e9fdadbb019ad2e;hpb=f943473cc7db20fbeceb66bd67b2f7872da6941b;p=ghc-hetmet.git diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index e8f64e8..9e33f51 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -29,7 +29,7 @@ module DriverPipeline ( import Packages import HeaderInfo import DriverPhases -import SysTools ( newTempName, addFilesToClean, getSysMan, copy ) +import SysTools ( newTempName, addFilesToClean, copy ) import qualified SysTools import HscMain import Finder @@ -50,17 +50,18 @@ import ParserCoreUtils ( getCoreModuleName ) import SrcLoc ( unLoc ) import SrcLoc ( Located(..) ) -import EXCEPTION -import DATA_IOREF ( readIORef, writeIORef, IORef ) -import GLAEXTS ( Int(..) ) - -import Directory -import System -import IO -import Monad +import Control.Exception as Exception +import Data.IORef ( readIORef, writeIORef, IORef ) +import GHC.Exts ( Int(..) ) +import System.Directory +import System.IO +import SYSTEM_IO_ERROR as IO +import Control.Monad import Data.List ( isSuffixOf ) -import Maybe - +import Data.Maybe +import System.Exit +import System.Cmd +import System.Environment -- --------------------------------------------------------------------------- -- Pre-process @@ -144,8 +145,8 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do extCoreName = basename ++ ".hcr" } -- -no-recomp should also work with --make - let do_recomp = dopt Opt_RecompChecking dflags - source_unchanged = isJust maybe_old_linkable && do_recomp + let force_recomp = dopt Opt_ForceRecomp dflags + source_unchanged = isJust maybe_old_linkable && not force_recomp hsc_env' = hsc_env { hsc_dflags = dflags' } object_filename = ml_obj_file location @@ -302,7 +303,7 @@ link BatchCompile dflags batch_attempt_linking hpt | Right t <- e_exe_time = any (t <) (map linkableTime linkables) - if dopt Opt_RecompChecking dflags && not linking_needed + if not (dopt Opt_ForceRecomp dflags) && not linking_needed then do debugTraceMsg dflags 2 (text exe_file <+> ptext SLIT("is up to date, linking not required.")) return Succeeded else do @@ -688,9 +689,9 @@ runPhase (Hsc src_flavour) stop dflags0 basename suff input_fn get_output_fn _ma -- date wrt M.hs (or M.o doesn't exist) so we must recompile regardless. src_timestamp <- getModificationTime (basename `joinFileExt` suff) - let do_recomp = dopt Opt_RecompChecking dflags + let force_recomp = dopt Opt_ForceRecomp dflags source_unchanged <- - if not do_recomp || not (isStopLn stop) + if force_recomp || not (isStopLn stop) -- Set source_unchanged to False unconditionally if -- (a) recompilation checker is off, or -- (b) we aren't going all the way to .o file (e.g. ghc -S) @@ -789,7 +790,7 @@ runPhase Cmm stop dflags basename suff input_fn get_output_fn maybe_loc -- way too many hacks, and I can't say I've ever used it anyway. runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc - | cc_phase `eqPhase` Cc || cc_phase `eqPhase` HCc + | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc = do let cc_opts = getOpts dflags opt_c hcc = cc_phase `eqPhase` HCc @@ -851,7 +852,8 @@ runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc -- compiling .hc files, by adding the -x c option. -- Also useful for plain .c files, just in case GHC saw a -- -x c option. - [ SysTools.Option "-x", SysTools.Option "c"] ++ + [ SysTools.Option "-x", if cc_phase `eqPhase` Ccpp + then SysTools.Option "c++" else SysTools.Option "c"] ++ [ SysTools.FileOption "" input_fn , SysTools.Option "-o" , SysTools.FileOption "" output_fn @@ -859,6 +861,15 @@ runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc ++ map SysTools.Option ( md_c_flags ++ pic_c_flags +#ifdef sparc_TARGET_ARCH + -- We only support SparcV9 and better because V8 lacks an atomic CAS + -- instruction. Note that the user can still override this + -- (e.g., -mcpu=ultrasparc) as GCC picks the "best" -mcpu flag + -- regardless of the ordering. + -- + -- This is a temporary hack. + ++ ["-mcpu=v9"] +#endif ++ (if hcc && mangle then md_regd_c_flags else []) @@ -946,6 +957,16 @@ runPhase As stop dflags _basename _suff input_fn get_output_fn maybe_loc SysTools.runAs dflags (map SysTools.Option as_opts ++ [ SysTools.Option ("-I" ++ p) | p <- cmdline_include_paths ] +#ifdef sparc_TARGET_ARCH + -- We only support SparcV9 and better because V8 lacks an atomic CAS + -- instruction so we have to make sure that the assembler accepts the + -- instruction set. Note that the user can still override this + -- (e.g., -mcpu=ultrasparc). GCC picks the "best" -mcpu flag + -- regardless of the ordering. + -- + -- This is a temporary hack. + ++ [ SysTools.Option "-mcpu=v9" ] +#endif ++ [ SysTools.Option "-c" , SysTools.FileOption "" input_fn , SysTools.Option "-o" @@ -1025,9 +1046,9 @@ runPhase SplitAs stop dflags basename _suff _input_fn get_output_fn maybe_loc -- we don't need the generality of a phase (MoveBinary is always -- done after linking and makes only sense in a parallel setup) -- HWL -runPhase_MoveBinary input_fn +runPhase_MoveBinary dflags input_fn = do - sysMan <- getSysMan + let sysMan = pgm_sysman dflags pvm_root <- getEnv "PVM_ROOT" pvm_arch <- getEnv "PVM_ARCH" let @@ -1113,7 +1134,7 @@ checkProcessArgsResult flags filename getHCFilePackages :: FilePath -> IO [PackageId] getHCFilePackages filename = - EXCEPTION.bracket (openFile filename ReadMode) hClose $ \h -> do + Exception.bracket (openFile filename ReadMode) hClose $ \h -> do l <- hGetLine h case l of '/':'*':' ':'G':'H':'C':'_':'P':'A':'C':'K':'A':'G':'E':'S':rest -> @@ -1224,7 +1245,7 @@ staticLink dflags o_files dep_packages = do -- parallel only: move binary to another dir -- HWL when (WayPar `elem` ways) - (do success <- runPhase_MoveBinary output_fn + (do success <- runPhase_MoveBinary dflags output_fn if success then return () else throwDyn (InstallationError ("cannot move binary to PVM dir")))