mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 09:53:36 +00:00
The default optimisation level was implemented by having the
Mercury.config file add a -O<n> option to the DEFAULT_MCFLAGS variable.
This allowed the user to override the default optimisation level
by setting the MERCURY_DEFAULT_OPT_LEVEL environment variable.
Commit 181ada0dbf made it so that -O<n>
options do not reset previously set options. This had the unintended
consequence that any -O<n> options below the default optimisation level
had no effect when passed on the command line or in a Mercury.options
file, because a -O<n> option passed by the user would never undo the
options set by the default optimisation level.
compiler/options.m:
Add new option `--default-opt-level' for use by Mercury.config.
tools/make_optimization_options_end:
Add predicate to parse the value of `--default-opt-level' from the
options table. The option value is a string because the value of the
MERCURY_DEFAULT_OPT_LEVEL environment variable will be passed as
the option value. The existence of the environment variable was
(barely) documented, but the allowable values are not.
Though the user might conceivably have set any Mercury compiler
option in that environment variable, the value was probably only
intended to be a string of the form "-O<int>", and that is all we
will support.
tools/make_optimization_options_middle:
Use `get_default_opt_level'.
compiler/optimization_options.m:
Regenerate this file.
compiler/options_file.m:
Do not automatically add "-O2" to MCFlags.
The comment says this was to set a default optimisation level when
calling the `mercury_compile' binary instead of the `mmc' script,
but `get_default_opt_level' already defaults to optimisation level 2.
scripts/Mercury.config.in:
Pass the value of MERCURY_DEFAULT_OPT_LEVEL using the
`--default-opt-level' option.
This directory, mercury/tools, contains scripts that are not intended for use by users. The scripts here are used by the Mercury developers for maintaining the Mercury compiler.