nhc98 compile-time options


nhc98 is a driver script which calls (if necessary) in turn, the C preprocessor, the GreenCard preprocessor, the compiler proper, the C compiler, the assembler, and finally the linker. You can control these stages using environment variables and flags.

File arguments.
.hs Haskell source file
.lhs literate Haskell source file
.gc Haskell source file to be preprocessed with GreenCard
.c nhc98 bytecode file
.s assembler file
.o object file

Environment variables.

No environment variables are required. However, if you wish, you can use some or all of the following variables to configure parts of the driver script at compile-time.
NHC98LIBDIR The full path (excluding final machine-specific part) to the nhc98 executables and libs
NHC98INCDIR The full path to the nhc98 interface and include files.
NHC98COMP The name/path of the nhc98 compiler proper
GREENCARD The name/path of the GreenCard preprocessor
GREENCARDOPTS Additional options to the GreenCard preprocessor
TMP A temporary directory for intermediate files (default: /tmp)

Flags.
--version display version information and quit
-98 ensure Haskell 98 compatibility
-v verbose - echo commands before executing them
-cpp run the C preprocessor over the source file first
-p compile for heap profiling
-t compile for time profiling
-T compile for tracing
-c compile only - do not link to a final executable
-S stop after generating assembler file (.s)
-C stop after generating bytecode file (.c)
-o file name the final object or executable file
-d objdir place intermediate object files in objdir
-Hsize set the default heap for the final executable to size
-llib link against the library named lib
-Ldir search dir when linking against libs
-package pkg use hierarchical modules from the package named pkg, e.g. base, HaXml, etc.
-Idir search directory dir for imported modules during compilation, and for #include'd C header files during compilation of the C-section of a GreenCard file
-idir as for -I option, except also search dir and dir/$MACHINE for a library archive called lib$CFG.a at link stage, where $CFG is taken from the -p, -t, and -T flags, respectively indicating heap profiling, time profiling or tracing
-Pdir search directory dir for prelude and stdlib modules during compilation
-Dsym define sym when pre-processing, and when compiling the C-section of a GreenCard file
-Usym undefine sym when pre-processing, and when compiling the C-section of a GreenCard file
+RTS the following options (up to -RTS) should be passed only to the compiler's runtime system (for instance to set the compilation heap size)
+CTS the following options (up to -CTS) should be passed only to the compiler proper (as detailed below)
+rts runtime system options specified between +RTS ... -RTS delimiters should be passed on to the compiler proper using the nhc98/ghc syntax (i.e. when nhc98comp was compiled by nhc98 or ghc). You are unlikely to need this option, because a default setting of +rts or -rts is determined at config time
-rts runtime system options specified between +RTS ... -RTS delimiters should be passed on to the compiler proper using the hbc syntax (i.e. when nhc98comp was compiled by hbc). You are unlikely to need this option, because a default setting of +rts or -rts is determined at config time


The following flags can be passed to the nhc98 compiler proper. Occasionally a compiler option-name may conflict with (for instance) a linker option-name. To be sure that compiler options are parsed correctly, it is best to enclose them between +CTS and -CTS.

Options to change the usual compilation behaviour.

In general, the default value of an option is "off" (except where noted), and using the flag turns the option on. Where the default value is "on", an option can be turned off by prefixing the flag with no: for instance -zap is usually on by default, but -nozap will turn it off.
-redefine Don't complain if redefining an imported identifier
-part Compiling part of a lib, so don't complain if module name differs from file name and don't create profiling information for this module
-lib Compiling a lib, don't complain if importing modules with names that differ from their filenames
-unix Use unix filenames (default=on) (off=RiscOS filenames)
-unlit Unliterate the source code
-nkpat Allow (n+k) patterns (default=off except in -98 compatibility mode)
-underscore Treat underscores strictly as lowercase (default=off except in -98 compatibility mode)
-puns Allow named field punning (default=on except in -98 compatibility mode)
-ansiC Generate bytecode file as ANSI C (default=on)
-showtype Report type of main expression, but do not generate code
-profile number of occurrences = amount of heap profiling information per node
-tprof compile for time profiling
-zap Generate code to zap unused arguments/stack positions (default=on)
-prelude Keep prelude definitions in interface file
-keepcase Don't lift case, we fix those later
-dbgtrans perform tracing translation (for runtime tracer)
-dbgprelude use the tracing prelude
-trusted make this a "trusted" module (tracer)

Options to examine the internal progress of the compiler, stage by stage.
-showwidth=w set width in characters of output of an intermediate syntax tree to w (default=80)
-showindent=i set indentation in characters for nesting of output of an intermediate syntax tree to i (default=2)
-showqualified use qualified names in output of intermediate syntax tree (default=on)
-lex show lexical input
-parse show syntax tree after parser
-need show need table before import
-import print names of explicitly imported files
-ilex show lexical input for interface files
-iineed show need table between all import files
-iibound show symbol table between all import files
-iirename show rename table between all import files
-ineed show need table after import
-ibound show symbol table after import
-irename show rename table after import
-rename show syntax tree after rename
-rbound show symbol table after rename
-depend print imported identifiers that are used (not even alpha-tested yet)
-derive show syntax tree after derive
-dbound show symbol table after derive
-ebound show symbol table after extract
-remove show syntax tree after fields are removed (translated into selectors)
-scc show syntax tree after splitting into strongly connected groups
-type show syntax tree after type check
-tbound show symbol table after type check
-report-imports display imports actually used
-fixsyntax show syntax tree after removing newtype constructors and fixing Class.Type.method
-fsbound show symbol table after adding Class.Type.method info
-case show stg tree after simplification of patterns
-cbound show symbol table after simplification of pattern
-prim show stg tree after inserting primitive functions
-pbound show symbol table after inserting primitive functions
-free show stg tree with explicit free variables
-arity show stg tree after arity grouping
-lift show syntax tree after lambda lifting
-lbound show symbol table after lambda lifting
-atom show stg tree after only atoms in applications
-abound show symbol table after only atoms in applications
-gcode show G code
-gcodefix show G code after large constant fixed
-gcodeopt1 show G code optimisation
-gcodemem show G code NEEDHEAP
-gcodeopt2 show G code optimisation
-gcoderel show G code after offsets
-funnames insert position and name of functions in the code


The latest updates to these pages are available on the WWW from http://www.haskell.org/nhc98/

4 July 2004
York Functional Programming Group