[project @ 2001-06-13 10:23:23 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverState.hs
index bbaadd5..8cad99c 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.25 2001/01/19 15:26:37 simonmar Exp $
+-- $Id: DriverState.hs,v 1.43 2001/06/13 10:23:23 simonmar Exp $
 --
 -- Settings for the driver
 --
@@ -9,6 +9,7 @@
 
 module DriverState where
 
+#include "../includes/config.h"
 #include "HsVersions.h"
 
 import CmStaticInfo
@@ -37,7 +38,7 @@ cHaskell1Version = "5" -- i.e., Haskell 98
 -- Global compilation flags
 
 -- location of compiler-related files
-GLOBAL_VAR(v_TopDir,  clibdir, String)
+GLOBAL_VAR(v_TopDir,  error "no TOPDIR", String)
 
 -- Cpp-related flags
 v_Hs_source_cpp_opts = global
@@ -92,10 +93,14 @@ defaultHscLang
   | otherwise                                  =  HscC
 
 GLOBAL_VAR(v_Output_dir,  Nothing, Maybe String)
-GLOBAL_VAR(v_Object_suf,  Nothing, Maybe String)
 GLOBAL_VAR(v_Output_file, Nothing, Maybe String)
 GLOBAL_VAR(v_Output_hi,   Nothing, Maybe String)
 
+GLOBAL_VAR(v_Object_suf,  Nothing, Maybe String)
+GLOBAL_VAR(v_HC_suf,     Nothing, Maybe String)
+GLOBAL_VAR(v_Hi_dir,      Nothing, Maybe String)
+GLOBAL_VAR(v_Hi_suf,      "hi",           String)
+
 GLOBAL_VAR(v_Ld_inputs,        [],      [String])
 
 odir_ify :: String -> IO String
@@ -113,50 +118,6 @@ osuf_ify f = do
        Just s  -> return (newsuf s f)
 
 -----------------------------------------------------------------------------
--- Hi Files
-
-GLOBAL_VAR(v_ProduceHi,        True,   Bool)
-GLOBAL_VAR(v_Hi_on_stdout,     False,  Bool)
-GLOBAL_VAR(v_Hi_suf,           "hi",   String)
-
------------------------------------------------------------------------------
--- Warnings & sanity checking
-
--- Warning packages that are controlled by -W and -Wall.  The 'standard'
--- warnings that you get all the time are
---        
---        -fwarn-overlapping-patterns
---        -fwarn-missing-methods
---        -fwarn-missing-fields
---        -fwarn-deprecations
---        -fwarn-duplicate-exports
--- 
--- these are turned off by -Wnot.
-
-
-standardWarnings  = [ "-fwarn-overlapping-patterns"
-                   , "-fwarn-missing-methods"
-                   , "-fwarn-missing-fields"
-                   , "-fwarn-deprecations"
-                   , "-fwarn-duplicate-exports"
-                   ]
-minusWOpts       = standardWarnings ++ 
-                   [ "-fwarn-unused-binds"
-                   , "-fwarn-unused-matches"
-                   , "-fwarn-incomplete-patterns"
-                   , "-fwarn-unused-imports"
-                   ]
-minusWallOpts    = minusWOpts ++
-                   [ "-fwarn-type-defaults"
-                   , "-fwarn-name-shadowing"
-                   , "-fwarn-missing-signatures"
-                   , "-fwarn-hi-shadowing"
-                   ]
-
-data WarningState = W_default | W_ | W_all | W_not
-GLOBAL_VAR(v_Warning_opt, W_default, WarningState)
-
------------------------------------------------------------------------------
 -- Compiler optimisation options
 
 GLOBAL_VAR(v_OptLevel, 0, Int)
@@ -182,16 +143,20 @@ hsc_minusNoO_flags =
        [ 
        "-fignore-interface-pragmas",
        "-fomit-interface-pragmas",
+       "-fdo-lambda-eta-expansion",    -- This one is important for a tiresome reason:
+                                       -- we want to make sure that the bindings for data 
+                                       -- constructors are eta-expanded.  This is probably
+                                       -- a good thing anyway, but it seems fragile.
        "-flet-no-escape"
        ]
 
 -- these are the static flags you get when -O is on.
 hsc_minusO_flags =
   [ 
+       "-fignore-asserts",
        "-ffoldr-build-on",
         "-fdo-eta-reduction",
        "-fdo-lambda-eta-expansion",
-       "-fcase-of-case",
        "-fcase-merge",
        "-flet-to-case",
        "-flet-no-escape"
@@ -314,6 +279,10 @@ buildCoreToDo = do
           CoreLiberateCase
        else
           CoreDoNothing,
+       if opt_level >= 2 then
+          CoreDoSpecConstr
+       else
+          CoreDoNothing,
 
        -- Final clean-up simplification:
        CoreDoSimplify (isAmongSimpl [
@@ -352,6 +321,8 @@ addToDirList ref path
   = do paths <- readIORef ref
        writeIORef ref (paths ++ split split_marker path)
 
+GLOBAL_VAR(v_HCHeader, "", String)
+
 -----------------------------------------------------------------------------
 -- Packages
 
@@ -364,7 +335,7 @@ addPackage :: String -> IO ()
 addPackage package
   = do pkg_details <- readIORef v_Package_details
        case lookupPkg package pkg_details of
-         Nothing -> throwDyn (OtherError ("unknown package name: " ++ package))
+         Nothing -> throwDyn (CmdLineError ("unknown package name: " ++ package))
          Just details -> do
            ps <- readIORef v_Packages
            unless (package `elem` ps) $ do
@@ -375,7 +346,7 @@ addPackage package
 getPackageImportPath   :: IO [String]
 getPackageImportPath = do
   ps <- getPackageInfo
-  return (nub (concat (map import_dirs ps)))
+  return (nub (filter (not.null) (concatMap import_dirs ps)))
 
 getPackageIncludePath   :: IO [String]
 getPackageIncludePath = do
@@ -391,7 +362,7 @@ getPackageCIncludes = do
 getPackageLibraryPath  :: IO [String]
 getPackageLibraryPath = do
   ps <- getPackageInfo
-  return (nub (concat (map library_dirs ps)))
+  return (nub (filter (not.null) (concatMap library_dirs ps)))
 
 getPackageLibraries    :: IO [String]
 getPackageLibraries = do
@@ -417,23 +388,24 @@ getPackageExtraLdOpts = do
   ps <- getPackageInfo
   return (concatMap extra_ld_opts ps)
 
-getPackageInfo :: IO [Package]
+getPackageInfo :: IO [PackageConfig]
 getPackageInfo = do
   ps <- readIORef v_Packages
   getPackageDetails ps
 
-getPackageDetails :: [String] -> IO [Package]
+getPackageDetails :: [String] -> IO [PackageConfig]
 getPackageDetails ps = do
   pkg_details <- readIORef v_Package_details
   return [ pkg | p <- ps, Just pkg <- [ lookupPkg p pkg_details ] ]
 
-GLOBAL_VAR(v_Package_details, (error "package_details"), [Package])
+GLOBAL_VAR(v_Package_details, (error "package_details"), [PackageConfig])
 
-lookupPkg :: String -> [Package] -> Maybe Package
+lookupPkg :: String -> [PackageConfig] -> Maybe PackageConfig
 lookupPkg nm ps
    = case [p | p <- ps, name p == nm] of
         []    -> Nothing
         (p:_) -> Just p
+
 -----------------------------------------------------------------------------
 -- Ways
 
@@ -490,7 +462,7 @@ findBuildTag :: IO [String]  -- new options
 findBuildTag = do
   way_names <- readIORef v_Ways
   case sort way_names of
-     []  -> do  writeIORef v_Build_tag ""
+     []  -> do  -- writeIORef v_Build_tag ""
                return []
 
      [w] -> do let details = lkupWay w
@@ -498,7 +470,7 @@ findBuildTag = do
               return (wayOpts details)
 
      ws  -> if not (allowed_combination ws)
-               then throwDyn (OtherError $
+               then throwDyn (CmdLineError $
                                "combination not supported: "  ++
                                foldr1 (\a b -> a ++ '/':b) 
                                (map (wayName . lkupWay) ws))
@@ -537,14 +509,45 @@ way_details =
     (WayUnreg, Way  "u" "Unregisterised" 
        unregFlags ),
 
+    -- optl's below to tell linker where to find the PVM library -- HWL
     (WayPar, Way  "mp" "Parallel" 
        [ "-fparallel"
        , "-D__PARALLEL_HASKELL__"
        , "-optc-DPAR"
        , "-package concurrent"
+        , "-optc-w"
+        , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
+        , "-optl-lpvm3"
+        , "-optl-lgpvm3"
        , "-fvia-C" ]),
 
-    (WayGran, Way  "mg" "Gransim" 
+    -- at the moment we only change the RTS and could share compiler and libs!
+    (WayPar, Way  "mt" "Parallel ticky profiling" 
+       [ "-fparallel"
+       , "-D__PARALLEL_HASKELL__"
+       , "-optc-DPAR"
+       , "-optc-DPAR_TICKY"
+       , "-package concurrent"
+        , "-optc-w"
+        , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
+        , "-optl-lpvm3"
+        , "-optl-lgpvm3"
+       , "-fvia-C" ]),
+
+    (WayPar, Way  "md" "Distributed" 
+       [ "-fparallel"
+       , "-D__PARALLEL_HASKELL__"
+       , "-D__DISTRIBUTED_HASKELL__"
+       , "-optc-DPAR"
+       , "-optc-DDIST"
+       , "-package concurrent"
+        , "-optc-w"
+        , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
+        , "-optl-lpvm3"
+        , "-optl-lgpvm3"
+       , "-fvia-C" ]),
+
+    (WayGran, Way  "mg" "GranSim" 
        [ "-fgransim"
        , "-D__GRANSIM__"
        , "-optc-DGRAN"
@@ -596,6 +599,10 @@ GLOBAL_VAR(v_Pgm_a,   cGCC,          String)
 GLOBAL_VAR(v_Pgm_l,   cGCC,          String)
 GLOBAL_VAR(v_Pgm_dll, cMkDLL,        String)
 
+#if defined(mingw32_TARGET_OS) && defined(MINIMAL_UNIX_DEPS)
+GLOBAL_VAR(v_Pgm_T,   cTOUCH,        String)
+#endif
+
 GLOBAL_VAR(v_Opt_dep,    [], [String])
 GLOBAL_VAR(v_Anti_opt_C, [], [String])
 GLOBAL_VAR(v_Opt_C,      [], [String])