Commit Graph

297 Commits

Author SHA1 Message Date
Julien Fischer
50ac3a9e66 Do not install low-level C parallel grades by default.
configure.ac:
compiler/handle_options.m:
     As above.
2026-03-27 12:28:31 +11:00
Zoltan Somogyi
821e03d8be Fix annoying unneeded recompilations.
runtime/Mmakefile:
    Some time ago, autoconf seems to have changed the text it puts
    into the files it generates, including mercury_conf.h.
    This broke the old code we had in this file that looked for
    the old text. Fix this by updating the pattern we look for.

    Document updates to autoconf as possible reasons for any future
    reoccurrence of this bug.

    Document the reason why we "standardize" the autoconfigured contents
    of mercury_conf.h.

    Fix programming style.

configure.ac:
    The changes in this file are only stylistic; they made it easier
    to track down the above bug.

    Put a comment about "order matters" *before* the lists whose order
    matters. Define the first of two lists being concatenated first
    (since order matters not just for code correctness, but also for
    reading comprehension :-().

    Fix misleading indentation.

    Add an XXX about some (seemingly) unneeded code.
2026-03-09 04:01:31 +11:00
Zoltan Somogyi
3aca14b385 Compile the Mercury system with --warn-unused-types.
configure.ac:
    Require the installed compiler to support that option.

STANDARD_MCFLAGS:
    Specify that option.

compiler/canonicalize_interface.m:
compiler/comp_unit_interface.m:
compiler/inst_user.m:
compiler/parse_module.m:
compiler/switch_util.m:
compiler/type_ctor_info.m:
deep_profiler/mdprof_dump.m:
library/digraph.m:
slice/mcov.m:
    Delete unused equivalence types that were picked up by the option.
2026-03-09 03:07:51 +11:00
Julien Fischer
5ce7e516e5 Fix namespace cleanliness checks with GCC on Windows.
On Windows, object files created by GCC contain reference pointer symbols
beginning with ".refptr.". Ignore these symbols when doing namespace
cleanliness checks. They are an implementation detail. If there is
an issue with namespace cleanliness, then we can detect and report it for
the original symbol for which the reference point was generated.

configure.ac:
    Detect whether this platform is one that generates reference pointers
    in object code.

Mmake.common.in:
    On platforms that have reference pointers, ignore all symbols beginning
    with ".refptr." when doing namespace cleanliness checks.
2026-02-01 13:22:59 +11:00
Julien Fischer
45c0b183e4 Delete an ancient workaround for SunOS 4
configure.ac:
runtime/mercury_conf.h.in:
runtime/mercury_goto.h:
    Delete workaround for systems where the assembler did not
    support the .type directive.
2026-02-01 02:53:04 +11:00
Julien Fischer
deac212895 Fix an ordering problem in configure.
configure.ac:
   Do not attempt to use the value of the variable ac_microsoft
   *before* it is defined.
2026-01-24 04:08:18 +11:00
Julien Fischer
0035d6d23d Delete --with-msvcrt configure option.
The --with-msvcrt option was intended for selecting between the older Microsoft
C runtime (crtdll.dll) and the Microsoft Visual C runtime (msvcrt.dll). This is
all now ancient history, since the MSVCRT itself has been superseded by the
Universal C runtime since Windows 10. Delete the --with-msvcrt option and all
uses of it.

configure.ac:
    Delete the --with-msvcrt option.

scripts/mgnuc.in
scripts/ml.in:
    Delete uses of the above configuration value.

Documentation/README.MS-VisualC.md:
    Delete references to --with-msvcrt.
2026-01-13 14:10:09 +11:00
Julien Fischer
714d2ccd3e Support bootchecking in the MSYS2 MSYS environment.
MSYS2's MSYS environment is similar to Cygwin and shares a lot of its
underlying code. Executables in this environment are linked with
msys-2.0.dll, which is a POSIX-emulation layer similar to cygwin1.dll.
The change of configuration triple for this environment last year from
x86_64-pc-msys to x86_64-pc-cygwin means that we can trivially support
Mercury in it by virtue of the fact that we already support Cygwin.

This diff makes some changes required to allow Mercury to bootcheck in
the MSYS2 MSYS environment.

configure.ac:
    Modify the error message we print if we detect *-pc-msys
    architecture.

tools/bootcheck:
    Do not abort if we detect the MSYS2 MSYS environment.

    Extend the comment describing the handling of the different MSYS2
    environment.

    Give a variable a more accurate name.
2026-01-04 03:01:25 +11:00
Julien Fischer
a1849e6ca2 Update links to README files.
Mmake.common.in:
RELEASE_NOTES:
configure.ac:
scripts/mgnuc.in:
tools/bootcheck:
tools/configure_cross:
tools/copy_mercury_binaries:
     Conform to the recent change that moved most of the README files into the
     Documentation directory.
2025-12-26 16:28:05 +11:00
Zoltan Somogyi
18f9fc3f2d Delete now-redundant blocks of unifications ...
compiler/print_help.m:
    ... that used to be required to help out switch detection.

configure.ac:
    Require the installed compiler to have the commit that makes those
    duplicate unifications unnecessary.
2025-11-17 18:47:02 +11:00
Zoltan Somogyi
fe1d779b25 Speed up {int,uint}{,8,16,32,64}_to_string ...
... when targeting C.

library/string.m:
    On 27 Oct 2021, Julien sped up one of these operations
    by avoiding the use of sprintf. Apply the same technique,
    suitably generalized, to all other similar operations.
    Use macros to reduce the amount of code duplication needed.

runtime/mercury_conf.h.in:
    Fix an old bug: spell MR_MERCURY_IS_{32,64}_BITS correctly,
    to match the name that is (conditionally) defined by configure.

configure.ac:
    Delete references to MERCURY_IS_{32,64}_BITS, which turn out
    to be totally unused.
2025-10-03 19:23:37 +10:00
Zoltan Somogyi
b6a0b12fc0 Use the new in_range builtin.
configure.ac:
    Require the installed compiler to support this new builtin.

library/private_builtin.m:
    Declare the builtin, making it usable.

library/string.m:
    Use it to replace the old hand-written range check.
2025-10-02 18:30:47 +10:00
Zoltan Somogyi
32006a1c7c Rename and generalize .c_debug to .target_debug.
runtime/mercury_grade.h:
    Rename the grade modifier, and the C macro that represents it.

compiler/options.m:
    Rename the --c-debug-grade option to --target-debug-grade.

compiler/compute_grade.m:
    Rename the grade modifier, and the option that represents it.

    Restrict the .target_debut grade modifier to MLDS grades.

compiler/handle_options.m:
    Implement --target-debug-grade by having it imply --target-debug.

compiler/compile_target_code.m:
compiler/link_target_code.m:
    Pay attention to either --target-debug-grade (for purposes related
    to the grade itself) and to --target-debug (for all other purposes).

scripts/canonical_grade.in:
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
    Parse target_debug grade modifiers and --target-debug-grade options
    instead of c_debug grade modifiers and --c-debug-grade options.

    Add (normally commented-out) infrastructure to make it easier
    to debug changes.

    Restrict the .target_debut grade modifier to MLDS grades.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
    Rename some variables to clarify the distinction between the
    --target-debug option (which, like -g, enabled debugging of only one file)
    and the --target-debug-grade option (which enables it for the whole
    program).

configure.ac:
    Make it easier to debug grade-related changes by recording
    both autoconfigured and user-supplied grades that the rejected by
    the canonical_grade script.

    Conform to the changes above.

README.sanitizers:
doc/user_guide.texi:
grade_lib/grade_spec.m:
grade_lib/grade_string.m:
scripts/ml.in:
tests/warnings/help_text.err_exp:
tools/lmc.in:
tools/test_mercury:
    Conform to the changes above.

scripts/Mmake.vars.in:
    Add some XXXs about style.
2025-08-09 21:48:23 +02:00
Zoltan Somogyi
7c84900d87 Start using --warn-include-and-non-include. 2025-07-31 06:37:09 +02:00
Zoltan Somogyi
9d2c686a35 Sort a list of files. 2025-07-12 14:53:46 +02:00
Zoltan Somogyi
7c296404bb Add "Opt level N automatically sets --xyz" ...
... to the user guide entries of the affected optimization options.

compiler/print_help.m:
    Implement the above.

doc/user_guide.texi:
    Expect the additions, both from this diff, and earlier ones.

tools/make_optimization_options_middle:
compiler/optimization_options.m:
    To make the above slightly simpler to implement, add a subtype
    of the option_data type, and change the type of the predicate
    that returns the options enabled at each optimization level
    to use this subtype.

configure.ac:
    Require the installed compiler to support the fix without which
    the subtype definition would make the automatically-generated
    contents of libs.optimization_options.int2 invalid.
2025-07-08 16:38:08 +02:00
Zoltan Somogyi
4d9200114d Delete scripts/Mercury.config.bootstrap.in.
scripts/Mercury.config.bootstrap.in:
    Delete this file.

configure.ac:
scripts/Mmakefile:
    Copy scripts/Mercury.config to scripts/Mercury.config.bootstrap.
    Add a note about filtering out options that the installed compiler
    does not yet understand.

scripts/Mercury.config.in:
    Document the new dual role of this file.
2025-06-25 08:12:11 +02:00
Zoltan Somogyi
8523329d70 Put the options in options.m into order.
compiler/options.m:
    Reorder optdb clauses

    - to put the categories options into the same order as in the help text
      generated by print_help.m;

    - to group related options within each category together;

    - to put those groups into a reasonable order; and

    - to put the options in those groups into a reasonable order.

    Reorder the definition of the option type to match the order of
    the optdb clauses.

    Add a require_switch_arms_in_type_order pragma for the optdb predicate
    to *keep* the type definition and the clauses in sync.

    Reorder the function symbols of the option_category type,
    since that pragma applies to *all* switches inside the optdb predicate,
    including the switch on the category in one mode.

configure.ac:
    Require the installed compiler to support the
    require_switch_arms_in_type_order pragma.

tests/warnings/help_text.err_exp:
    Expect the updated help text. The chapters and sections are in the same
    order as before, but the order of options within them has changed.
2025-06-23 18:10:08 +02:00
Zoltan Somogyi
6e109c022b Add optdb clauses for warning options.
compiler/options.m:
    As above. The new clauses are not yet used.

compiler/Mercury.options:
    Specify that the clauses of the optdef and optdb predicates
    may be interleaved.

configure.ac:
    Require the installed compiler to support the --allow-non-contiguity-for
    option.
2025-06-06 10:21:26 +10:00
Zoltan Somogyi
3dd0f2e03b Act on all remaining warnings about unused state vars.
compiler/add_heap_ops.m:
compiler/check_import_accessibility.m:
compiler/comp_unit_interface.m:
compiler/convert_import_use.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/equiv_type.m:
compiler/generate_dep_d_files.m:
compiler/generate_mmakefile_fragments.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/higher_order.specialize_unify_compare.m:
compiler/jumpopt.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make_hlds_passes.m:
compiler/make_module_file_names.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_lookup_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_target_util.m:
compiler/module_cmds.m:
compiler/opt_deps_spec.m:
compiler/optimize.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_string_format.m:
compiler/proc_gen.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/simplify_goal_disj.m:
compiler/ssdebug.m:
compiler/stack_opt.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/term_constr_build.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/untupling.m:
compiler/write_deps_file.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/html_format.m:
deep_profiler/startup.m:
profiler/mercury_profile.m:
profiler/propagate.m:
    Act on the new warnings. In a few cases, conform to the changes
    resulting from acting on the warnings in other modules.

browser/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
ssdb/Mercury.options:
    Specify options for disabling the new warnings for modules
    where we (probably) won't want them.

configure.ac:
    Require the installed compiler to understand the options that
    we now reference in the Mercury.options files above.

tests/debugger/tailrec1.exp:
    Expect variable names for the middle versions of state vars
    using the new naming scheme.

tests/invalid/Mercury.options:
    Fix references to obsolete test names.

tests/warnings/Mercury.options:
    Avoid a test failure with intermodule optimization.
2025-05-19 00:33:06 +10:00
Peter Wang
9833e275dd Prevent executable stack warning while building Boehm GC.
The file boehm_gc/atomic_ops_sysdeps.o is built from an assembly file,
and will be empty (devoid of sections) except when targeting
Solaris/SPARC with a compiler other than GCC. If the empty object file
is linked in, GNU ld will treat the executable or shared library as
requiring an executable stack, and newer versions of GNU ld will
warn that "missing .note.GNU-stack section implies executable stack".

Mmake.common.in:
    Introduce a variable BOEHM_NEED_ATOMIC_OPS_ASM,
    to be consulted by boehm_gc/Makefile.direct.

configure.ac:
    Set BOEHM_NEED_ATOMIC_OPS_ASM=yes only when building for
    Solaris/SPARC with a compiler other than GCC.
2025-04-07 15:23:15 +10:00
Julien Fischer
04557df655 Delete remaining support for Java native methods.
Prior to 2009 some of the standard library predicates were implemented using
Java native methods. These were disabled or replaced by commit 9fc47f5c in
order to give us pure Java versions of the runtime and standard libraries.
However, the machinery for supporting native methods was left in place. This
change deletes that machinery. We are not going to use it again.

library/Mmakefile:
    Do not build Native.so. (From the looks of it we never installed it
    anyway.)

java/runtime/Native.c:
    Delete the C implementations of the native methods ...

java/runtime/Native.java.in:
    ... and the corresponding Java support for them.

java/runtime/Mmakefile:
    Delete this Mmakefile, there is no longer anything for it to do.

configure.ac:
    Do not create Native.java.
2025-01-21 20:32:29 +11:00
Zoltan Somogyi
2db9ed70c9 Put the standard mmc flags in one file.
STANDARD_MCFLAGS:
    Put the mmc options that are common to either

    - all of the dir/DIR_FLAGS.in files, or
    - all but one of them,

    into this new file.

    (MFILTERJAVAC_FLAGS did not specify --warn-suspicious-foreign-code;
    after this diff, it does.)

configure.ac:
    Enable replacing @STANDARD_MCFLAGS@ with the new file's contents.

browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Include STANDARD_MCFLAGS instead of listing each option in it
    individually, making future global changes to options easier.
2024-11-09 20:55:44 +11:00
Zoltan Somogyi
9a16d92e68 Add support for \e as the escape char, stage 2.
doc/reference_manual.texi:
    Include \e among the list of the escape sequences that are part of Mercury.

NEWS.md:
    Announce the change.

vim/syntax/mercury.vim:
    Color \e as we do other escape sequences.

configure.ac:
    Require the installed compiler to support stage 1.

library/mercury_term_lexer.m:
library/rtti_implementation.m:
library/term_io.m:
    Use \e where appropriate.
2024-05-01 20:22:00 +10:00
Zoltan Somogyi
039d6eaefa Delete the bytecode backend.
NEWS.md:
    Announce the deletion of the --generate-bytecode mmc option,
    which was the only visible part of the deleted backend.

bytecode:
    Delete this directory, and all its files.

compiler/bytecode*m:
    Delete these files.

compiler/options.m:
doc/user_guide.texi:
    Delete the --generate-bytecode option.

compiler/mercury_compile_middle_passes.m:
    Delete the code that used to invoke the deleted backend.

compiler/file_names.m:
    Delete the representations of the filenames used by the deleted backend.

compiler/backend_libs.m:
compiler/builtin_ops.m:
compiler/code_model.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/mercury_compile_main.m:
compiler/proc_gen.m:
configure.ac:
    Conform to the changes above.

compiler/notes/compiler_design.html:
    Delete the description of the bytecode backend, and move the one remaining
    reference to it to the past tense.
2024-04-14 11:21:29 +10:00
Zoltan Somogyi
3c014aebbe Start using type_spec_constrained_preds pragmas.
In the compiler, this results in all-new specializations. In the library,
it mostly replaces (and augments) existing specializations, but some of
those specializations were missing, almost certainly through simple oversight.

configure.ac:
    Require the installed compiler to support those pragmas.

compiler/parse_tree_out.m:
compiler/parse_tree_out_clause.m:
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_item.m:
compiler/parse_tree_out_misc.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
compiler/parse_tree_out_sym_name.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_out_type.m:
compiler/parse_tree_out_type_repn.m:
    These are the modules that write out parse trees, e.g. to .intN
    and .*opt files. Specialize all of them for the I/O and "build a string"
    use cases.

library/pretty_printer.m:
library/stream.string_writer.m:
    Specialize all three of these modules for the I/O and "build a string"
    use cases, deleting all the indivial type_spec pragmas for the
    I/O use case. (There were no type_spec pragmas for building strings.)

    In pretty_printer.m, group the predicates for writing out sized integers
    first by signedness and then by size, instead of the other way around,
    since this results in easier-to-read code.

library/term_io.m:
    Specialize all three of these modules for the I/O and "build a string"
    use cases, deleting all the indivial type_spec pragmas for the
    both use cases.
2024-02-10 16:20:34 +11:00
Julien Fischer
f682b77f44 Disable the use of asm_fast grades on Windows.
Compilation of the stage 3 library currently results in a segmentation fault on
Windows. Since this can affect users who follow the advice of the configuration
script and attempt to re-install Mercury in a more efficient grades, disable
the use of the asm_fast grades until this is fixed.

configure.ac:
tools/configure_cross:
    As above.
2024-01-22 14:26:21 +11:00
Julien Fischer
dce6967ee3 Add configuration option to enable internal file copying.
Add a new configuration option, --with-cp, that controls whether file copying
by the Mercury compiler is done by invoking the "cp" command or by using the
file copying predicates in the new copy_util module.

When using MSVC or when using MinGW, make the new file copying predicates the
default. (These configurations are the most likely to be the ones where the
Mercury compiler is used from the Windows command prompt, where cp is not
available.)

configure.ac:
    Add the new option, --with-cp.

    Require the bootstrap compiler to support the --install-method configuration
    option that was added last November.

scripts/Mercury.config.in:
     Set the install method configuration option.
2024-01-14 17:02:59 +11:00
Julien Fischer
801f1f8d72 Do not install batch files on non-Windows systems.
configure.ac:
Mmake.common.in:
   Add a configuration parameter that says if the batch files in
   the scripts directory should be installed or not.

scripts/Mmakefile:
   Make the set of scripts to be installed dependent on the value of
   the new configuration parameter.
2024-01-11 19:58:48 +11:00
Julien Fischer
f256369bbb Attempt to preserve file permissions when copying.
Make the Mercury implementation of copying attempt to preserve file permissions
if we are on system that supports stat() and chmod().

compiler/copy_util.m:
    As above.

configure.ac:
runtime/mercury_conf.h.in:
    Check for the presence of the chmod() function.
2024-01-07 17:09:05 +11:00
Peter Wang
d7099e830a Remove MR_INT_LEAST64_LENGTH_MODIFIER.
We had configure choose the format string length modifier for
MR_int_least64_t based on whether the type is an alias for "int",
"long", "long long" or "__int64". That does not work for some versions
of MinGW-w64, which warn about the "ll" length modifier even though
MR_int_least64_t is an alias for "long long". The reason is that
we would be calling the MSVC runtime *printf functions,
which require the "I64" length modifier instead of "ll".

The only place MR_INT_LEAST64_LENGTH_MODIFIER is used in the Mercury
system is in the hidden function float64_bits_string (which is also
no longer used by the Mercury compiler after the removal of the hl
grades). We can replace that use with PRIdLEAST64 from inttypes.h.

Users are unlikely to be using MR_INT_LEAST64_LENGTH_MODIFIER,
so it should be safe to remove it.

configure.ac:
runtime/mercury_conf.h.in:
    Don't define MR_INT_LEAST64_LENGTH_MODIFIER.

library/float.m:
    Replace use of MR_INT_LEAST64_LENGTH_MODIFIER with PRIdLEAST64
    in float64_bits_string.

    Mark all float32_bits_string and float64_bits_string foreign procs
    as 'may_not_export_body'. There is no need to opt-export procedures
    that will rarely be used, if ever.

runtime/mercury_types.h:
    Update comment.
2023-12-20 15:32:02 +11:00
Julien Fischer
e14f918e63 Delete MR_HAVE_STDINT_H.
The configure script currently contains a check for the presence of the C99
header stdint.h. This is redundant since (1) *all* C compilers that are
currently capable of compiling Mercury support C99 and (2) most #includes of
stdint.h in the Mercury system are not, and have never been, protected by the
MR_HAVE_STDINT_H anyway.

configure.ac:
runtime/mercury_conf.h.in:
    Do not check for stdint.h.

runtime/mercury_std.h:
    Delete the one remaining use of the MR_HAVE_STDINT_H macro.
2023-12-03 00:19:48 +11:00
Zoltan Somogyi
f9c185e5e8 Start actively using --generate-dependencies-ints.
configure.ac:
    Require the installed compiler to support both the option,
    and the Mmake rules that invoke it.

compiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
ssdb/Mmakefile:
    Get the mmake depend to depend on prog.depend_ints, not prog.depend,

    Give the prog.depend_ints targets themselves the same prerequisites
    as the existing prog.depend targets.

    In mfilterjavac/Mmakefile, fix what looks like an old problem
    by making the depend target a prerequisite of the check and ints targets.
2023-10-20 20:11:45 +11:00
Julien Fischer
14ecd27af0 Announce --with-pkgversion option.
NEWS.md:
    Announce the recently added --with-pkgversion option to configure.

configure.ac:
    Adjust the help message for --with-pkgversion.
2023-10-08 12:22:43 +11:00
Julien Fischer
57acffa039 Support optional package version information.
Add a new configure option, ---with-pkgversion, that allows those packaging
Mercury to include additional version information specific to their package in
the output of mmc --version etc.

Omit version and copyright information from the short usage messages for mmc, mprof
and mcov. The result is less cluttered and more direct.

Omit version information from the long usage (i.e. --help) message for the
above programs. This is to save space on the first line of the output and also
brings the man pages for mmc, mprof and mcov into line with the other man
pages, which do *not* have version information in their NAME section.

configure.ac:
    Add the new --with-pkgversion option.

runtime/mercury_conf.h.in:
runtime/mercury_dotnet.cs.in:
java/runtime/Constants.java.in:
    Define a constant for the package version.

library/library.m:
    Add the function package_version/0, which returns the package
    version string.

compiler/handle_options.m:
profiler/mercury_profile.m:
slice/mcov.m:
    Include a non-empty package version in the output of --version.

    Make the above changes to the short and long usage messages.

    Add an XXX about mprof's short usage message.
2023-09-09 14:23:50 +10:00
Zoltan Somogyi
5f47a8389b Stop using higher order insts as modes.
configure.ac:
    Require the installed compiler to support --allow-insts-as-modes
    (and therefore its negation).

*/*_FLAGS.in:
    Add -no-allow-ho-insts-as-modes as a default option.

compiler/bytecode_data.m:
compiler/deforest.m:
compiler/inst_graph.m:
compiler/introduce_parallelism.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_robdd.equiv_vars.m:
compiler/mode_robdd.implications.m:
compiler/mode_robdd.tfeirn.m:
compiler/parse_util.m:
compiler/recompilation.version.m:
compiler/set_of_var.m:
compiler/term_constr_fixpoint.m:
deep_profiler/array_util.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/dump.m:
deep_profiler/interface.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
    Add in() wrappers around higher order insts used as modes.

    Use simply "in" as the mode of functions with the default mode
    and determinism.

    Fix a few style issues.
2023-08-15 00:19:34 +02:00
Julien Fischer
460a11ec3d Fix the debugger tests with MSYS2/MinGW64.
These were failing because debugger expects Windows-style paths in the
test_mdbrc file, but it was being generated with Unix-style paths. A
similar problem was recently fixed for MSVC, this change extends that
fix to also work for MSYS2/MinGW64.

configure.ac:
    Define a new configuration variable, FIX_PATH_FOR_WINDOWS, that expands
    to the command used to do path conversion in Unix-like environments on
    Windows. (The previous fix for MSVC used FIX_PATH_FOR_CC to do this,
    but the MinGW64 port of GCC does use Unix-style paths so that cannot
    be used here.)

scripts/Mmake.vars.in:
    Add a new mmake variable, FIX_PATH_FOR_WINDOWS.

scripts/Mmakefile:
    Use FIX_PATH_FOR_WINDOWS when creating the test_mdbrc file.
2023-07-26 21:24:28 +10:00
Julien Fischer
6b731ff970 Avoid a spurious warning from configure.
The configure script currently emits a warning about static linking not being
supported when using MSVC. This wrong: static linking is the only form of
of linking that *is* currently supported when using MSVC.

Clean-up a left over reference to lcc.

src/configure.ac:
    As above.
2023-07-26 16:19:04 +10:00
Zoltan Somogyi
685eefa206 Move base of term_io.m to X_to_string, write_X, format_X.
library/term_io.m:
    Move the base operations of term_io.m to the structure we use
    in parse_tree_out*.m in the compiler, where for every type X,
    there is a function X_to_string, and two predicates write_X and format_X,
    with the former operating on I/O states, and the latter operating on
    arbitrary streams. The idea is to apply the "don't repeat yourself"
    principle by having both X_to_string and write_X just call format_X.

    Apply that principle here as well, with one minor exception,
    which is that for some values of X, both write_X and format_X are
    implemented in terms of X_to_string.

    Impose the X_to_string, write_X, format_X naming scheme. The ancient code
    already in term_io.m had (each for some values of X) had

    - some of these functions/predicates missing
    - inconsistent names, in that write_X/N did I/O while write_X/(N+1)
      wrote to arbitrary streams
    - names that were inconsistent in another way, in that write_X/N did
      I/O of values of type X, but the function to convert X to string
      was NOT named X_to_string.

    Keep some of the misnamed functions around permanently, because
    some of the names for fitting into the new scheme, such as
    "escaped_string_to_string", would be strange.

    Keep the rest of the misnamed functions and all the misnamed predicates
    around temporarily, with commented-out obsolete pragmas. I expect
    to make these pragmas active when the rest of term_io.m is converted
    to this scheme.

    To prepare for that, use string.builder, not string, as the
    stream.writer instance to implement X_to_string, because of its
    better algorithmic complexity, which is needed mainly for terms
    of nontrivial size.

    Consistently put operations on each X in the order X_to_string,
    write_X and format_X.

NEWS.md:
    List all the new predicates and functions.

configure.ac:
    Require the installed compiler to contain the fix which allows
    a typespec pragma for an obsolete predicate or function.

browser/interactive_query.m:
compiler/hlds_out_util.m:
compiler/parse_tree_out_clause.m:
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_sym_name.m:
compiler/parse_tree_out_type_repn.m:
library/pretty_printer.m:
library/stream.string_writer.m:
library/string.builder.m:
mdbcomp/trace_counts.m:
    Update all references to the newly-obsolete predicates and functions.

library/string.to_string.m:
    Improve variable names.
2023-07-04 00:00:09 +02:00
Julien Fischer
4b5c94c050 Work towards supporting 64-bit Windows with MSVC.
compiler/globals.m:
     Extend c_compiler_type to distinguish between versions of MSVC
     that target x86 and those that target x86_64 (x64).

compiler/handle_options.m:
     Update the list of valid C compiler types.

compiler/compile_target_code.m:
     Handle versions of MSVC that generate x86_64 code.

m4/mercury.m4:
    Distinguish between versions of MSVC that target x86 and those
    that target x86_64.

configure.ac:
    Generate the new values of --c-compiler-type for MSVC.

    Determine the CPU type to pass to boehm_gc/NT_MAKEFILE.
    (This will also require an update to boehm_gc/Mmakefile; this change does
    not do that.)

Mmake.common.in:
    Add a new variable for setting the CPU type for boehm_gc/NT_MAKEFILE.
2023-06-25 16:19:01 +10:00
Zoltan Somogyi
80d740f46a Use "some [Var] ( ... Var ... )', now that we can.
compiler/types_into_modes.m:
    As above.

configure.ac:
    Require the installed compiler to have the fix that allows the above.
2023-06-12 13:33:08 +02:00
Julien Fischer
2a366cf295 Deprecate --no-ansi and --no-ansi-c.
--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)

Also deprecate the internal compiler option --cflags-for-ansi.

compiler/options.m:
    Document that --no-ansi-c is now deprecated.

    Document that the internal option --cflags-for-ansi is now
    deprecated.

compiler/compile_target_code.m:
    Do not pass the ANSI options to the C compiler.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
    Deprecate the --no-ansi option; delete code that no longer does
    anything useful.

configure.ac:
    Delete the configuration variable CFLAGS_FOR_ANSI; it is only ever
    set to be empty. (The comment talks about --no-ansi doing other things
    in the mgnuc script. It used to also cause some preprocessor macros
    to be defined for compatibility with the system headers on some
    platforms -- that has not been the case since 2013.)

doc/user_guide.texi:
    Document that --no-ansi-c is deprecated.

bytecode/Mmakefile:
compiler/Mercury.options:
library/Mercury.options:
extras/odbc/odbc.m:
runtime/Mmakefile:
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
tests/hard_coded/Mercury.options:
tests/valid/Mercury.options:
trace/Mmakefile:
util/Mmakefile:
    Conform to the above change.

NEWS.md:
    Announce the above.
2023-05-31 17:44:26 +10:00
Zoltan Somogyi
8de0a1351a Fix comments. 2023-04-23 15:30:24 +10:00
Zoltan Somogyi
d3425a4f6f Improve some comments. 2023-03-30 21:49:47 +11:00
Julien Fischer
2c8ada3dcc Delete unused string formatting predicates.
library/string.format.m:
    Delete the old predicates for formatting ints as unsigned values;
    these are now unused.

configure.ac:
    Require the use of a compiler that does not generate references
    to the deleted predicates.

compiler/introduced_call_table.m:
    Delete the above predicates from the introduced call table.
2023-02-09 10:39:58 +11:00
Peter Wang
b0ae10248b Use --trans-opt-deps-spec option.
Use the recently added --trans-opt-deps-spec option to break cycles in
the trans-opt dependency graph for the standard library. This enables
more parallelism when making the .trans_opt files; it now takes about
half as long as before.

Ordering modules sensibly, so that .trans_opt files are created in a
logical order, also improves analysis results for many predicates and
functions. The only results which show a regression with this change are
for deprecated forwarding predicates/functions.

In future, we will probably be able to trim more dependencies to further
improve parallelism, without impacting analysis results.

configure.ac:
    Check that the bootstrap compiler supports --trans-opt-deps-spec.

library/mer_std.trans_opt_deps_spec:
    Add the spec file that adjusts dependencies in the trans-opt
    dependency graph.

library/INTER_FLAGS:
    Use the --trans-opt-deps-spec option when building with mmake.

scripts/prepare_install_dir.in:
tools/binary:
tools/bootcheck:
tools/unary:
    Copy mer_std.trans_opt_deps_spec when preparing a copy of the
    library directory.
2023-01-25 16:48:45 +11:00
Zoltan Somogyi
d4220530c9 Act on a review comment. 2022-12-30 20:01:54 +11:00
Zoltan Somogyi
05ef8e01fb Rename the .ll_debug grade component to .c_debug.
Rename mmc and mgnuc options that set this grade component to --c-debug-grade.
Let the options named --c-debug of both mmc and mgnuc enable C level debugging
of only the module being compiled.

runtime/mercury_grade.h:
    Rename the .ll_debug grade component to .c_debug. Also rename the C macro
    that controls the presence or absence of this grade component
    from MR_LL_DEBUG to MR_C_DEBUG_GRADE.

runtime/mercury_conf_param.h:
runtime/mercury_debug.c:
runtime/mercury_debug.h:
runtime/mercury_engine.c:
runtime/mercury_label.c:
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
runtime/mercury_overflow.c:
runtime/mercury_std.h:
runtime/mercury_wrapper.c:
    Rename the MR_LOWLEVEL_DEBUG macro to MR_DEBUG_THE_RUNTIME.
    Previously, the name of this macro wrongly implied that it had
    something to do with the old .ll_debug grade component, even though

    - the MR_LOWLEVEL_DEBUG macro was designed to debug LLDS grades,
      since only these existed when it was created, while

    - the .ll_debug grade component (now .c_debug) is useful only for
      MLDS grades targeting C.

compiler/options.m:
    Rename the old confusingly named low_level_debug option to c_debug_grade.
    Move it to the list of grade options, and fix its documentation, which
    was completely wrong:

    - code in compile_target_code.m treated it as being a synonym of
      the .ll_debug (now .c_debug) grade component, while
    - its (commented out) documentation here in options.m said it called for
      the enabling of what is now MR_DEBUG_THE_RUNTIME.

compiler/compile_target_code.m:
    Conform to the rename just above.

    Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.

    Pass -g to the C compiler if either c_debug_grade or target_debug
    is enabled.

    Add an XXX about a missing safety check for an obsolete experimental
    feature.

compiler/compute_grade.m:
    When given a grade with a .c_debug grade component, set only the
    c_debug_grade option; don't set the target_debug option, which is NOT
    a grade option. The change to compile_target_code.m above handles the
    only situation in which this implication was formerly required.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
    Look for and process the .c_debug grade component instead of .ll_debug.
    Use a sh variable named c_debug_grade to record its absence/presence.

    Look for and process the --c-debug-grade grade-component option,
    setting the same sh variable, c_debug_grade. (All grade components
    can be set piecemeal using sh options to the scripts using these
    subroutines.) This replaces the old, confusingly named option
    --low-level-debug.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
    Consistently use the sh variable c_debug to record the presence of
    the (non-grade) --c-debug option to mgnuc, and the sh variable
    c_debug_grade to record the presence of the .c_debug grade component.

    Stop looking for and handling the --low-level-debug option, which
    mgnuc used to document, even though this duplicated the same documentation
    in init_grade_options.sh-subr, which mgnuc includes. The difference was
    that init_grade_options.sh-subr meant it to represent the old .ll_debug
    MLDS grade component, while mgnuc treated it as specifying what is now
    MR_DEBUG_THE_RUNTIME for LLDS grades. It didn't help that two sh variables
    with quite different semantics had names that differed only in an
    underscore: LLDEBUG_OPTS vs LL_DEBUG_OPTS.

scripts/Mmakefile:
    Add a missing dependency to force the rebuild of mgnuc after each update
    of its sh subroutine mgnuc_file_ops.sh-subr.

doc/user_guide.texi:
    Document the --c-debug-grade option of mmc. This option was not publicly
    documented under its original misleading name (--low-level-debug), but
    its documentation is now possible without contorted dancing around the
    name.

    Clarify the documentation of mgnuc's --c-debug option.

README.sanitizers:
configure.ac:
    Conform to the rename of the grade component.

grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/try_all_grade_structs.m:
    Conform to the rename of the grade component .ll_debug to .c_debug.

    Don't allow the .c_debug grade component in LLDS grades.

    In grade_string.m, add some obvious implications of some grade components.

grade_lib/choose_grade.m:
grade_lib/grade_lib.m:
grade_lib/test_grades.m:
grade_lib/var_value_names.m:
    Fix white space.

scripts/ml.in:
tools/lmc.in:
tools/test_mercury:
    Conform to the change in compile_target_code.m to the naming of
    Boehm gc library variants.
2022-12-29 20:33:08 +11:00
Zoltan Somogyi
5206fc5bbc Rename hlc-low-level-debug-grades to hlc-gdb-grades.
This should help reduce confusion.
2022-12-20 00:56:13 +11:00
Zoltan Somogyi
1faa7dc914 Factor out common code in const_prop.m.
compiler/const_prop.m:
    As above.

    Handle / in both int.m and uint.m the same way as //, since / is a
    synonym of // in both modules.

    Also, handle the compile-time evaluation of plus, minus, and
    unchecked_quotient in uint.m. Previusly, we only evaluated
    their synonyms +, -, * and //.

configure.ac:
    Require the installed compiler to contain the fix for a bug that
    prevents compilation of the new code of const_prop.m in hlc grades.
2022-12-09 15:12:03 +11:00