1 \section[invoking-GHC]{Invoking GHC: Command-line options}
2 \index{command-line options}
3 \index{options, GHC command-line}
5 Command-line arguments are either options or file names.
7 Command-line options begin with \tr{-}. They may {\em not} be
8 grouped: \tr{-vO} is different from \tr{-v -O}. Options need not
9 precede filenames: e.g., \tr{ghc *.o -o foo}. All options are
10 processed and then applied to all files; you cannot, for example, invoke
11 \tr{ghc -c -O1 Foo.hs -O2 Bar.hs} to apply different optimisation
12 levels to the files \tr{Foo.hs} and \tr{Bar.hs}. For conflicting
13 options, e.g., \tr{-c -S}, we reserve the right to do anything we
14 want. (Usually, the last one applies.)
16 Options related to profiling, Glasgow extensions to Haskell (e.g.,
17 unboxed values), Concurrent and Parallel Haskell are described in
18 \sectionref{profiling}, \sectionref{glasgow-exts}, and
19 \sectionref{concurrent-and-parallel}, respectively.
21 %************************************************************************
23 \subsection[file-suffixes]{Meaningful file suffixes}
24 \index{suffixes, file}
25 \index{file suffixes for GHC}
27 %************************************************************************
29 File names with ``meaningful'' suffixes (e.g., \tr{.lhs} or \tr{.o})
30 cause the ``right thing'' to happen to those files.
34 \index{lhs suffix@.lhs suffix}
35 A ``literate Haskell'' module.
38 A not-so-literate Haskell module.
41 A Haskell interface file, probably compiler-generated.
44 Intermediate C file produced by the Haskell compiler.
47 A C~file not produced by the Haskell compiler.
50 % C code after it has be preprocessed by the C compiler (using the
54 An assembly-language source file, usually
55 produced by the compiler.
58 An object file, produced by an assembler.
61 Files with other suffixes (or without suffixes) are passed straight
64 %************************************************************************
66 \subsection[options-help]{Help and verbosity options}
67 \index{help options (GHC)}
68 \index{verbose option (GHC)}
70 %************************************************************************
72 A good option to start with is the \tr{-help} (or \tr{-?}) option.
75 GHC spews a long message to standard output and then exits.
77 The \tr{-v}\index{-v option} option makes GHC {\em verbose}: it
78 reports its version number and shows (on stderr) exactly how it invokes each
79 phase of the compilation system. Moreover, it passes
80 the \tr{-v} flag to most phases; each reports
81 its version number (and possibly some other information).
83 Please, oh please, use the \tr{-v} option when reporting bugs!
84 Knowing that you ran the right bits in the right order is always the
85 first thing we want to verify.
87 If you're just interested in the compiler version number, the
88 \tr{--version}\index{--version option} option prints out a
89 one-line string containing the requested info.
91 %************************************************************************
93 \subsection[options-order]{Running the right phases in the right order}
94 \index{order of passes in GHC}
95 \index{pass ordering in GHC}
97 %************************************************************************
99 The basic task of the \tr{ghc} driver is to run each input file
100 through the right phases (parsing, linking, etc.).
102 The first phase to run is determined by the input-file suffix, and the
103 last phase is determined by a flag. If no relevant flag is present,
104 then go all the way through linking. This table summarises:
106 \begin{tabular}{llll}
107 phase of the & suffix saying & flag saying & (suffix of) \\
108 compilation system & ``start here''& ``stop after''& output file \\ \hline
110 literate pre-processor & .lhs & - & - \\
111 C pre-processor (opt.) & - & - & - \\
112 Haskell compiler & .hs & -C, -S & .hc, .s \\
113 C compiler (opt.) & .hc or .c & -S & .s \\
114 assembler & .s & -c & .o \\
115 linker & other & - & a.out \\
121 Thus, a common invocation would be: \tr{ghc -c Foo.hs}
123 Note: What the Haskell compiler proper produces depends on whether a
124 native-code generator is used (producing assembly language) or not
127 %The suffix information may be overridden with a \tr{-lang <suf>}
128 %\index{-lang <suf> option} option. This says: process all inputs
129 %files as if they had suffix \pl{<suf>}. [NOT IMPLEMENTED YET]
131 The option \tr{-cpp}\index{-cpp option} must be given for the C
132 pre-processor phase to be run, that is, the pre-processor will be run
133 over your Haskell source file before continuing.
135 The option \tr{-E}\index{-E option} runs just the pre-processing
136 passes of the compiler, outputting the result on stdout before
137 stopping. If used in conjunction with -cpp, the output is the
138 code blocks of the original (literal) source after having put it
139 through the grinder that is the C pre-processor. Sans \tr{-cpp}, the
140 output is the de-litted version of the original source.
142 The option \tr{-optcpp-E}\index{-optcpp-E option} runs just the
143 pre-processing stage of the C-compiling phase, sending the result to
144 stdout. (For debugging or obfuscation contests, usually.)
146 %************************************************************************
148 \subsection[options-optimise]{Optimisation (code improvement)}
149 \index{optimisation (GHC)}
150 \index{improvement, code (GHC)}
152 %************************************************************************
154 The \tr{-O*} options specify convenient ``packages'' of optimisation
155 flags; the \tr{-f*} options described later on specify {\em individual}
156 optimisations to be turned on/off; the \tr{-m*} options specify {\em
157 machine-specific} optimisations to be turned on/off.
159 %----------------------------------------------------------------------
160 \subsubsection[optimise-pkgs]{\tr{-O*}: convenient ``packages'' of optimisation flags.}
161 \index{-O options (GHC)}
163 There are {\em many} options that affect the quality of code produced by
164 GHC. Most people only have a general goal, something like ``Compile
165 quickly'' or ``Make my program run like greased lightning.'' The
166 following ``packages'' of optimisations (or lack thereof) should suffice.
168 Once you choose a \tr{-O*} ``package,'' stick with it---don't chop and
169 change. Modules' interfaces {\em will} change with a shift to a new
170 \tr{-O*} option, and you may have to recompile a large chunk of all
171 importing modules before your program can again be run
172 safely\sectionref{recomp}.
175 \item[No \tr{-O*}-type option specified:]
176 \index{-O* not specified}
177 This is taken to mean: ``Please compile quickly; I'm not over-bothered
178 about compiled-code quality.'' So, for example: \tr{ghc -c Foo.hs}
180 \item[\tr{-O} or \tr{-O1}:]
183 \index{optimise normally}
184 Means: ``Generate good-quality code without taking too long about it.''
185 Thus, for example: \tr{ghc -c -O Main.lhs}
189 \index{optimise aggressively}
190 Means: ``Apply every non-dangerous optimisation, even if it means
191 significantly longer compile times.''
193 The avoided ``dangerous'' optimisations are those that can make
194 runtime or space {\em worse} if you're unlucky. They are
195 normally turned on or off individually.
197 At the moment, \tr{-O2} is {\em unlikely} to produce
198 better code than \tr{-O}.
202 % \index{optimise minimally}
203 % [``Oh zero''] Means: ``Turn {\em off} as many optimisations (e.g.,
204 % simplifications) as possible.'' This is the only optimisation level
205 % at which the GCC-register-trickery is turned off. {\em You can't use
206 % it unless you have a suitably-built Prelude to match.} Intended for
207 % hard-core debugging.
210 \index{-fvia-C option}
211 Compile via C, and don't use the native-code generator.
212 (There are many cases when GHC does this on its own.) You might
213 pick up a little bit of speed by compiling via C. If you use
214 \tr{_ccall_}s or \tr{_casm_}s, you probably {\em have to} use
217 \item[\tr{-O2-for-C}:]
218 \index{-O2-for-C option}
219 Says to run GCC with \tr{-O2}, which may be worth a few percent in
220 execution speed. Don't forget \tr{-fvia-C}, lest you use the
221 native-code generator and bypass GCC altogether!
225 \index{optimising, reset}
226 This option will make GHC ``forget'' any -Oish options it has seen
227 so far. Sometimes useful; for example: \tr{make all EXTRA_HC_OPTS=-Onot}.
229 \item[\tr{-Ofile <file>}:]
230 \index{-Ofile <file> option}
231 \index{optimising, customised}
232 For those who need {\em absolute} control over {\em exactly} what
233 options are used (e.g., compiler writers, sometimes :-), a list of
234 options can be put in a file and then slurped in with \tr{-Ofile}.
236 In that file, comments are of the \tr{#}-to-end-of-line variety; blank
237 lines and most whitespace is ignored.
239 Please ask if you are baffled and would like an example of \tr{-Ofile}!
242 At Glasgow, we don't use a \tr{-O*} flag for day-to-day work. We use
243 \tr{-O} to get respectable speed; e.g., when we want to measure
244 something. When we want to go for broke, we tend to use
245 \tr{-O -fvia-C -O2-for-C} (and we go for lots of coffee breaks).
247 %Here is a table to summarise whether pragmatic interface information
248 %is used or not, whether the native-code generator is used (if
249 %available), and whether we use GCC register tricks (for speed!) on the
252 %\begin{tabular}{lccl}
253 %\tr{-O*} & Interface & Native code & `Registerised' C \\
254 % & pragmas? & (if avail.) & (if avail.) \\ \hline
256 %\pl{<none>} & no & yes & yes, only if \tr{-fvia-C} \\
257 %\tr{-O,-O1} & yes & yes & yes, only if \tr{-fvia-C} \\
258 %\tr{-O2} & yes & no & yes \\
259 %\tr{-Ofile} & yes & yes & yes, only if \tr{-fvia-C} \\
262 The easiest way to see what \tr{-O} (etc) ``really mean'' is to run
263 with \tr{-v}, then stand back in amazement.
264 Alternatively, just look at the
265 \tr{@HsC_minus<blah>} lists in the \tr{ghc} driver script.
267 %----------------------------------------------------------------------
268 \subsubsection{\tr{-f*}: platform-independent flags}
269 \index{-f* options (GHC)}
270 \index{-fno-* options (GHC)}
272 Flags can be turned {\em off} individually. (NB: I hope
273 you have a good reason for doing this....) To turn off the \tr{-ffoo}
274 flag, just use the \tr{-fno-foo} flag.\index{-fno-<opt> anti-option}
275 So, for example, you can say
276 \tr{-O2 -fno-strictness}, which will then drop out any running of the
279 The options you are most likely to want to turn off are:
280 \tr{-fno-strictness}\index{-fno-strictness option} (strictness
281 analyser [because it is sometimes slow]),
282 \tr{-fno-specialise}\index{-fno-specialise option} (automatic
283 specialisation of overloaded functions [because it makes your code
284 bigger]) [US spelling also accepted],
286 \tr{-fno-foldr-build}\index{-fno-foldr-build option}.
288 Should you wish to turn individual flags {\em on}, you are advised to
289 use the \tr{-Ofile} option, described above. Because the order in
290 which optimisation passes are run is sometimes crucial, it's quite
291 hard to do with command-line options.
293 Here are some ``dangerous'' optimisations you {\em might} want to try:
295 %------------------------------------------------------------------
296 \item[\tr{-funfolding-creation-threshold<n>}:]
297 (Default: 30) By raising or lowering this number, you can raise or
298 lower the amount of pragmatic junk that gets spewed into interface
299 files. (An unfolding has a ``size'' that reflects the cost in terms
300 of ``code bloat'' of expanding that unfolding in another module. A
301 bigger Core expression would be assigned a bigger cost.)
303 \item[\tr{-funfolding-use-threshold<n>}:]
304 (Default: 3) By raising or lowering this number, you can make the
305 compiler more or less keen to expand unfoldings.
307 OK, folks, these magic numbers `30' and `3' are mildly arbitrary; they
308 are of the ``seem to be OK'' variety. The `3' is the more critical
309 one; it's what determines how eager GHC is about expanding unfoldings.
311 \item[\tr{-funfolding-override-threshold<n>}:]
312 (Default: 8) [Pretty obscure]
313 When deciding what unfoldings from a module should be made available
314 to the rest of the world (via this module's interface), the compiler
315 normally likes ``small'' expressions.
317 For example, if it sees \tr{foo = bar}, it will decide that the very
318 small expression \tr{bar} is a great unfolding for \tr{foo}. But if
319 \tr{bar} turns out to be \tr{(True,False,True)}, we would probably
320 prefer {\em that} for the unfolding for \tr{foo}.
322 Should we ``override'' the initial small unfolding from \tr{foo=bar}
323 with the bigger-but-better one? Yes, if the bigger one's ``size'' is
324 still under the ``override threshold.'' You can use this flag to
325 adjust this threshold (why, I'm not sure).
327 % \item[\tr{-fliberated-case-threshold<n>}:]
328 % (Default: 12) [Vastly obscure: NOT IMPLEMENTED YET]
329 % ``Case liberation'' lifts evaluation out of recursive functions; it
330 % does this by duplicating code. Done without constraint, you can get
331 % serious code bloat; so we only do it if the ``size'' of the duplicated
332 % code is smaller than some ``threshold.'' This flag can fiddle that
335 \item[\tr{-fsemi-tagging}:]
336 This option (which {\em does not work} with the native-code generator)
337 tells the compiler to add extra code to test for already-evaluated
338 values. You win if you have lots of such values during a run of your
339 program, you lose otherwise. (And you pay in extra code space.)
341 We have not played with \tr{-fsemi-tagging} enough to recommend it.
342 (For all we know, it doesn't even work anymore... Sigh.)
345 %----------------------------------------------------------------------
346 % \subsubsection[optimise-simplifier]{Controlling ``simplification'' in the Haskell compiler.}
348 %Almost everyone turns program transformation
349 % (a.k.a. ``simplification'') on/off via one of the ``packages'' above,
350 %but you can exert absolute control if you want to. Do a \tr{ghc -v -O ...},
351 %and you'll see there are plenty of knobs to turn!
353 %The Core-to-Core and STG-to-STG passes can be run multiple times, and
354 %in varying orders (though you may live to regret it). The on-or-off
355 %global flags, however, are simply, well, on or off.
357 %The best way to give an exact list of options is the \tr{-Ofile}
358 %option, described elsewhere.
360 % [Check out \tr{ghc/compiler/simplCore/SimplCore.lhs} and
361 %\tr{simplStg/SimplStg.lhs} if you {\em really} want to see every
362 %possible Core-to-Core and STG-to-STG pass, respectively. The
363 %on-or-off global flags that effect what happens {\em within} one of
364 %these passes are defined by the \tr{GlobalSwitch} datatype in
365 %\tr{compiler/main/CmdLineOpts.lhs}.]
367 %----------------------------------------------------------------------
368 \subsubsection{\tr{-m*}: platform-specific flags}
369 \index{-m* options (GHC)}
370 \index{platform-specific options}
371 \index{machine-specific options}
373 Some flags only make sense for particular target platforms.
377 (SPARC machines)\index{-mv8 option (SPARC only)}
378 Means to pass the like-named option to GCC; it says to use the
379 Version 8 SPARC instructions, notably integer multiply and divide.
380 The similiar \tr{-m*} GCC options for SPARC also work, actually.
382 \item[\tr{-mlong-calls}:]
383 (HPPA machines)\index{-mlong-calls option (HPPA only)}
384 Means to pass the like-named option to GCC. Required for Very Big
385 modules, maybe. (Probably means you're in trouble...)
387 \item[\tr{-monly-[32]-regs}:]
388 (iX86 machines)\index{-monly-N-regs option (iX86 only)}
389 GHC tries to ``steal'' four registers from GCC, for performance
390 reasons; it almost always works. However, when GCC is compiling some
391 modules with four stolen registers, it will crash, probably saying:
393 Foo.hc:533: fixed or forbidden register was spilled.
394 This may be due to a compiler bug or to impossible asm
395 statements or clauses.
397 Just give some registers back with \tr{-monly-N-regs}. Try `3' first,
398 then `2'. If `2' doesn't work, please report the bug to us.
401 %----------------------------------------------------------------------
402 \subsubsection[optimise-C-compiler]{Code improvement by the C compiler.}
403 \index{optimisation by GCC}
404 \index{GCC optimisation}
406 The C~compiler (GCC) is run with \tr{-O} turned on. (It has
409 If you want to run GCC with \tr{-O2}---which may be worth a few
410 percent in execution speed---you can give a
411 \tr{-O2-for-C}\index{-O2-for-C option} option.
413 %If you are brave or foolish, you might want to omit some checking code
414 % (e.g., for stack-overflow checks), as sketched in
415 %\sectionref{omit-checking}.
417 %************************************************************************
419 \subsection[options-sanity]{Warnings and sanity-checking}
420 \index{sanity-checking options}
422 %************************************************************************
424 If you would like GHC to check that every top-level value has a type
425 signature, use the \tr{-fsignatures-required}
426 option.\index{-fsignatures-required option}
428 If you would like to disallow ``name shadowing,'' i.e., an inner-scope
429 value has the same name as an outer-scope value, then use the
430 \tr{-fwarn-name-shadowing}
431 option.\index{-fwarn-name-shadowing option}
432 This option catches typographical errors that turn into hard-to-find
433 bugs, e.g., in the inadvertent cyclic definition \tr{let x = ... x ... in}.
435 Consequently, this option does {\em not} allow cyclic recursive
438 By default, the compiler will warn you if a set of patterns are either
439 incomplete (i.e., you're only matching on a subset of an algebraic
440 data type's constructors), or overlapping, i.e.,
451 where the last pattern match in \tr{f} won't ever be reached, as the
452 second pattern overlaps it. More often than not, redundant patterns
453 is a programmer mistake/error, but if you don't want the compiler to
454 ``baby-sit'', use the \tr{-fno-warn-overlapping-patterns} option to
455 turn these warnings off.\index{-fno-warn-overlapping-patterns option}
457 Similarly for incomplete patterns, the function \tr{g} will fail when
458 applied to non-empty lists, so the compiler will by default emit a
459 warning about this. The option \tr{-fno-warn-incomplete-patterns}
460 turns rhis off.\index{-fno-warn-incomplete-pattern option}
463 If you're feeling really paranoid, the \tr{-dcore-lint}
464 option\index{-dcore-lint option} is a good choice. It turns on
465 heavyweight intra-pass sanity-checking within GHC. (It checks GHC's
468 %************************************************************************
470 \subsection[options-output]{Re-directing the compilation output(s)}
471 \index{output-directing options}
473 %************************************************************************
475 When compiling a Haskell module, GHC may produce several files of
476 output (usually two).
478 One file is usually an {\em interface file}. If compiling
479 \tr{bar/Foo.hs}, the interface file would normally be \tr{bar/Foo.hi}.
480 The interface output may be directed to another file
481 \tr{bar2/Wurble.iface} with the option
482 \tr{-ohi bar2/Wurble.iface}\index{-ohi <file> option} (not recommended).
484 To avoid generating an interface file at all, use a \tr{-nohi}
485 option.\index{-nohi option}
487 The compiler does not overwrite an existing \tr{.hi} interface file if
488 the new one is byte-for-byte the same as the old one; this is friendly to
489 \tr{make}. When an interface does change, it is often enlightening to
490 be informed. The \tr{-hi-diffs}\index{-hi-diffs option} option will
491 make \tr{ghc} run \tr{diff} on the old and new \tr{.hi} files.
493 The \tr{.hi} files from GHC 2.xx contain ``usage'' information which
494 changes often and uninterestingly. If you really want to see these
495 changes reported, you need to use the
496 \tr{-hi-diffs-with-usages}\index{-hi-diffs-with-usages option} option.
498 GHC's non-interface output normally goes into a \tr{.hc}, \tr{.o},
499 etc., file, depending on the last-run compilation phase. The option
500 \tr{-o foo}\index{-o option} re-directs the output of that last-run
501 phase to file \tr{foo}.
503 Note: this ``feature'' can be counterintuitive:
504 \tr{ghc -C -o foo.o foo.hs} will put the intermediate C code in the
505 file \tr{foo.o}, name notwithstanding!
507 EXOTICA: But the \tr{-o} option isn't of much use if you have {\em
508 several} input files... Non-interface output files are normally put
509 in the same directory as their corresponding input file came from.
510 You may specify that they be put in another directory using the
511 \tr{-odir <dir>}\index{-odir <dir> option} (the ``Oh, dear'' option).
515 % ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch`
518 The output files, \tr{Foo.o}, \tr{Bar.o}, and \tr{Bumble.o} would be
519 put into a subdirectory named after the architecture of the executing
520 machine (\tr{sun4}, \tr{mips}, etc). The directory must already
521 exist; it won't be created.
523 Note that the \tr{-odir} option does {\em not} affect where the
524 interface files are put. In the above example, they would still be
525 put in \tr{parse/Foo.hi}, \tr{parse/Bar.hi}, and
526 \tr{gurgle/Bumble.hi}.
528 MORE EXOTICA: The \tr{-osuf <suffix>}\index{-osuf <suffix> option}
529 will change the \tr{.o} file suffix for object files to whatever
530 you specify. (We use this in compiling the prelude.)
532 Similarly, the \tr{-hisuf <suffix>}\index{-hisuf <suffix> option} will
533 change the \tr{.hi} file suffix for non-system interface files. This
534 can be useful when you are trying to compile a program several ways,
535 all in the same directory. The suffix given is used for {\em all}
536 interfaces files written, {\em and} for all non-system interface files
539 The \tr{-hisuf}/\tr{-osuf} game is useful if you want to compile a
540 program with both GHC and HBC (say) in the same directory. Let HBC
541 use the standard \tr{.hi}/\tr{.o} suffixes; add
542 \tr{-hisuf g_hi -osuf g_o} to your \tr{make} rule for GHC compiling...
544 NB: {\em A change from 0.26 and before:} Before, you might have said
545 \tr{-hisuf _g.hi -osuf _g.o}; now, the \tr{.} is assumed and you
546 specify what comes {\em after} it. (This is a more portable solution
549 % THIS SHOULD HAPPEN AUTOMAGICALLY:
550 % If you want to change the suffix looked for on system-supplied
551 % interface files (notably the \tr{Prelude.hi} file), use the
552 % \tr{-hisuf-prelude <suffix>}\index{-hisuf-prelude <suffix> option}
553 % option. (This may be useful if you've built GHC in various funny
554 % ways, and you are running tests in even more funny ways. It happens.)
556 FURTHER EXOTICA: If you are doing a normal \tr{.hs}-to-\tr{.o} compilation
557 but would like to hang onto the intermediate \tr{.hc} C file, just
558 throw in a \tr{-keep-hc-file-too} option\index{-keep-hc-file-too option}.
559 If you would like to look at the assembler output, toss in a
560 \tr{-keep-s-file-too},\index{-keep-hc-file-too option} too.
562 SAVING GHC STDERR OUTPUT: Sometimes, you may cause GHC to be rather
563 chatty on standard error; with \tr{-fshow-import-specs}, for example.
564 You can instruct GHC to {\em append} this output to a particular log
565 file with a \tr{-odump <blah>}\index{-odump <blah> option} option.
567 TEMPORARY FILES: If you have trouble because of running out of space
568 in \tr{/tmp/} (or wherever your installation thinks temporary files
569 should go), you may use the \tr{-tmpdir <dir>}\index{-tmpdir <dir> option}
570 option to specify an alternate directory. For example, \tr{-tmpdir .}
571 says to put temporary files in the current working directory.
573 BETTER IDEA FOR TEMPORARY FILES: Use your \tr{TMPDIR} environment
574 variable.\index{TMPDIR environment variable} Set it to the name of
575 the directory where temporary files should be put. GCC and other
576 programs will honour the \tr{TMPDIR} variable as well.
578 EVEN BETTER IDEA: Set the \tr{TMPDIR} variable when building
579 GHC, and never worry about \tr{TMPDIR} again. (see the build
582 %************************************************************************
584 \subsection[options-finding-imports-etc]{For finding interface files, etc.}
585 \index{interface files, finding them}
586 \index{finding interface files}
588 %************************************************************************
590 In your program, you import a module \tr{Foo} by saying
591 \tr{import Foo}. GHC goes looking for an interface file, \tr{Foo.hi}.
592 It has a builtin list of directories (notably including \tr{.}) where
595 The \tr{-i<dirs>} option\index{-i<dirs> option} prepends a
596 colon-separated list of \tr{dirs} to the ``import directories'' list.
598 A plain \tr{-i} resets the ``import directories'' list back to nothing.
600 GHC normally imports \tr{Prelude.hi} files for you. If you'd rather
601 it didn't, then give it a \tr{-fno-implicit-prelude}
602 option\index{-fno-implicit-prelude option}. You are unlikely to get
603 very far without a Prelude, but, hey, it's a free country.
605 If you are using a system-supplied non-Prelude library (e.g., the HBC
606 library), just use a \tr{-syslib hbc}\index{-syslib <lib> option}
607 option (for example). The right interface files should then be
610 Once a Haskell module has been compiled to C (\tr{.hc} file), you may
611 wish to specify where GHC tells the C compiler to look for \tr{.h}
612 files. (Or, if you are using the \tr{-cpp} option\index{-cpp option},
613 where it tells the C pre-processor to look...) For this purpose, use
614 a \tr{-I<dir>}\index{-I<dir> option} in the usual C-ish way.
616 Pragmas: Interface files are normally jammed full of
617 compiler-produced {\em pragmas}, which record arities, strictness
618 info, etc. If you think these pragmas are messing you up (or you are
619 doing some kind of weird experiment), you can tell GHC to ignore them
620 with the \tr{-fignore-interface-pragmas}\index{-fignore-interface-pragmas option}
623 When compiling without optimisations on, the compiler is extra-careful
624 about not slurping in data constructors and instance declarations that
625 it will not need. If you believe it is getting it wrong and not
626 importing stuff which you think it should, this optimisation can be
627 turned off with \tr{-fno-prune-tydecls} and \tr{-fno-prune-instdecls}.
628 \index{-fno-prune-tydecls option}\index{-fno-prune-instdecls}
630 See also \sectionref{options-linker}, which describes how the linker
631 finds standard Haskell libraries.
633 %************************************************************************
635 %\subsection[options-names]{Fiddling with namespaces}
637 %************************************************************************
639 %-split-objs and -fglobalise-toplev-names. You don't need them and you
640 %don't want to know; used for the prelude (ToDo).
642 %************************************************************************
644 \subsection[options-CPP]{Related to the C pre-processor}
645 \index{C pre-processor options}
646 \index{pre-processor (cpp) options}
648 %************************************************************************
650 The C pre-processor \tr{cpp} is run over your Haskell code only if the
651 \tr{-cpp} option \index{-cpp option} is given. Unless you are
652 building a large system with significant doses of conditional
653 compilation, you really shouldn't need it.
656 \index{-D<name> option}
657 Define macro \tr{<foo>} in the usual way. NB: does {\em not} affect
658 \tr{-D} macros passed to the C~compiler when compiling via C! For
659 those, use the \tr{-optc-Dfoo} hack...
662 \index{-U<name> option}
663 Undefine macro \tr{<foo>} in the usual way.
666 \index{-I<dir> option}
667 Specify a directory in which to look for \tr{#include} files, in
671 The \tr{ghc} driver pre-defines several macros:
673 \item[\tr{__HASKELL1__}:]
674 \index{__HASKELL1__ macro}
675 If defined to $n$, that means GHC supports the
676 Haskell language defined in the Haskell report version $1.n$.
679 NB: This macro is set both when pre-processing Haskell source and
680 when pre-processing generated C (\tr{.hc}) files.
682 % If you give the \tr{-fhaskell-1.3} flag\index{-fhaskell-1.3 option},
683 % then \tr{__HASKELL1__} is set to 3. Obviously.
685 \item[\tr{__GLASGOW_HASKELL__}:]
686 \index{__GLASGOW_HASKELL__ macro}
687 For version $n$ of the GHC system, this will be \tr{#define}d to
688 $100 \times n$. So, for version~2.02, it is 202.
690 This macro is {\em only} set when pre-processing Haskell source.
691 ({\em Not} when pre-processing generated C.)
693 With any luck, \tr{__GLASGOW_HASKELL__} will be undefined in all other
694 implementations that support C-style pre-processing.
696 (For reference: the comparable symbols for other systems are:
697 \tr{__HUGS__} for Hugs and \tr{__HBC__} for Chalmers.)
699 \item[\tr{__CONCURRENT_HASKELL__}:]
700 \index{__CONCURRENT_HASKELL__ macro}
701 Only defined when \tr{-concurrent} is in use!
702 This symbol is defined when pre-processing Haskell (input) and
703 pre-processing C (GHC output).
705 \item[\tr{__PARALLEL_HASKELL__}:]
706 \index{__PARALLEL_HASKELL__ macro}
707 Only defined when \tr{-parallel} is in use! This symbol is defined when
708 pre-processing Haskell (input) and pre-processing C (GHC output).
711 Options other than the above can be forced through to the C
712 pre-processor with the \tr{-opt} flags (see
713 \sectionref{forcing-options-through}).
715 A small word of warning: \tr{-cpp} is not friendly to
716 ``string gaps''.\index{-cpp vs string gaps}\index{string gaps vs -cpp}
719 %************************************************************************
721 \subsection[options-C-compiler]{Options affecting the C compiler (if applicable)}
722 \index{include-file-option}
723 \index{C compiler options}
726 %************************************************************************
728 At the moment, quite a few common C-compiler options are passed on
729 quietly to the C compilation of Haskell-compiler-generated C files.
730 THIS MAY CHANGE. Meanwhile, options so sent are:
733 \tr{-Wall} & get all warnings from GCC \\
734 \tr{-ansi} & do ANSI C (not K\&R) \\
735 \tr{-pedantic} & be so\\
736 \tr{-dgcc-lint} & (hack) short for ``make GCC very paranoid''\\
738 \index{-Wall option (for GCC)}
739 \index{-ansi option (for GCC)}
740 \index{-pedantic option (for GCC)}
741 \index{-dgcc-lint option (GCC paranoia)}
743 If you are compiling with lots of \tr{ccalls}, etc., you may need to
744 tell the C~compiler about some \tr{#include} files. There is no real
745 pretty way to do this, but you can use this hack from the
748 % ghc -c '-#include <X/Xlib.h>' Xstuff.lhs
752 %************************************************************************
754 %\subsection[options-native-code]{Options affecting the native-code generator(s)}
756 %************************************************************************
758 %The only option is to select the target architecture. Right now,
759 %you have only at most one choice: \tr{-fasm-sparc}.\index{-fasm-<target> option}
761 %EXPECT this native-code stuff to change in the future.
763 %************************************************************************
765 \subsection[options-linker]{Linking and consistency-checking}
766 \index{linker options}
769 %************************************************************************
771 GHC has to link your code with various libraries, possibly including:
772 user-supplied, GHC-supplied, and system-supplied (\tr{-lm} math
773 library, for example).
777 \index{-l<lib> option}
778 Link in a library named \tr{lib<FOO>.a} which resides somewhere on the
779 library directories path.
781 Because of the sad state of most UNIX linkers, the order of such
782 options does matter. Thus: \tr{ghc -lbar *.o} is almost certainly
783 wrong, because it will search \tr{libbar.a} {\em before} it has
784 collected unresolved symbols from the \tr{*.o} files.
785 \tr{ghc *.o -lbar} is probably better.
787 The linker will of course be informed about some GHC-supplied
788 libraries automatically; these are:
791 -l equivalent & description \\ \hline
793 -lHSrts,-lHSclib & basic runtime libraries \\
794 -lHS & standard Prelude library \\
795 -lHS\_cbits & C support code for standard Prelude library \\
796 -lgmp & GNU multi-precision library (for Integers)\\
799 \index{-lHS_cbits library}
800 \index{-lHSrts library}
801 \index{-lgmp library}
803 \item[\tr{-syslib <name>}:]
804 \index{-syslib <name> option}
806 If you are using a Haskell ``system library'' (e.g., the HBC
807 library), just use the \tr{-syslib hbc} option, and the correct code
810 %Please see \sectionref{syslibs} for information about
811 %``system libraries.''
814 \index{-L<dir> option}
815 Where to find user-supplied libraries... Prepend the directory
816 \tr{<dir>} to the library directories path.
819 \index{-static option}
820 Tell the linker to avoid shared libraries.
822 \item[\tr{-no-link-chk} and \tr{-link-chk}:]
823 \index{-no-link-chk option}
824 \index{-link-chk option}
825 \index{consistency checking of executables}
826 By default, immediately after linking an executable, GHC verifies that
827 the pieces that went into it were compiled with compatible flags; a
828 ``consistency check''.
829 (This is to avoid mysterious failures caused by non-meshing of
830 incompatibly-compiled programs; e.g., if one \tr{.o} file was compiled
831 for a parallel machine and the others weren't.) You may turn off this
832 check with \tr{-no-link-chk}. You can turn it (back) on with
833 \tr{-link-chk} (the default).
836 %************************************************************************
838 \subsection[options-compiler-RTS]{For the compiler's RTS: heap, stack sizes, etc.}
839 \index{heap-size options (for GHC)}
840 \index{stack-size options (for GHC)}
842 %************************************************************************
844 The compiler is itself a Haskell program, so it has a tweakable
845 runtime-system (RTS), just like any other Haskell program.
848 \item[\tr{-H<size>} or \tr{-Rmax-heapsize <size>}:]
849 \index{-H<size> option}
850 \index{-Rmax-heapsize <size> option}
851 Don't use more than \tr{<size>} {\em bytes} for heap space. If more
852 than one of these arguments is given, the largest will be taken.
854 A size of zero can be used to reset the heap size downwards. For
855 example, to run GHC with a heap of 250KB (the default is 6MB), do
858 \item[\tr{-K<size>} or \tr{-Rmax-stksize <size>}:]
859 \index{-K<size> option}
860 \index{-Rmax-stksize <size> option}
861 Set the stack space to \tr{<size>} bytes. If you have to set it very
862 high [a megabyte or two, say], the compiler is probably looping, which
863 is a BUG (please report).
865 A size of zero can be used to rest the stack size downwards, as above.
867 \item[\tr{-Rscale-sizes<factor>}:]
868 \index{-Rscale-sizes<factor> option}
869 Multiply the given (or default) heap and stack sizes by \tr{<factor>}.
870 For example, on a DEC Alpha (a 64-bit machine), you might want to
871 double those space sizes; just use \tr{-Rscale-sizes2}.
873 A non-integral factor is OK, too: \tr{-Rscale-sizes1.2}.
875 \item[\tr{-Rghc-timing}:]
876 \index{-Rghc-timing option}
877 Reports a one-line useful collection of time- and space- statistics
878 for a module's compilation.
880 \item[\tr{-Rgc-stats}:]
881 \index{-Rgc-stats option}
882 Report garbage-collection statistics. It will create a
883 \tr{<foo>.stat} file, in some obvious place (I hope).
885 Alternatively, if you'd rather the GC stats went straight to standard
886 error, you can ``cheat'' by using, instead: \tr{-optCrts-Sstderr}.
889 %\index{-Rhbc option}
890 %Tell the compiler it has an HBC-style RTS; i.e., it was compiled with
891 %HBC. Not used in Real Life.
894 %\index{-Rghc option}
895 %Tell the compiler it has a GHC-style RTS; i.e., it was compiled with
896 %GHC. Not used in Real Life.
899 For all \tr{<size>}s: If the last character of \tr{size} is a K,
900 multiply by 1000; if an M, by 1,000,000; if a G, by 1,000,000,000.
901 Sizes are always in {\em bytes}, not words. Good luck on the G's (I
902 think the counter is still only 32-bits [WDP])!
904 %************************************************************************
906 %\subsection[options-cross-compiling]{For cross-compiling to another architecture}
908 %************************************************************************
910 % (We do this for GRIP at Glasgow; it's hacked in---not proper
911 %cross-compiling support. But you could do the same, if required...)
913 %The \tr{-target <arch>} option\index{-target <arch> option} says to
914 %generate code for the \tr{<arch>} architecture.
916 %************************************************************************
918 \subsection[options-parallel]{For Concurrent and Parallel Haskell}
920 %************************************************************************
922 For the full story on using GHC for concurrent \& parallel Haskell
923 programming, please see \Sectionref{concurrent-and-parallel}.
925 %The \tr{-fparallel} option\index{-fparallel option} tells the compiler
926 %to generate code for parallel execution. The \tr{-mgrip}
927 %option\index{-mgrip option} says that the code should be explicitly
928 %suitable for the GRIP multiprocessor (the one in our Glasgow basement).
930 %************************************************************************
932 %\subsection[options-experimental]{For experimental purposes}
933 %\index{experimental options}
935 %************************************************************************
937 %From time to time, we provide GHC options for ``experimenting.'' Easy
938 %come, easy go. In version~0.26, the ``experimental'' options are:
940 %\item[\tr{-firrefutable-tuples} option:]
941 %\index{-firrefutable-tuples option (experimental)}
942 %Pretend that every tuple pattern is irrefutable; i.e., has a
943 %``twiddle'' (\tr{~}) in front of it.
945 %Some parts of the GHC system {\em depend} on strictness properties which
946 %\tr{-firrefutable-tuples} may undo, notably the low-level state-transformer
947 %stuff, which includes I/O (!). You're on your own...
949 %\item[\tr{-fall-strict} option:]
950 %\index{-fall-strict option (experimental)}
951 % (DOESN'T REALLY WORK, I THINK) Changes the strictness analyser so
952 %that, when it asks the question ``Is this function argument certain to
953 %be evaluated?'', the answer is always ``yes''.
955 %Compilation is changed in no other way.
958 % -firrefutable-everything
961 %************************************************************************
963 \subsection[options-debugging]{For debugging the compiler}
964 \index{debugging options (for GHC)}
966 %************************************************************************
968 HACKER TERRITORY. HACKER TERRITORY.
971 %----------------------------------------------------------------------
972 \subsubsection[replacing-phases]{Replacing the program for one or more phases.}
973 \index{GHC phases, changing}
974 \index{phases, changing GHC}
976 You may specify that a different program
977 be used for one of the phases of the compilation system, in place of
978 whatever the driver \tr{ghc} has wired into it. For example, you
979 might want to try a different assembler. The
980 \tr{-pgm<phase-code><program-name>}\index{-pgm<phase><stuff> option} option to
981 \tr{ghc} will cause it to use \pl{<program-name>} for phase
982 \pl{<phase-code>}, where the codes to indicate the phases are:
985 code & phase \\ \hline
986 L & literate pre-processor \\
987 P & C pre-processor (if -cpp only) \\
988 C & Haskell compiler \\
994 %----------------------------------------------------------------------
995 \subsubsection[forcing-options-through]{Forcing options to a particular phase.}
996 \index{forcing GHC-phase options}
998 The preceding sections describe driver options that are mostly
999 applicable to one particular phase. You may also {\em force} a
1000 specific option \tr{<option>} to be passed to a particular phase
1001 \tr{<phase-code>} by feeding the driver the option
1002 \tr{-opt<phase-code><option>}.\index{-opt<phase><stuff> option} The
1003 codes to indicate the phases are the same as in the previous section.
1005 So, for example, to force an \tr{-Ewurble} option to the assembler, you
1006 would tell the driver \tr{-opta-Ewurble} (the dash before the E is
1009 Besides getting options to the Haskell compiler with \tr{-optC<blah>},
1010 you can get options through to its runtime system with
1011 \tr{-optCrts<blah>}\index{-optCrts<blah> option}.
1013 So, for example: when I want to use my normal driver but with my
1014 profiled compiler binary, I use this script:
1017 exec /local/grasp_tmp3/simonpj/ghc-BUILDS/working-alpha/ghc/driver/ghc \
1018 -pgmC/local/grasp_tmp3/simonpj/ghc-BUILDS/working-hsc-prof/hsc \
1024 %----------------------------------------------------------------------
1025 \subsubsection[dumping-output]{Dumping out compiler intermediate structures}
1026 \index{dumping GHC intermediates}
1027 \index{intermediate passes, output}
1032 Don't bother generating C output {\em or} an interface file. Usually
1033 used in conjunction with one or more of the \tr{-ddump-*} options; for
1034 example: \tr{ghc -noC -ddump-simpl Foo.hs}
1038 {\em Do} generate an interface file. This would normally be used in
1039 conjunction with \tr{-noC}, which turns off interface generation;
1040 thus: \tr{-noC -hi}.
1042 \item[\tr{-dshow-passes}:]
1043 \index{-dshow-passes option}
1044 Prints a message to stderr as each pass starts. Gives a warm but
1045 undoubtedly misleading feeling that GHC is telling you what's
1048 \item[\tr{-ddump-<pass>}:]
1049 \index{-ddump-<pass> options}
1050 Make a debugging dump after pass \tr{<pass>} (may be common enough to
1051 need a short form...). Some of the most useful ones are:
1054 \tr{-ddump-rdr} & reader output (earliest stuff in the compiler) \\
1055 \tr{-ddump-rn} & renamer output \\
1056 \tr{-ddump-tc} & typechecker output \\
1057 \tr{-ddump-deriv} & derived instances \\
1058 \tr{-ddump-ds} & desugarer output \\
1059 \tr{-ddump-simpl} & simplifer output (Core-to-Core passes) \\
1060 \tr{-ddump-stranal} & strictness analyser output \\
1061 \tr{-ddump-occur-anal} & `occurrence analysis' output \\
1062 \tr{-ddump-spec} & dump specialisation info \\
1063 \tr{-ddump-stg} & output of STG-to-STG passes \\
1064 \tr{-ddump-absC} & {\em un}flattened Abstract~C \\
1065 \tr{-ddump-flatC} & {\em flattened} Abstract~C \\
1066 \tr{-ddump-realC} & same as what goes to the C compiler \\
1067 \tr{-ddump-asm} & assembly language from the native-code generator \\
1069 \index{-ddump-rdr option}%
1070 \index{-ddump-rn option}%
1071 \index{-ddump-tc option}%
1072 \index{-ddump-deriv option}%
1073 \index{-ddump-ds option}%
1074 \index{-ddump-simpl option}%
1075 \index{-ddump-stranal option}%
1076 \index{-ddump-occur-anal option}%
1077 \index{-ddump-spec option}%
1078 \index{-ddump-stg option}%
1079 \index{-ddump-absC option}%
1080 \index{-ddump-flatC option}%
1081 \index{-ddump-realC option}%
1082 \index{-ddump-asm option}
1084 %For any other \tr{-ddump-*} options: consult the source, notably
1085 %\tr{ghc/compiler/main/CmdLineOpts.lhs}.
1087 \item[\tr{-dverbose-simpl} and \tr{-dverbose-stg}:]
1088 \index{-dverbose-simpl option}
1089 \index{-dverbose-stg option}
1090 Show the output of the intermediate Core-to-Core and STG-to-STG
1091 passes, respectively. ({\em Lots} of output!) So: when we're
1094 % ghc -noC -O -ddump-simpl -dverbose-simpl -dcore-lint Foo.hs
1097 \item[\tr{-dppr-{user,debug,all}}:]
1098 \index{-dppr-user option}
1099 \index{-dppr-debug option}
1100 \index{-dppr-all option}
1101 Debugging output is in one of several ``styles.'' Take the printing
1102 of types, for example. In the ``user'' style, the compiler's internal
1103 ideas about types are presented in Haskell source-level syntax,
1104 insofar as possible. In the ``debug'' style (which is the default for
1105 debugging output), the types are printed in the most-often-desired
1106 form, with explicit foralls, etc. In the ``show all'' style, very
1107 verbose information about the types (e.g., the Uniques on the
1108 individual type variables) is displayed.
1110 \item[\tr{-ddump-raw-asm}:]
1111 \index{-ddump-raw-asm option}
1112 Dump out the assembly-language stuff, before the ``mangler'' gets it.
1114 \item[\tr{-ddump-rn-trace}:]
1115 \index{-ddump-rn-trace}
1116 Make the renamer be *real* chatty about what it is upto.
1118 \item[\tr{-dshow-rn-stats}:]
1119 \index{-dshow-rn-stats}
1120 Print out summary of what kind of information the renamer had to bring
1122 \item[\tr{-dshow-unused-imports}:]
1123 \index{-dshow-unused-imports}
1124 Have the renamer report what imports does not contribute.
1126 \item[\tr{-fwarn-unused-names}:]
1127 \index{-fwarn-unused-names}
1128 Have the renamer report which locally defined names are not used/exported.
1131 %\item[\tr{-dgc-debug}:]
1132 %\index{-dgc-debug option}
1133 %Enables some debugging code related to the garbage-collector.
1136 %ToDo: -ddump-asm-insn-counts
1137 %-ddump-asm-globals-info
1139 %----------------------------------------------------------------------
1140 \subsubsection{How to read Core syntax (from some \tr{-ddump-*} flags)}
1141 \index{reading Core syntax}
1142 \index{Core syntax, how to read}
1144 Let's do this by commenting an example. It's from doing
1145 \tr{-ddump-ds} on this code:
1147 skip2 m = m : skip2 (m+2)
1150 Before we jump in, a word about names of things. Within GHC,
1151 variables, type constructors, etc., are identified by their
1152 ``Uniques.'' These are of the form `letter' plus `number' (both
1153 loosely interpreted). The `letter' gives some idea of where the
1154 Unique came from; e.g., \tr{_} means ``built-in type variable'';
1155 \tr{t} means ``from the typechecker''; \tr{s} means ``from the
1156 simplifier''; and so on. The `number' is printed fairly compactly in
1157 a `base-62' format, which everyone hates except me (WDP).
1159 Remember, everything has a ``Unique'' and it is usually printed out
1160 when debugging, in some form or another. So here we go...
1164 Main.skip2{-r1L6-} :: _forall_ a$_4 =>{{Num a$_4}} -> a$_4 -> [a$_4]
1166 --# `r1L6' is the Unique for Main.skip2;
1167 --# `_4' is the Unique for the type-variable (template) `a'
1168 --# `{{Num a$_4}}' is a dictionary argument
1172 --# `_NI_' means "no (pragmatic) information" yet; it will later
1173 --# evolve into the GHC_PRAGMA info that goes into interface files.
1175 Main.skip2{-r1L6-} =
1176 /\ _4 -> \ d.Num.t4Gt ->
1179 +.t4Hg :: _4 -> _4 -> _4
1181 +.t4Hg = (+{-r3JH-} _4) d.Num.t4Gt
1183 fromInt.t4GS :: Int{-2i-} -> _4
1185 fromInt.t4GS = (fromInt{-r3JX-} _4) d.Num.t4Gt
1187 --# The `+' class method (Unique: r3JH) selects the addition code
1188 --# from a `Num' dictionary (now an explicit lamba'd argument).
1189 --# Because Core is 2nd-order lambda-calculus, type applications
1190 --# and lambdas (/\) are explicit. So `+' is first applied to a
1191 --# type (`_4'), then to a dictionary, yielding the actual addition
1192 --# function that we will use subsequently...
1194 --# We play the exact same game with the (non-standard) class method
1195 --# `fromInt'. Unsurprisingly, the type `Int' is wired into the
1202 ds.d4Qz :: Int{-2i-}
1205 } in fromInt.t4GS ds.d4Qz
1207 --# `I# 2#' is just the literal Int `2'; it reflects the fact that
1208 --# GHC defines `data Int = I# Int#', where Int# is the primitive
1209 --# unboxed type. (see relevant info about unboxed types elsewhere...)
1211 --# The `!' after `I#' indicates that this is a *saturated*
1212 --# application of the `I#' data constructor (i.e., not partially
1215 skip2.t3Ja :: _4 -> [_4]
1219 let { ds.d4QQ :: [_4]
1225 ds.d4QY = +.t4Hg m.r1H4 lit.t4Hb
1226 } in skip2.t3Ja ds.d4QY
1228 :! _4 m.r1H4 ds.d4QQ
1234 (``It's just a simple functional language'' is an unregisterised
1235 trademark of Peyton Jones Enterprises, plc.)
1237 %----------------------------------------------------------------------
1238 \subsubsection[source-file-options]{Command line options in source files}
1239 \index{source-file options}
1241 Sometimes it is useful to make the connection between a source file
1242 and the command-line options it requires, quite tight. For instance,
1243 if a (Glasgow) Haskell source file uses \tr{casm}s, the C back-end
1244 often needs to be told about which header files to include. Rather than
1245 maintaining the list of files the source depends on in a
1246 \tr{Makefile} (using the \tr{-#include} command-line option), it is
1247 possible to do this directly in the source file using the \tr{OPTIONS}
1248 pragma \index{OPTIONS pragma}:
1251 {-# OPTIONS -#include "foo.h" #-}
1257 \tr{OPTIONS} pragmas are only looked for at the top of your source
1258 files, upto the first (non-literate,non-empty) line not containing
1259 \tr{OPTIONS}. Multiple \tr{OPTIONS} pragmas are recognised. Note
1260 that your command shell does not get to the source file options, they
1261 are just included literally in the array of command-line arguments
1262 the compiler driver maintains internally, so you'll be desperately
1263 disappointed if you try to glob etc. inside \tr{OPTIONS}.
1265 It is not recommended to move all the contents of your Makefiles into
1266 your source files, but in some circumstances, the \tr{OPTIONS} pragma
1267 is the Right Thing. (If you use \tr{-keep-hc-file-too} and have OPTION
1268 flags in your module, the OPTIONS will get put into the generated .hc
1271 %----------------------------------------------------------------------
1272 \subsubsection{How to compile mutually recursive modules}
1273 \index{module system, recursion}
1275 Currently, the compiler does not have proper support for dealing with
1276 mutually recursive modules:
1298 When compiling either module A and B, the compiler will try (in vain)
1299 to look for the interface file of the other. So, to get mutually
1300 recursive modules off the ground, you need to hand write an interface
1301 file for A or B, so as to break the loop. For the example at hand, the
1302 boot interface file for A would like the following:
1309 1 newtype A = A PrelBase.Int ;
1310 1 f _:_ B.B -> A.A ;;
1313 To make sure you get the syntax right, tailoring an existing interface
1314 file is a Good Idea.
1316 {\bf Note:} This is all a temporary solution, a version of the compiler
1317 that handles mutually recursive properly without the manual
1318 construction of interface file, is in the works.
1320 %----------------------------------------------------------------------
1321 %\subsubsection[arity-checking]{Options to insert arity-checking code}
1322 %\index{arity checking}
1324 %The \tr{-darity-checks}\index{-darity-checks option} option inserts
1325 %code to check for arity violations. Unfortunately, it's not that
1326 %simple: you have to link with a prelude that was also built with arity
1327 %checks. If you have one, then great; otherwise...
1329 %The \tr{-darity-checks-C-only}\index{-darity-checks-C-only option}
1330 %option inserts the self-same arity checking code into \tr{.hc} files,
1331 %but doesn't compile it into the \tr{.o} files. We use this flag with
1332 %the \tr{-keep-hc-file-too}\index{-keep-hc-file-too option}, where we
1333 %are keeping \tr{.hc} files around for debugging purposes.
1335 %----------------------------------------------------------------------
1336 %\subsubsection[omit-checking]{Options to omit checking code}
1337 %\index{omitting runtime checks}
1339 %By default, the GHC system emits all possible not-too-expensive
1340 %runtime checking code. If you are brave or experimenting, you might
1341 %want to turn off some of this (not recommended):
1343 %\begin{tabular}{ll}
1344 %-dno-black-holing & won't buy you much (even if it works) \\
1345 %-dno-updates & you're crazy if you do this \\
1346 %-dno-stk-stubbing & omit stack stubbing (NOT DONE YET) \\
1348 %\index{-dno-black-holing option}%
1349 %\index{-dno-updates option}%
1350 %\index{-dno-stk-stubbing option}
1352 %Warning: all very lightly tested, if at all...
1354 %% %************************************************************************
1356 %% \subsection[options-GC]{Choosing a garbage collector}
1358 %% %************************************************************************
1360 %% (Note: you need a Good Reason before launching into this territory.)
1362 %% There are up to four garbage collectors to choose from (it depends how
1363 %% your local system was built); the Appel-style generational collector
1366 %% If you choose a non-default collector, you must specify it both when
1367 %% compiling the modules and when linking them together into an
1368 %% executable. Also, the native-code generator only works with the
1369 %% default collector (a small point to bear in mind).
1371 %% \begin{description}
1372 %% \item[\tr{-gc-ap} option:]
1373 %% \index{-gc-ap option}
1374 %% Appel-like generational collector (the default).
1376 %% \item[\tr{-gc-2s} option:]
1377 %% \index{-gc-2s option}
1378 %% Two-space copying collector.
1380 %% \item[\tr{-gc-1s} option:]
1381 %% \index{-gc-1s option}
1382 %% One-space compacting collector.
1384 %% \item[\tr{-gc-du} option:]
1385 %% \index{-gc-du option}
1386 %% Dual-mode collector (swaps between copying and compacting).
1387 %% \end{description}