11 Using a different C compiler
The Mercury compiler takes special advantage of certain extensions
provided by GNU C to generate much more efficient code. We therefore
recommend that you use GNU C for compiling Mercury programs.
However, if for some reason you wish to use another compiler,
it is possible to do so. Here's what you need to do.
- Create a new configuration for the Mercury system using the
‘mercury_config’ script, specifying the different C compiler, e.g.
‘mercury_config --output-prefix=/usr/local/mercury-cc --with-cc=cc’.
- Add the ‘bin’ directory of the new configuration to the beginning
of your PATH.
- You must use a grade beginning with ‘none’, ‘hlc’ or ‘hl’
(e.g. ‘hlc.gc’).
You can specify the grade in one of three ways: by setting the
‘MERCURY_DEFAULT_GRADE’ environment variable, by adding a line
‘GRADE=...’ to your ‘Mmake’ file, or by using the
‘--grade’ option to ‘mmc’. (You will also need to install
those grades of the Mercury library, if you have not already done so.)
- If your compiler is particularly strict in
enforcing ANSI compliance, you may also need to compile the Mercury
code with ‘--no-static-ground-terms’.