499367dafdc38397b2a48a8dff362d87f73bfac0
[ghc-hetmet.git] / compiler / main / StaticFlags.hs
1 {-# OPTIONS -fno-cse #-}
2 -- -fno-cse is needed for GLOBAL_VAR's to behave properly
3
4 -----------------------------------------------------------------------------
5 --
6 -- Static flags
7 --
8 -- Static flags can only be set once, on the command-line.  Inside GHC,
9 -- each static flag corresponds to a top-level value, usually of type Bool.
10 --
11 -- (c) The University of Glasgow 2005
12 --
13 -----------------------------------------------------------------------------
14
15 module StaticFlags (
16         parseStaticFlags,
17         staticFlags,
18         initStaticOpts,
19
20         -- Ways
21         WayName(..), v_Ways, v_Build_tag, v_RTS_Build_tag, isRTSWay,
22
23         -- Output style options
24         opt_PprUserLength,
25         opt_SuppressUniques,
26         opt_PprStyle_Debug,
27         opt_NoDebugOutput,
28
29         -- profiling opts
30         opt_AutoSccsOnAllToplevs,
31         opt_AutoSccsOnExportedToplevs,
32         opt_AutoSccsOnIndividualCafs,
33         opt_SccProfilingOn,
34         opt_DoTickyProfiling,
35
36         -- Hpc opts
37         opt_Hpc,
38
39         -- language opts
40         opt_DictsStrict,
41         opt_IrrefutableTuples,
42         opt_Parallel,
43
44         -- optimisation opts
45         opt_DsMultiTyVar,
46         opt_NoStateHack,
47         opt_SpecInlineJoinPoints,
48         opt_CprOff,
49         opt_SimplNoPreInlining,
50         opt_SimplExcessPrecision,
51         opt_MaxWorkerArgs,
52
53         -- Unfolding control
54         opt_UF_CreationThreshold,
55         opt_UF_UseThreshold,
56         opt_UF_FunAppDiscount,
57         opt_UF_KeenessFactor,
58         opt_UF_DearOp,
59
60         -- Optimization fuel controls
61         opt_Fuel,
62
63         -- Related to linking
64         opt_PIC,
65         opt_Static,
66
67         -- misc opts
68         opt_IgnoreDotGhci,
69         opt_ErrorSpans,
70         opt_GranMacros,
71         opt_HiVersion,
72         opt_HistorySize,
73         opt_OmitBlackHoling,
74         opt_Unregisterised,
75         opt_EmitExternalCore,
76         v_Ld_inputs,
77         tablesNextToCode
78   ) where
79
80 #include "HsVersions.h"
81
82 import CmdLineParser
83 import Config
84 import FastString
85 import Util
86 import Maybes           ( firstJust )
87 import Panic
88
89 import Control.Exception ( throwDyn )
90 import Data.IORef
91 import System.IO.Unsafe ( unsafePerformIO )
92 import Control.Monad    ( when )
93 import Data.Char        ( isDigit )
94 import Data.List
95
96 -----------------------------------------------------------------------------
97 -- Static flags
98
99 parseStaticFlags :: [String] -> IO ([String], [String])
100 parseStaticFlags args = do
101   ready <- readIORef v_opt_C_ready
102   when ready $ throwDyn (ProgramError "Too late for parseStaticFlags: call it before newSession")
103
104   (leftover, errs, warns1) <- processArgs static_flags args
105   when (not (null errs)) $ throwDyn (UsageError (unlines errs))
106
107     -- deal with the way flags: the way (eg. prof) gives rise to
108     -- further flags, some of which might be static.
109   way_flags <- findBuildTag
110
111     -- if we're unregisterised, add some more flags
112   let unreg_flags | cGhcUnregisterised == "YES" = unregFlags
113                   | otherwise = []
114
115   (more_leftover, errs, warns2) <- processArgs static_flags (unreg_flags ++ way_flags)
116
117     -- see sanity code in staticOpts
118   writeIORef v_opt_C_ready True
119
120     -- TABLES_NEXT_TO_CODE affects the info table layout.
121     -- Be careful to do this *after* all processArgs,
122     -- because evaluating tablesNextToCode involves looking at the global
123     -- static flags.  Those pesky global variables...
124   let cg_flags | tablesNextToCode = ["-optc-DTABLES_NEXT_TO_CODE"]
125                | otherwise        = []
126
127     -- HACK: -fexcess-precision is both a static and a dynamic flag.  If
128     -- the static flag parser has slurped it, we must return it as a 
129     -- leftover too.  ToDo: make -fexcess-precision dynamic only.
130   let excess_prec | opt_SimplExcessPrecision = ["-fexcess-precision"]
131                   | otherwise                = []
132
133   when (not (null errs)) $ ghcError (UsageError (unlines errs))
134   return (excess_prec ++ cg_flags ++ more_leftover ++ leftover,
135           warns1 ++ warns2)
136
137 initStaticOpts :: IO ()
138 initStaticOpts = writeIORef v_opt_C_ready True
139
140 static_flags :: [Flag IO]
141 -- All the static flags should appear in this list.  It describes how each
142 -- static flag should be processed.  Two main purposes:
143 -- (a) if a command-line flag doesn't appear in the list, GHC can complain
144 -- (b) a command-line flag may remove, or add, other flags; e.g. the "-fno-X" things
145 --
146 -- The common (PassFlag addOpt) action puts the static flag into the bunch of
147 -- things that are searched up by the top-level definitions like
148 --      opt_foo = lookUp (fsLit "-dfoo")
149
150 -- Note that ordering is important in the following list: any flag which
151 -- is a prefix flag (i.e. HasArg, Prefix, OptPrefix, AnySuffix) will override
152 -- flags further down the list with the same prefix.
153
154 static_flags = [
155         ------- GHCi -------------------------------------------------------
156     Flag "ignore-dot-ghci" (PassFlag addOpt) Supported
157   , Flag "read-dot-ghci"   (NoArg (removeOpt "-ignore-dot-ghci")) Supported
158
159         ------- ways --------------------------------------------------------
160   , Flag "prof"           (NoArg (addWay WayProf)) Supported
161   , Flag "ticky"          (NoArg (addWay WayTicky)) Supported
162   , Flag "parallel"       (NoArg (addWay WayPar)) Supported
163   , Flag "gransim"        (NoArg (addWay WayGran)) Supported
164   , Flag "smp"            (NoArg (addWay WayThreaded))
165          (Deprecated "Use -threaded instead")
166   , Flag "debug"          (NoArg (addWay WayDebug)) Supported
167   , Flag "ndp"            (NoArg (addWay WayNDP)) Supported
168   , Flag "threaded"       (NoArg (addWay WayThreaded)) Supported
169         -- ToDo: user ways
170
171         ------ Debugging ----------------------------------------------------
172   , Flag "dppr-debug"        (PassFlag addOpt) Supported
173   , Flag "dsuppress-uniques" (PassFlag addOpt) Supported
174   , Flag "dppr-user-length"  (AnySuffix addOpt) Supported
175   , Flag "dopt-fuel"         (AnySuffix addOpt) Supported
176   , Flag "dno-debug-output"  (PassFlag addOpt) Supported
177       -- rest of the debugging flags are dynamic
178
179         --------- Profiling --------------------------------------------------
180   , Flag "auto-all"       (NoArg (addOpt "-fauto-sccs-on-all-toplevs"))
181          Supported
182   , Flag "auto"           (NoArg (addOpt "-fauto-sccs-on-exported-toplevs"))
183          Supported
184   , Flag "caf-all"        (NoArg (addOpt "-fauto-sccs-on-individual-cafs"))
185          Supported
186          -- "ignore-sccs"  doesn't work  (ToDo)
187
188   , Flag "no-auto-all"    (NoArg (removeOpt "-fauto-sccs-on-all-toplevs"))
189          Supported
190   , Flag "no-auto"        (NoArg (removeOpt "-fauto-sccs-on-exported-toplevs"))
191          Supported
192   , Flag "no-caf-all"     (NoArg (removeOpt "-fauto-sccs-on-individual-cafs"))
193          Supported
194
195         ----- Linker --------------------------------------------------------
196   , Flag "static"         (PassFlag addOpt) Supported
197   , Flag "dynamic"        (NoArg (removeOpt "-static")) Supported
198     -- ignored for compat w/ gcc:
199   , Flag "rdynamic"       (NoArg (return ())) Supported
200
201         ----- RTS opts ------------------------------------------------------
202   , Flag "H"              (HasArg (setHeapSize . fromIntegral . decodeSize))
203          Supported
204   , Flag "Rghc-timing"    (NoArg  (enableTimingStats)) Supported
205
206         ------ Compiler flags -----------------------------------------------
207         -- All other "-fno-<blah>" options cancel out "-f<blah>" on the hsc cmdline
208   , Flag "fno-"
209          (PrefixPred (\s -> isStaticFlag ("f"++s)) (\s -> removeOpt ("-f"++s)))
210          Supported
211
212         -- Pass all remaining "-f<blah>" options to hsc
213   , Flag "f"                      (AnySuffixPred (isStaticFlag) addOpt)
214          Supported
215   ]
216
217 addOpt :: String -> IO ()
218 addOpt = consIORef v_opt_C
219
220 addWay :: WayName -> IO ()
221 addWay = consIORef v_Ways
222
223 removeOpt :: String -> IO ()
224 removeOpt f = do
225   fs <- readIORef v_opt_C
226   writeIORef v_opt_C $! filter (/= f) fs    
227
228 lookUp           :: FastString -> Bool
229 lookup_def_int   :: String -> Int -> Int
230 lookup_def_float :: String -> Float -> Float
231 lookup_str       :: String -> Maybe String
232
233 -- holds the static opts while they're being collected, before
234 -- being unsafely read by unpacked_static_opts below.
235 GLOBAL_VAR(v_opt_C, defaultStaticOpts, [String])
236 GLOBAL_VAR(v_opt_C_ready, False, Bool)
237
238 staticFlags :: [String]
239 staticFlags = unsafePerformIO $ do
240   ready <- readIORef v_opt_C_ready
241   if (not ready)
242         then panic "Static flags have not been initialised!\n        Please call GHC.newSession or GHC.parseStaticFlags early enough."
243         else readIORef v_opt_C
244
245 -- -static is the default
246 defaultStaticOpts :: [String]
247 defaultStaticOpts = ["-static"]
248
249 packed_static_opts :: [FastString]
250 packed_static_opts   = map mkFastString staticFlags
251
252 lookUp     sw = sw `elem` packed_static_opts
253         
254 -- (lookup_str "foo") looks for the flag -foo=X or -fooX, 
255 -- and returns the string X
256 lookup_str sw 
257    = case firstJust (map (maybePrefixMatch sw) staticFlags) of
258         Just ('=' : str) -> Just str
259         Just str         -> Just str
260         Nothing          -> Nothing     
261
262 lookup_def_int sw def = case (lookup_str sw) of
263                             Nothing -> def              -- Use default
264                             Just xx -> try_read sw xx
265
266 lookup_def_float sw def = case (lookup_str sw) of
267                             Nothing -> def              -- Use default
268                             Just xx -> try_read sw xx
269
270
271 try_read :: Read a => String -> String -> a
272 -- (try_read sw str) tries to read s; if it fails, it
273 -- bleats about flag sw
274 try_read sw str
275   = case reads str of
276         ((x,_):_) -> x  -- Be forgiving: ignore trailing goop, and alternative parses
277         []        -> ghcError (UsageError ("Malformed argument " ++ str ++ " for flag " ++ sw))
278                         -- ToDo: hack alert. We should really parse the arugments
279                         --       and announce errors in a more civilised way.
280
281
282 {-
283  Putting the compiler options into temporary at-files
284  may turn out to be necessary later on if we turn hsc into
285  a pure Win32 application where I think there's a command-line
286  length limit of 255. unpacked_opts understands the @ option.
287
288 unpacked_opts :: [String]
289 unpacked_opts =
290   concat $
291   map (expandAts) $
292   map unpackFS argv  -- NOT ARGV any more: v_Static_hsc_opts
293   where
294    expandAts ('@':fname) = words (unsafePerformIO (readFile fname))
295    expandAts l = [l]
296 -}
297
298 opt_IgnoreDotGhci :: Bool
299 opt_IgnoreDotGhci               = lookUp (fsLit "-ignore-dot-ghci")
300
301 -- debugging opts
302 opt_SuppressUniques :: Bool
303 opt_SuppressUniques             = lookUp  (fsLit "-dsuppress-uniques")
304 opt_PprStyle_Debug  :: Bool
305 opt_PprStyle_Debug              = lookUp  (fsLit "-dppr-debug")
306 opt_PprUserLength   :: Int
307 opt_PprUserLength               = lookup_def_int "-dppr-user-length" 5 --ToDo: give this a name
308 opt_Fuel            :: Int
309 opt_Fuel                        = lookup_def_int "-dopt-fuel" maxBound
310 opt_NoDebugOutput   :: Bool
311 opt_NoDebugOutput               = lookUp  (fsLit "-dno-debug-output")
312
313
314 -- profiling opts
315 opt_AutoSccsOnAllToplevs :: Bool
316 opt_AutoSccsOnAllToplevs        = lookUp  (fsLit "-fauto-sccs-on-all-toplevs")
317 opt_AutoSccsOnExportedToplevs :: Bool
318 opt_AutoSccsOnExportedToplevs   = lookUp  (fsLit "-fauto-sccs-on-exported-toplevs")
319 opt_AutoSccsOnIndividualCafs :: Bool
320 opt_AutoSccsOnIndividualCafs    = lookUp  (fsLit "-fauto-sccs-on-individual-cafs")
321 opt_SccProfilingOn :: Bool
322 opt_SccProfilingOn              = lookUp  (fsLit "-fscc-profiling")
323 opt_DoTickyProfiling :: Bool
324 opt_DoTickyProfiling            = WayTicky `elem` (unsafePerformIO $ readIORef v_Ways)
325
326 -- Hpc opts
327 opt_Hpc :: Bool
328 opt_Hpc                         = lookUp (fsLit "-fhpc")  
329
330 -- language opts
331 opt_DictsStrict :: Bool
332 opt_DictsStrict                 = lookUp  (fsLit "-fdicts-strict")
333 opt_IrrefutableTuples :: Bool
334 opt_IrrefutableTuples           = lookUp  (fsLit "-firrefutable-tuples")
335 opt_Parallel :: Bool
336 opt_Parallel                    = lookUp  (fsLit "-fparallel")
337
338 -- optimisation opts
339 opt_DsMultiTyVar :: Bool
340 opt_DsMultiTyVar                = not (lookUp (fsLit "-fno-ds-multi-tyvar"))
341         -- On by default
342
343 opt_SpecInlineJoinPoints :: Bool
344 opt_SpecInlineJoinPoints        = lookUp  (fsLit "-fspec-inline-join-points")
345
346 opt_NoStateHack :: Bool
347 opt_NoStateHack                 = lookUp  (fsLit "-fno-state-hack")
348 opt_CprOff :: Bool
349 opt_CprOff                      = lookUp  (fsLit "-fcpr-off")
350         -- Switch off CPR analysis in the new demand analyser
351 opt_MaxWorkerArgs :: Int
352 opt_MaxWorkerArgs               = lookup_def_int "-fmax-worker-args" (10::Int)
353
354 opt_GranMacros :: Bool
355 opt_GranMacros                  = lookUp  (fsLit "-fgransim")
356 opt_HiVersion :: Integer
357 opt_HiVersion                   = read (cProjectVersionInt ++ cProjectPatchLevel) :: Integer
358 opt_HistorySize :: Int
359 opt_HistorySize                 = lookup_def_int "-fhistory-size" 20
360 opt_OmitBlackHoling :: Bool
361 opt_OmitBlackHoling             = lookUp  (fsLit "-dno-black-holing")
362
363 -- Simplifier switches
364 opt_SimplNoPreInlining :: Bool
365 opt_SimplNoPreInlining          = lookUp  (fsLit "-fno-pre-inlining")
366         -- NoPreInlining is there just to see how bad things
367         -- get if you don't do it!
368 opt_SimplExcessPrecision :: Bool
369 opt_SimplExcessPrecision        = lookUp  (fsLit "-fexcess-precision")
370
371 -- Unfolding control
372 opt_UF_CreationThreshold :: Int
373 opt_UF_CreationThreshold        = lookup_def_int "-funfolding-creation-threshold"  (45::Int)
374 opt_UF_UseThreshold :: Int
375 opt_UF_UseThreshold             = lookup_def_int "-funfolding-use-threshold"       (8::Int)     -- Discounts can be big
376 opt_UF_FunAppDiscount :: Int
377 opt_UF_FunAppDiscount           = lookup_def_int "-funfolding-fun-discount"        (6::Int)     -- It's great to inline a fn
378 opt_UF_KeenessFactor :: Float
379 opt_UF_KeenessFactor            = lookup_def_float "-funfolding-keeness-factor"    (1.5::Float)
380
381 opt_UF_DearOp :: Int
382 opt_UF_DearOp   = ( 4 :: Int)
383
384
385 -- Related to linking
386 opt_PIC :: Bool
387 #if darwin_TARGET_OS && x86_64_TARGET_ARCH
388 opt_PIC                         = True
389 #else
390 opt_PIC                         = lookUp (fsLit "-fPIC")
391 #endif
392 opt_Static :: Bool
393 opt_Static                      = lookUp  (fsLit "-static")
394 opt_Unregisterised :: Bool
395 opt_Unregisterised              = lookUp  (fsLit "-funregisterised")
396
397 -- Derived, not a real option.  Determines whether we will be compiling
398 -- info tables that reside just before the entry code, or with an
399 -- indirection to the entry code.  See TABLES_NEXT_TO_CODE in 
400 -- includes/InfoTables.h.
401 tablesNextToCode :: Bool
402 tablesNextToCode                = not opt_Unregisterised
403                                   && cGhcEnableTablesNextToCode == "YES"
404
405 opt_EmitExternalCore :: Bool
406 opt_EmitExternalCore            = lookUp  (fsLit "-fext-core")
407
408 -- Include full span info in error messages, instead of just the start position.
409 opt_ErrorSpans :: Bool
410 opt_ErrorSpans                  = lookUp (fsLit "-ferror-spans")
411
412
413 -- object files and libraries to be linked in are collected here.
414 -- ToDo: perhaps this could be done without a global, it wasn't obvious
415 -- how to do it though --SDM.
416 GLOBAL_VAR(v_Ld_inputs, [],      [String])
417
418 isStaticFlag :: String -> Bool
419 isStaticFlag f =
420   f `elem` [
421         "fauto-sccs-on-all-toplevs",
422         "fauto-sccs-on-exported-toplevs",
423         "fauto-sccs-on-individual-cafs",
424         "fscc-profiling",
425         "fdicts-strict",
426         "fspec-inline-join-points",
427         "firrefutable-tuples",
428         "fparallel",
429         "fgransim",
430         "fno-hi-version-check",
431         "dno-black-holing",
432         "fno-method-sharing",
433         "fno-state-hack",
434         "fno-ds-multi-tyvar",
435         "fruntime-types",
436         "fno-pre-inlining",
437         "fexcess-precision",
438         "static",
439         "fhardwire-lib-paths",
440         "funregisterised",
441         "fext-core",
442         "fcpr-off",
443         "ferror-spans",
444         "fPIC",
445         "fhpc"
446         ]
447   || any (`isPrefixOf` f) [
448         "fliberate-case-threshold",
449         "fmax-worker-args",
450         "fhistory-size",
451         "funfolding-creation-threshold",
452         "funfolding-use-threshold",
453         "funfolding-fun-discount",
454         "funfolding-keeness-factor"
455      ]
456
457 -----------------------------------------------------------------------------
458 -- convert sizes like "3.5M" into integers
459
460 decodeSize :: String -> Integer
461 decodeSize str
462   | c == ""              = truncate n
463   | c == "K" || c == "k" = truncate (n * 1000)
464   | c == "M" || c == "m" = truncate (n * 1000 * 1000)
465   | c == "G" || c == "g" = truncate (n * 1000 * 1000 * 1000)
466   | otherwise            = throwDyn (CmdLineError ("can't decode size: " ++ str))
467   where (m, c) = span pred str
468         n      = readRational m
469         pred c = isDigit c || c == '.'
470
471
472 -----------------------------------------------------------------------------
473 -- RTS Hooks
474
475 foreign import ccall unsafe "setHeapSize"       setHeapSize       :: Int -> IO ()
476 foreign import ccall unsafe "enableTimingStats" enableTimingStats :: IO ()
477
478 -----------------------------------------------------------------------------
479 -- Ways
480
481 -- The central concept of a "way" is that all objects in a given
482 -- program must be compiled in the same "way".  Certain options change
483 -- parameters of the virtual machine, eg. profiling adds an extra word
484 -- to the object header, so profiling objects cannot be linked with
485 -- non-profiling objects.
486
487 -- After parsing the command-line options, we determine which "way" we
488 -- are building - this might be a combination way, eg. profiling+ticky-ticky.
489
490 -- We then find the "build-tag" associated with this way, and this
491 -- becomes the suffix used to find .hi files and libraries used in
492 -- this compilation.
493
494 GLOBAL_VAR(v_Build_tag, "", String)
495
496 -- The RTS has its own build tag, because there are some ways that
497 -- affect the RTS only.
498 GLOBAL_VAR(v_RTS_Build_tag, "", String)
499
500 data WayName
501   = WayThreaded
502   | WayDebug
503   | WayProf
504   | WayTicky
505   | WayPar
506   | WayGran
507   | WayNDP
508   | WayUser_a
509   | WayUser_b
510   | WayUser_c
511   | WayUser_d
512   | WayUser_e
513   | WayUser_f
514   | WayUser_g
515   | WayUser_h
516   | WayUser_i
517   | WayUser_j
518   | WayUser_k
519   | WayUser_l
520   | WayUser_m
521   | WayUser_n
522   | WayUser_o
523   | WayUser_A
524   | WayUser_B
525   deriving (Eq,Ord)
526
527 GLOBAL_VAR(v_Ways, [] ,[WayName])
528
529 allowed_combination :: [WayName] -> Bool
530 allowed_combination way = and [ x `allowedWith` y 
531                               | x <- way, y <- way, x < y ]
532   where
533         -- Note ordering in these tests: the left argument is
534         -- <= the right argument, according to the Ord instance
535         -- on Way above.
536
537         -- debug is allowed with everything
538         _ `allowedWith` WayDebug                = True
539         WayDebug `allowedWith` _                = True
540
541         WayProf `allowedWith` WayNDP            = True
542         WayThreaded `allowedWith` WayProf       = True
543         _ `allowedWith` _                       = False
544
545
546 findBuildTag :: IO [String]  -- new options
547 findBuildTag = do
548   way_names <- readIORef v_Ways
549   let ws = sort (nub way_names)
550
551   if not (allowed_combination ws)
552       then throwDyn (CmdLineError $
553                     "combination not supported: "  ++
554                     foldr1 (\a b -> a ++ '/':b) 
555                     (map (wayName . lkupWay) ws))
556       else let ways    = map lkupWay ws
557                tag     = mkBuildTag (filter (not.wayRTSOnly) ways)
558                rts_tag = mkBuildTag ways
559                flags   = map wayOpts ways
560            in do
561            writeIORef v_Build_tag tag
562            writeIORef v_RTS_Build_tag rts_tag
563            return (concat flags)
564
565
566
567 mkBuildTag :: [Way] -> String
568 mkBuildTag ways = concat (intersperse "_" (map wayTag ways))
569
570 lkupWay :: WayName -> Way
571 lkupWay w = 
572    case lookup w way_details of
573         Nothing -> error "findBuildTag"
574         Just details -> details
575
576 isRTSWay :: WayName -> Bool
577 isRTSWay = wayRTSOnly . lkupWay 
578
579 data Way = Way {
580   wayTag     :: String,
581   wayRTSOnly :: Bool,
582   wayName    :: String,
583   wayOpts    :: [String]
584   }
585
586 way_details :: [ (WayName, Way) ]
587 way_details =
588   [ (WayThreaded, Way "thr" True "Threaded" [
589 #if defined(freebsd_TARGET_OS)
590 --        "-optc-pthread"
591 --      , "-optl-pthread"
592         -- FreeBSD's default threading library is the KSE-based M:N libpthread,
593         -- which GHC has some problems with.  It's currently not clear whether
594         -- the problems are our fault or theirs, but it seems that using the
595         -- alternative 1:1 threading library libthr works around it:
596           "-optl-lthr"
597 #elif defined(solaris2_TARGET_OS)
598           "-optl-lrt"
599 #endif
600         ] ),
601
602     (WayDebug, Way "debug" True "Debug" [] ),
603
604     (WayProf, Way  "p" False "Profiling"
605         [ "-fscc-profiling"
606         , "-DPROFILING"
607         , "-optc-DPROFILING" ]),
608
609     (WayTicky, Way  "t" True "Ticky-ticky Profiling"  
610         [ "-DTICKY_TICKY"
611         , "-optc-DTICKY_TICKY" ]),
612
613     -- optl's below to tell linker where to find the PVM library -- HWL
614     (WayPar, Way  "mp" False "Parallel" 
615         [ "-fparallel"
616         , "-D__PARALLEL_HASKELL__"
617         , "-optc-DPAR"
618         , "-package concurrent"
619         , "-optc-w"
620         , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
621         , "-optl-lpvm3"
622         , "-optl-lgpvm3" ]),
623
624     -- at the moment we only change the RTS and could share compiler and libs!
625     (WayPar, Way  "mt" False "Parallel ticky profiling" 
626         [ "-fparallel"
627         , "-D__PARALLEL_HASKELL__"
628         , "-optc-DPAR"
629         , "-optc-DPAR_TICKY"
630         , "-package concurrent"
631         , "-optc-w"
632         , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
633         , "-optl-lpvm3"
634         , "-optl-lgpvm3" ]),
635
636     (WayPar, Way  "md" False "Distributed" 
637         [ "-fparallel"
638         , "-D__PARALLEL_HASKELL__"
639         , "-D__DISTRIBUTED_HASKELL__"
640         , "-optc-DPAR"
641         , "-optc-DDIST"
642         , "-package concurrent"
643         , "-optc-w"
644         , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
645         , "-optl-lpvm3"
646         , "-optl-lgpvm3" ]),
647
648     (WayGran, Way  "mg" False "GranSim"
649         [ "-fgransim"
650         , "-D__GRANSIM__"
651         , "-optc-DGRAN"
652         , "-package concurrent" ]),
653
654     (WayNDP, Way  "ndp" False "Nested data parallelism"
655         [ "-XParr"
656         , "-fvectorise"]),
657
658     (WayUser_a,  Way  "a"  False "User way 'a'"  ["$WAY_a_REAL_OPTS"]), 
659     (WayUser_b,  Way  "b"  False "User way 'b'"  ["$WAY_b_REAL_OPTS"]), 
660     (WayUser_c,  Way  "c"  False "User way 'c'"  ["$WAY_c_REAL_OPTS"]), 
661     (WayUser_d,  Way  "d"  False "User way 'd'"  ["$WAY_d_REAL_OPTS"]), 
662     (WayUser_e,  Way  "e"  False "User way 'e'"  ["$WAY_e_REAL_OPTS"]), 
663     (WayUser_f,  Way  "f"  False "User way 'f'"  ["$WAY_f_REAL_OPTS"]), 
664     (WayUser_g,  Way  "g"  False "User way 'g'"  ["$WAY_g_REAL_OPTS"]), 
665     (WayUser_h,  Way  "h"  False "User way 'h'"  ["$WAY_h_REAL_OPTS"]), 
666     (WayUser_i,  Way  "i"  False "User way 'i'"  ["$WAY_i_REAL_OPTS"]), 
667     (WayUser_j,  Way  "j"  False "User way 'j'"  ["$WAY_j_REAL_OPTS"]), 
668     (WayUser_k,  Way  "k"  False "User way 'k'"  ["$WAY_k_REAL_OPTS"]), 
669     (WayUser_l,  Way  "l"  False "User way 'l'"  ["$WAY_l_REAL_OPTS"]), 
670     (WayUser_m,  Way  "m"  False "User way 'm'"  ["$WAY_m_REAL_OPTS"]), 
671     (WayUser_n,  Way  "n"  False "User way 'n'"  ["$WAY_n_REAL_OPTS"]), 
672     (WayUser_o,  Way  "o"  False "User way 'o'"  ["$WAY_o_REAL_OPTS"]), 
673     (WayUser_A,  Way  "A"  False "User way 'A'"  ["$WAY_A_REAL_OPTS"]), 
674     (WayUser_B,  Way  "B"  False "User way 'B'"  ["$WAY_B_REAL_OPTS"]) 
675   ]
676
677 unregFlags :: [String]
678 unregFlags = 
679    [ "-optc-DNO_REGS"
680    , "-optc-DUSE_MINIINTERPRETER"
681    , "-fno-asm-mangling"
682    , "-funregisterised"
683    , "-fvia-C" ]