+{-# OPTIONS -fno-cse #-}
+-- -fno-cse is needed for GLOBAL_VAR's to behave properly
+
-----------------------------------------------------------------------------
--
-- GHC Driver
import SrcLoc ( Located(..) )
import FastString
-import Control.Exception as Exception
+import Exception
import Data.IORef ( readIORef, writeIORef, IORef )
import GHC.Exts ( Int(..) )
import System.Directory
compileFile hsc_env stop_phase (src, mb_phase) = do
exists <- doesFileExist src
when (not exists) $
- throwDyn (CmdLineError ("does not exist: " ++ src))
+ ghcError (CmdLineError ("does not exist: " ++ src))
let
dflags = hsc_dflags hsc_env
-- Always link in the haskell98 package for static linking. Other
-- packages have to be specified via the -package flag.
link_pkgs
- | dopt Opt_LinkHaskell98 dflags = [haskell98PackageId]
- | otherwise = []
+ | dopt Opt_AutoLinkPackages dflags = [haskell98PackageId]
+ | otherwise = []
-- ---------------------------------------------------------------------------
-- before B in a normal compilation pipeline.
when (not (start_phase `happensBefore` stop_phase)) $
- throwDyn (UsageError
+ ghcError (UsageError
("cannot compile this file to desired target: "
++ input_fn))
Nothing -- No "module i of n" progress info
case mbResult of
- Nothing -> throwDyn (PhaseFailed "hsc" (ExitFailure 1))
+ Nothing -> ghcError (PhaseFailed "hsc" (ExitFailure 1))
Just HscNoRecomp
-> do SysTools.touch dflags' "Touching object file" o_file
-- The .o file must have a later modification date
ok <- hscCmmFile hsc_env' input_fn
- when (not ok) $ throwDyn (PhaseFailed "cmm" (ExitFailure 1))
+ when (not ok) $ ghcError (PhaseFailed "cmm" (ExitFailure 1))
return (next_phase, dflags, maybe_loc, output_fn)
pvm_executable_base = "=" ++ input_fn
pvm_executable = pvm_root ++ "/bin/" ++ pvm_arch ++ "/" ++ pvm_executable_base
-- nuke old binary; maybe use configur'ed names for cp and rm?
- Panic.try (removeFile pvm_executable)
+ tryIO (removeFile pvm_executable)
-- move the newly created binary into PVM land
copy dflags "copying PVM executable" input_fn pvm_executable
-- generate a wrapper script for running a parallel prg under PVM
-- parallel only: move binary to another dir -- HWL
success <- runPhase_MoveBinary dflags output_fn dep_packages
if success then return ()
- else throwDyn (InstallationError ("cannot move binary"))
+ else ghcError (InstallationError ("cannot move binary"))
exeFileName :: DynFlags -> FilePath
let verb = getVerbFlag dflags
let o_file = outputFile dflags
- pkg_lib_paths <- getPackageLibraryPath dflags dep_packages
+ -- We don't want to link our dynamic libs against the RTS package,
+ -- because the RTS lib comes in several flavours and we want to be
+ -- able to pick the flavour when a binary is linked.
+ pkgs <- getPreloadPackagesAnd dflags dep_packages
+ let pkgs_no_rts = filter ((/= rtsPackageId) . packageConfigId) pkgs
+
+ let pkg_lib_paths = collectLibraryPaths pkgs_no_rts
let pkg_lib_path_opts = map ("-L"++) pkg_lib_paths
let lib_paths = libraryPaths dflags
let lib_path_opts = map ("-L"++) lib_paths
- pkg_link_opts <- getPackageLinkOpts dflags dep_packages
+ let pkg_link_opts = collectLinkOpts dflags pkgs_no_rts
-- probably _stub.o files
extra_ld_inputs <- readIORef v_Ld_inputs