[project @ 2001-06-12 17:07:23 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverState.hs
1 -----------------------------------------------------------------------------
2 -- $Id: DriverState.hs,v 1.42 2001/06/12 17:07:23 simonmar Exp $
3 --
4 -- Settings for the driver
5 --
6 -- (c) The University of Glasgow 2000
7 --
8 -----------------------------------------------------------------------------
9
10 module DriverState where
11
12 #include "../includes/config.h"
13 #include "HsVersions.h"
14
15 import CmStaticInfo
16 import CmdLineOpts
17 import DriverUtil
18 import Util
19 import Config
20 import Exception
21 import IOExts
22 #ifdef mingw32_TARGET_OS
23 import TmpFiles ( newTempName )
24 import Directory ( removeFile )
25 #endif
26 import Panic
27
28 import List
29 import Char  
30 import Monad
31
32 -----------------------------------------------------------------------------
33 -- non-configured things
34
35 cHaskell1Version = "5" -- i.e., Haskell 98
36
37 -----------------------------------------------------------------------------
38 -- Global compilation flags
39
40 -- location of compiler-related files
41 GLOBAL_VAR(v_TopDir,  error "no TOPDIR", String)
42
43 -- Cpp-related flags
44 v_Hs_source_cpp_opts = global
45         [ "-D__HASKELL1__="++cHaskell1Version
46         , "-D__GLASGOW_HASKELL__="++cProjectVersionInt                          
47         , "-D__HASKELL98__"
48         , "-D__CONCURRENT_HASKELL__"
49         ]
50 {-# NOINLINE v_Hs_source_cpp_opts #-}
51
52 -- Keep output from intermediate phases
53 GLOBAL_VAR(v_Keep_hi_diffs,             False,          Bool)
54 GLOBAL_VAR(v_Keep_hc_files,             False,          Bool)
55 GLOBAL_VAR(v_Keep_s_files,              False,          Bool)
56 GLOBAL_VAR(v_Keep_raw_s_files,          False,          Bool)
57 GLOBAL_VAR(v_Keep_tmp_files,            False,          Bool)
58
59 -- Misc
60 GLOBAL_VAR(v_Scale_sizes_by,            1.0,            Double)
61 GLOBAL_VAR(v_Dry_run,                   False,          Bool)
62 GLOBAL_VAR(v_Static,                    True,           Bool)
63 GLOBAL_VAR(v_NoHsMain,                  False,          Bool)
64 GLOBAL_VAR(v_Recomp,                    True,           Bool)
65 GLOBAL_VAR(v_Collect_ghc_timing,        False,          Bool)
66 GLOBAL_VAR(v_Do_asm_mangling,           True,           Bool)
67 GLOBAL_VAR(v_Excess_precision,          False,          Bool)
68
69 -----------------------------------------------------------------------------
70 -- Splitting object files (for libraries)
71
72 GLOBAL_VAR(v_Split_object_files,        False,          Bool)
73 GLOBAL_VAR(v_Split_prefix,              "",             String)
74 GLOBAL_VAR(v_N_split_files,             0,              Int)
75         
76 can_split :: Bool
77 can_split =  prefixMatch "i386"    cTARGETPLATFORM
78           || prefixMatch "alpha"   cTARGETPLATFORM
79           || prefixMatch "hppa"    cTARGETPLATFORM
80           || prefixMatch "m68k"    cTARGETPLATFORM
81           || prefixMatch "mips"    cTARGETPLATFORM
82           || prefixMatch "powerpc" cTARGETPLATFORM
83           || prefixMatch "rs6000"  cTARGETPLATFORM
84           || prefixMatch "sparc"   cTARGETPLATFORM
85
86 -----------------------------------------------------------------------------
87 -- Compiler output options
88
89 defaultHscLang
90   | cGhcWithNativeCodeGen == "YES" && 
91         (prefixMatch "i386" cTARGETPLATFORM ||
92          prefixMatch "sparc" cTARGETPLATFORM)   =  HscAsm
93   | otherwise                                   =  HscC
94
95 GLOBAL_VAR(v_Output_dir,  Nothing, Maybe String)
96 GLOBAL_VAR(v_Output_file, Nothing, Maybe String)
97 GLOBAL_VAR(v_Output_hi,   Nothing, Maybe String)
98
99 GLOBAL_VAR(v_Object_suf,  Nothing, Maybe String)
100 GLOBAL_VAR(v_HC_suf,      Nothing, Maybe String)
101 GLOBAL_VAR(v_Hi_dir,      Nothing, Maybe String)
102 GLOBAL_VAR(v_Hi_suf,      "hi",    String)
103
104 GLOBAL_VAR(v_Ld_inputs, [],      [String])
105
106 odir_ify :: String -> IO String
107 odir_ify f = do
108   odir_opt <- readIORef v_Output_dir
109   case odir_opt of
110         Nothing -> return f
111         Just d  -> return (newdir d f)
112
113 osuf_ify :: String -> IO String
114 osuf_ify f = do
115   osuf_opt <- readIORef v_Object_suf
116   case osuf_opt of
117         Nothing -> return f
118         Just s  -> return (newsuf s f)
119
120 -----------------------------------------------------------------------------
121 -- Compiler optimisation options
122
123 GLOBAL_VAR(v_OptLevel, 0, Int)
124
125 setOptLevel :: String -> IO ()
126 setOptLevel ""              = do { writeIORef v_OptLevel 1 }
127 setOptLevel "not"           = writeIORef v_OptLevel 0
128 setOptLevel [c] | isDigit c = do
129    let level = ord c - ord '0'
130    writeIORef v_OptLevel level
131 setOptLevel s = unknownFlagErr ("-O"++s)
132
133 GLOBAL_VAR(v_minus_o2_for_C,            False, Bool)
134 GLOBAL_VAR(v_MaxSimplifierIterations,   4,     Int)
135 GLOBAL_VAR(v_StgStats,                  False, Bool)
136 GLOBAL_VAR(v_UsageSPInf,                False, Bool)  -- Off by default
137 GLOBAL_VAR(v_Strictness,                True,  Bool)
138 GLOBAL_VAR(v_CPR,                       True,  Bool)
139 GLOBAL_VAR(v_CSE,                       True,  Bool)
140
141 -- these are the static flags you get without -O.
142 hsc_minusNoO_flags =
143        [ 
144         "-fignore-interface-pragmas",
145         "-fomit-interface-pragmas",
146         "-fdo-lambda-eta-expansion",    -- This one is important for a tiresome reason:
147                                         -- we want to make sure that the bindings for data 
148                                         -- constructors are eta-expanded.  This is probably
149                                         -- a good thing anyway, but it seems fragile.
150         "-flet-no-escape"
151         ]
152
153 -- these are the static flags you get when -O is on.
154 hsc_minusO_flags =
155   [ 
156         "-fignore-asserts",
157         "-ffoldr-build-on",
158         "-fdo-eta-reduction",
159         "-fdo-lambda-eta-expansion",
160         "-fcase-merge",
161         "-flet-to-case",
162         "-flet-no-escape"
163    ]
164
165 hsc_minusO2_flags = hsc_minusO_flags    -- for now
166
167 getStaticOptimisationFlags 0 = hsc_minusNoO_flags
168 getStaticOptimisationFlags 1 = hsc_minusO_flags
169 getStaticOptimisationFlags n = hsc_minusO2_flags
170
171 buildCoreToDo :: IO [CoreToDo]
172 buildCoreToDo = do
173    opt_level  <- readIORef v_OptLevel
174    max_iter   <- readIORef v_MaxSimplifierIterations
175    usageSP    <- readIORef v_UsageSPInf
176    strictness <- readIORef v_Strictness
177    cpr        <- readIORef v_CPR
178    cse        <- readIORef v_CSE
179
180    if opt_level == 0 then return
181       [
182         CoreDoSimplify (isAmongSimpl [
183             MaxSimplifierIterations max_iter
184         ])
185       ]
186
187     else {- opt_level >= 1 -} return [ 
188
189         -- initial simplify: mk specialiser happy: minimum effort please
190         CoreDoSimplify (isAmongSimpl [
191             SimplInlinePhase 0,
192                         -- Don't inline anything till full laziness has bitten
193                         -- In particular, inlining wrappers inhibits floating
194                         -- e.g. ...(case f x of ...)...
195                         --  ==> ...(case (case x of I# x# -> fw x#) of ...)...
196                         --  ==> ...(case x of I# x# -> case fw x# of ...)...
197                         -- and now the redex (f x) isn't floatable any more
198             DontApplyRules,
199                         -- Similarly, don't apply any rules until after full 
200                         -- laziness.  Notably, list fusion can prevent floating.
201             NoCaseOfCase,
202                         -- Don't do case-of-case transformations.
203                         -- This makes full laziness work better
204             MaxSimplifierIterations max_iter
205         ]),
206
207         -- Specialisation is best done before full laziness
208         -- so that overloaded functions have all their dictionary lambdas manifest
209         CoreDoSpecialising,
210
211         CoreDoFloatOutwards False{-not full-},
212         CoreDoFloatInwards,
213
214         CoreDoSimplify (isAmongSimpl [
215            SimplInlinePhase 1,
216                 -- Want to run with inline phase 1 after the specialiser to give
217                 -- maximum chance for fusion to work before we inline build/augment
218                 -- in phase 2.  This made a difference in 'ansi' where an 
219                 -- overloaded function wasn't inlined till too late.
220            MaxSimplifierIterations max_iter
221         ]),
222
223         -- infer usage information here in case we need it later.
224         -- (add more of these where you need them --KSW 1999-04)
225         if usageSP then CoreDoUSPInf else CoreDoNothing,
226
227         CoreDoSimplify (isAmongSimpl [
228                 -- Need inline-phase2 here so that build/augment get 
229                 -- inlined.  I found that spectral/hartel/genfft lost some useful
230                 -- strictness in the function sumcode' if augment is not inlined
231                 -- before strictness analysis runs
232            SimplInlinePhase 2,
233            MaxSimplifierIterations max_iter
234         ]),
235
236         CoreDoSimplify (isAmongSimpl [
237            MaxSimplifierIterations 2
238                 -- No -finline-phase: allow all Ids to be inlined now
239                 -- This gets foldr inlined before strictness analysis
240         ]),
241
242         if strictness then CoreDoStrictness else CoreDoNothing,
243         if cpr        then CoreDoCPResult   else CoreDoNothing,
244         CoreDoWorkerWrapper,
245         CoreDoGlomBinds,
246
247         CoreDoSimplify (isAmongSimpl [
248            MaxSimplifierIterations max_iter
249                 -- No -finline-phase: allow all Ids to be inlined now
250         ]),
251
252         CoreDoFloatOutwards False{-not full-},
253                 -- nofib/spectral/hartel/wang doubles in speed if you
254                 -- do full laziness late in the day.  It only happens
255                 -- after fusion and other stuff, so the early pass doesn't
256                 -- catch it.  For the record, the redex is 
257                 --        f_el22 (f_el21 r_midblock)
258
259
260 -- Leave out lambda lifting for now
261 --        "-fsimplify", -- Tidy up results of full laziness
262 --          "[", 
263 --                "-fmax-simplifier-iterations2",
264 --          "]",
265 --        "-ffloat-outwards-full",      
266
267         -- We want CSE to follow the final full-laziness pass, because it may
268         -- succeed in commoning up things floated out by full laziness.
269         -- CSE used to rely on the no-shadowing invariant, but it doesn't any more
270
271         if cse then CoreCSE else CoreDoNothing,
272
273         CoreDoFloatInwards,
274
275 -- Case-liberation for -O2.  This should be after
276 -- strictness analysis and the simplification which follows it.
277
278         if opt_level >= 2 then
279            CoreLiberateCase
280         else
281            CoreDoNothing,
282         if opt_level >= 2 then
283            CoreDoSpecConstr
284         else
285            CoreDoNothing,
286
287         -- Final clean-up simplification:
288         CoreDoSimplify (isAmongSimpl [
289           MaxSimplifierIterations max_iter
290                 -- No -finline-phase: allow all Ids to be inlined now
291         ])
292      ]
293
294 buildStgToDo :: IO [ StgToDo ]
295 buildStgToDo = do
296   stg_stats <- readIORef v_StgStats
297   let flags1 | stg_stats = [ D_stg_stats ]
298              | otherwise = [ ]
299
300         -- STG passes
301   ways_ <- readIORef v_Ways
302   let flags2 | WayProf `elem` ways_ = StgDoMassageForProfiling : flags1
303              | otherwise            = flags1
304
305   return flags2
306
307 -----------------------------------------------------------------------------
308 -- Paths & Libraries
309
310 split_marker = ':'   -- not configurable (ToDo)
311
312 v_Import_paths, v_Include_paths, v_Library_paths :: IORef [String]
313 GLOBAL_VAR(v_Import_paths,  ["."], [String])
314 GLOBAL_VAR(v_Include_paths, ["."], [String])
315 GLOBAL_VAR(v_Library_paths, [],  [String])
316
317 GLOBAL_VAR(v_Cmdline_libraries,   [], [String])
318
319 addToDirList :: IORef [String] -> String -> IO ()
320 addToDirList ref path
321   = do paths <- readIORef ref
322        writeIORef ref (paths ++ split split_marker path)
323
324 GLOBAL_VAR(v_HCHeader, "", String)
325
326 -----------------------------------------------------------------------------
327 -- Packages
328
329 GLOBAL_VAR(v_Path_package_config, error "path_package_config", String)
330
331 -- package list is maintained in dependency order
332 GLOBAL_VAR(v_Packages, ("std":"rts":"gmp":[]), [String])
333
334 addPackage :: String -> IO ()
335 addPackage package
336   = do pkg_details <- readIORef v_Package_details
337        case lookupPkg package pkg_details of
338           Nothing -> throwDyn (CmdLineError ("unknown package name: " ++ package))
339           Just details -> do
340             ps <- readIORef v_Packages
341             unless (package `elem` ps) $ do
342                 mapM_ addPackage (package_deps details)
343                 ps <- readIORef v_Packages
344                 writeIORef v_Packages (package:ps)
345
346 getPackageImportPath   :: IO [String]
347 getPackageImportPath = do
348   ps <- getPackageInfo
349   munge_paths (concatMap import_dirs ps)
350
351 getPackageIncludePath   :: IO [String]
352 getPackageIncludePath = do
353   ps <- getPackageInfo
354   munge_paths (concatMap include_dirs ps)
355
356         -- includes are in reverse dependency order (i.e. rts first)
357 getPackageCIncludes   :: IO [String]
358 getPackageCIncludes = do
359   ps <- getPackageInfo
360   return (reverse (nub (filter (not.null) (concatMap c_includes ps))))
361
362 getPackageLibraryPath  :: IO [String]
363 getPackageLibraryPath = do
364   ps <- getPackageInfo
365   munge_paths (concatMap library_dirs ps)
366
367 getPackageLibraries    :: IO [String]
368 getPackageLibraries = do
369   ps <- getPackageInfo
370   tag <- readIORef v_Build_tag
371   let suffix = if null tag then "" else '_':tag
372   return (concat (
373         map (\p -> map (++suffix) (hs_libraries p) ++ extra_libraries p) ps
374      ))
375
376 getPackageExtraGhcOpts :: IO [String]
377 getPackageExtraGhcOpts = do
378   ps <- getPackageInfo
379   return (concatMap extra_ghc_opts ps)
380
381 getPackageExtraCcOpts  :: IO [String]
382 getPackageExtraCcOpts = do
383   ps <- getPackageInfo
384   return (concatMap extra_cc_opts ps)
385
386 getPackageExtraLdOpts  :: IO [String]
387 getPackageExtraLdOpts = do
388   ps <- getPackageInfo
389   return (concatMap extra_ld_opts ps)
390
391 getPackageInfo :: IO [PackageConfig]
392 getPackageInfo = do
393   ps <- readIORef v_Packages
394   getPackageDetails ps
395
396 getPackageDetails :: [String] -> IO [PackageConfig]
397 getPackageDetails ps = do
398   pkg_details <- readIORef v_Package_details
399   return [ pkg | p <- ps, Just pkg <- [ lookupPkg p pkg_details ] ]
400
401 GLOBAL_VAR(v_Package_details, (error "package_details"), [PackageConfig])
402
403 lookupPkg :: String -> [PackageConfig] -> Maybe PackageConfig
404 lookupPkg nm ps
405    = case [p | p <- ps, name p == nm] of
406         []    -> Nothing
407         (p:_) -> Just p
408
409 munge_paths ps = do
410   topdir <- readIORef v_TopDir
411   return (nub (filter (not.null) (map (munge_path topdir) ps)))
412  where munge_path topdir p 
413           | Just p' <- my_prefix_match "$libdir" p = topdir ++ p'
414           | otherwise = p
415
416 -----------------------------------------------------------------------------
417 -- Ways
418
419 -- The central concept of a "way" is that all objects in a given
420 -- program must be compiled in the same "way".  Certain options change
421 -- parameters of the virtual machine, eg. profiling adds an extra word
422 -- to the object header, so profiling objects cannot be linked with
423 -- non-profiling objects.
424
425 -- After parsing the command-line options, we determine which "way" we
426 -- are building - this might be a combination way, eg. profiling+ticky-ticky.
427
428 -- We then find the "build-tag" associated with this way, and this
429 -- becomes the suffix used to find .hi files and libraries used in
430 -- this compilation.
431
432 GLOBAL_VAR(v_Build_tag, "", String)
433
434 data WayName
435   = WayProf
436   | WayUnreg
437   | WayTicky
438   | WayPar
439   | WayGran
440   | WaySMP
441   | WayDebug
442   | WayUser_a
443   | WayUser_b
444   | WayUser_c
445   | WayUser_d
446   | WayUser_e
447   | WayUser_f
448   | WayUser_g
449   | WayUser_h
450   | WayUser_i
451   | WayUser_j
452   | WayUser_k
453   | WayUser_l
454   | WayUser_m
455   | WayUser_n
456   | WayUser_o
457   | WayUser_A
458   | WayUser_B
459   deriving (Eq,Ord)
460
461 GLOBAL_VAR(v_Ways, [] ,[WayName])
462
463 allowed_combination way = way `elem` combs
464   where  -- the sub-lists must be ordered according to WayName, 
465          -- because findBuildTag sorts them
466     combs                = [ [WayProf,WayUnreg], [WayProf,WaySMP] ]
467
468 findBuildTag :: IO [String]  -- new options
469 findBuildTag = do
470   way_names <- readIORef v_Ways
471   case sort way_names of
472      []  -> do  -- writeIORef v_Build_tag ""
473                 return []
474
475      [w] -> do let details = lkupWay w
476                writeIORef v_Build_tag (wayTag details)
477                return (wayOpts details)
478
479      ws  -> if not (allowed_combination ws)
480                 then throwDyn (CmdLineError $
481                                 "combination not supported: "  ++
482                                 foldr1 (\a b -> a ++ '/':b) 
483                                 (map (wayName . lkupWay) ws))
484                 else let stuff = map lkupWay ws
485                          tag   = concat (map wayTag stuff)
486                          flags = map wayOpts stuff
487                      in do
488                      writeIORef v_Build_tag tag
489                      return (concat flags)
490
491 lkupWay w = 
492    case lookup w way_details of
493         Nothing -> error "findBuildTag"
494         Just details -> details
495
496 data Way = Way {
497   wayTag   :: String,
498   wayName  :: String,
499   wayOpts  :: [String]
500   }
501
502 way_details :: [ (WayName, Way) ]
503 way_details =
504   [ (WayProf, Way  "p" "Profiling"  
505         [ "-fscc-profiling"
506         , "-DPROFILING"
507         , "-optc-DPROFILING"
508         , "-fvia-C" ]),
509
510     (WayTicky, Way  "t" "Ticky-ticky Profiling"  
511         [ "-fticky-ticky"
512         , "-DTICKY_TICKY"
513         , "-optc-DTICKY_TICKY"
514         , "-fvia-C" ]),
515
516     (WayUnreg, Way  "u" "Unregisterised" 
517         unregFlags ),
518
519     -- optl's below to tell linker where to find the PVM library -- HWL
520     (WayPar, Way  "mp" "Parallel" 
521         [ "-fparallel"
522         , "-D__PARALLEL_HASKELL__"
523         , "-optc-DPAR"
524         , "-package concurrent"
525         , "-optc-w"
526         , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
527         , "-optl-lpvm3"
528         , "-optl-lgpvm3"
529         , "-fvia-C" ]),
530
531     -- at the moment we only change the RTS and could share compiler and libs!
532     (WayPar, Way  "mt" "Parallel ticky profiling" 
533         [ "-fparallel"
534         , "-D__PARALLEL_HASKELL__"
535         , "-optc-DPAR"
536         , "-optc-DPAR_TICKY"
537         , "-package concurrent"
538         , "-optc-w"
539         , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
540         , "-optl-lpvm3"
541         , "-optl-lgpvm3"
542         , "-fvia-C" ]),
543
544     (WayPar, Way  "md" "Distributed" 
545         [ "-fparallel"
546         , "-D__PARALLEL_HASKELL__"
547         , "-D__DISTRIBUTED_HASKELL__"
548         , "-optc-DPAR"
549         , "-optc-DDIST"
550         , "-package concurrent"
551         , "-optc-w"
552         , "-optl-L${PVM_ROOT}/lib/${PVM_ARCH}"
553         , "-optl-lpvm3"
554         , "-optl-lgpvm3"
555         , "-fvia-C" ]),
556
557     (WayGran, Way  "mg" "GranSim" 
558         [ "-fgransim"
559         , "-D__GRANSIM__"
560         , "-optc-DGRAN"
561         , "-package concurrent"
562         , "-fvia-C" ]),
563
564     (WaySMP, Way  "s" "SMP"
565         [ "-fsmp"
566         , "-optc-pthread"
567         , "-optl-pthread"
568         , "-optc-DSMP"
569         , "-fvia-C" ]),
570
571     (WayUser_a,  Way  "a"  "User way 'a'"  ["$WAY_a_REAL_OPTS"]),       
572     (WayUser_b,  Way  "b"  "User way 'b'"  ["$WAY_b_REAL_OPTS"]),       
573     (WayUser_c,  Way  "c"  "User way 'c'"  ["$WAY_c_REAL_OPTS"]),       
574     (WayUser_d,  Way  "d"  "User way 'd'"  ["$WAY_d_REAL_OPTS"]),       
575     (WayUser_e,  Way  "e"  "User way 'e'"  ["$WAY_e_REAL_OPTS"]),       
576     (WayUser_f,  Way  "f"  "User way 'f'"  ["$WAY_f_REAL_OPTS"]),       
577     (WayUser_g,  Way  "g"  "User way 'g'"  ["$WAY_g_REAL_OPTS"]),       
578     (WayUser_h,  Way  "h"  "User way 'h'"  ["$WAY_h_REAL_OPTS"]),       
579     (WayUser_i,  Way  "i"  "User way 'i'"  ["$WAY_i_REAL_OPTS"]),       
580     (WayUser_j,  Way  "j"  "User way 'j'"  ["$WAY_j_REAL_OPTS"]),       
581     (WayUser_k,  Way  "k"  "User way 'k'"  ["$WAY_k_REAL_OPTS"]),       
582     (WayUser_l,  Way  "l"  "User way 'l'"  ["$WAY_l_REAL_OPTS"]),       
583     (WayUser_m,  Way  "m"  "User way 'm'"  ["$WAY_m_REAL_OPTS"]),       
584     (WayUser_n,  Way  "n"  "User way 'n'"  ["$WAY_n_REAL_OPTS"]),       
585     (WayUser_o,  Way  "o"  "User way 'o'"  ["$WAY_o_REAL_OPTS"]),       
586     (WayUser_A,  Way  "A"  "User way 'A'"  ["$WAY_A_REAL_OPTS"]),       
587     (WayUser_B,  Way  "B"  "User way 'B'"  ["$WAY_B_REAL_OPTS"]) 
588   ]
589
590 unregFlags = 
591    [ "-optc-DNO_REGS"
592    , "-optc-DUSE_MINIINTERPRETER"
593    , "-fno-asm-mangling"
594    , "-funregisterised"
595    , "-fvia-C" ]
596
597 -----------------------------------------------------------------------------
598 -- Programs for particular phases
599
600 GLOBAL_VAR(v_Pgm_L,   error "pgm_L", String)
601 GLOBAL_VAR(v_Pgm_P,   cRAWCPP,       String)
602 GLOBAL_VAR(v_Pgm_c,   cGCC,          String)
603 GLOBAL_VAR(v_Pgm_m,   error "pgm_m", String)
604 GLOBAL_VAR(v_Pgm_s,   error "pgm_s", String)
605 GLOBAL_VAR(v_Pgm_a,   cGCC,          String)
606 GLOBAL_VAR(v_Pgm_l,   cGCC,          String)
607 GLOBAL_VAR(v_Pgm_dll, cMkDLL,        String)
608
609 #if defined(mingw32_TARGET_OS) && defined(MINIMAL_UNIX_DEPS)
610 GLOBAL_VAR(v_Pgm_T,   cTOUCH,        String)
611 #endif
612
613 GLOBAL_VAR(v_Opt_dep,    [], [String])
614 GLOBAL_VAR(v_Anti_opt_C, [], [String])
615 GLOBAL_VAR(v_Opt_C,      [], [String])
616 GLOBAL_VAR(v_Opt_l,      [], [String])
617 GLOBAL_VAR(v_Opt_dll,    [], [String])
618
619 getStaticOpts :: IORef [String] -> IO [String]
620 getStaticOpts ref = readIORef ref >>= return . reverse