Commit Graph

325 Commits

Author SHA1 Message Date
Zoltan Somogyi
71b4de934a Allow TEST_FAILS_DIR to be set by an environment var. 2026-03-06 05:38:56 +11:00
Zoltan Somogyi
19d8f1e0de Delete a redundant assign and a redundant test. 2026-02-23 20:49:01 +11:00
Julien Fischer
12e12ac3e3 Add a missing word.
tools/bootcheck:
    Add a missing word in the usage message.
2026-02-01 02:59:16 +11:00
Julien Fischer
aaa7a84133 Re-enable namespace checks on Cygwin.
tools/boocheck:
    Re-enable the namespace checks on Cygwin; they were disabled
    to workaround issues with GCC 2.95.
2026-01-31 13:49:51 +11:00
Julien Fischer
ada73d8836 Fix test suite on Windows.
tools/bootcheck:
    Set the diff options to strip trailing carriage returns on all native
    Windows configurations, not just the ones available through MSYS2.
2026-01-25 21:28:35 +11:00
Julien Fischer
94d9422453 Minor fixes.
NEWS.md:
    Fix whitespace.

tools/bootcheck:
    s/the/then/ in a spot.
2026-01-25 16:34:38 +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
87f40d1313 Add any contents of ~/.bootcheck_date to date commands. 2025-12-10 08:10:49 +11:00
Julien Fischer
0dbf9e21cc Fix a problme with bootcheck --no-bootcheck.
tools/bootcheck:
     With --no-bootcheck in the Java grade, do not pass any runtime
     options. The Java version of the runtime only supports a very
     small subset of the options.
2025-10-31 15:02:41 +11:00
Zoltan Somogyi
372f41f867 Don't leave stray Mercury directories in tests.
tests/Mmake.common:
    Bootchecks in the csharp and java grades, which use mmc --make
    and --use-subdirs, have traditionally left all the Mercury directories
    they constructed in tests/*. These screwed up any subsequent bootchecks
    in other grades, because the mere presence of those directories
    told the compiler to put their results in there, which was not always
    what was wanted.

    Fix this by

    - deleting any Mercury directories before we start runtests in a test
      directory,

    - deleting any Mercury directories after runtests succeeds in a test
      directory, and

    - rename any Mercury directories after runtests fails in a test
      directory, to Mercury.failed.

    This last part allows any failures to be investigated and debugged,
    without interfering with later bootchecks. (Though those later bootchecks
    will delete any Mercury.failed directories, so they should be moved
    elsewhere first if they may be needed later.)

tools/bootcheck:
    Delete the temporary code that helped me track down this issue
    and to conform its fix.

    Fix too-long lines.
2025-07-13 17:32:44 +02:00
Zoltan Somogyi
7d05201c2b Fix some problems with bootchecks.
These caused the tests in the mmc_make directory to be executed even
when they shouldn't have been, because the bootcheck did not specify
the --use-subdirs option. The root cause was probably the existence
of unintended Mercury directories, since this would cause mmake
to set MMAKE_USE_SUBDIRS to yes even without --use-subdirs.

tests/invalid/Mmakefile:
    Clean up the Mercury directory created by a test case here.

tests/mmc_make/Mmakefile:
    Clean up the Mercury directory created by all the test cases here.

    Make a rule more robust.

    Add a note about a currently unenabled test case.

tests/mmc_make/Mmakefile:
tests/valid_make_int/Mmakefile:
    Test for --use-subdirs being enabled via the new variable
    set by tools/bootcheck.

tools/bootcheck:
    Record the value of --use subdirs in a variable, TESTS_USE_SUBDIRS,
    that mmake does not know about and therefore will not touch.

    Fix three unrelated issues that came up in bootchecks for testing
    the above diff. They all involve the same small piece of code
    whose job is to clean up .data and .procrep files left by bootchecks
    in deep profiling grades.

    - One issue was the lack of an update for the somewhat-recent change
      in the naming of deep profiling data files;

    - another was the lack of required parentheses on the find command line;

    - and the third was the lack of protection for version-controlled files
      that we do NOT want to delete.
2025-03-28 11:17:06 +11:00
Zoltan Somogyi
da4d770b5b Fix stray blank line. 2025-01-09 01:49:26 +11:00
Zoltan Somogyi
7c92a7f410 Fix formatting, and add an XXX. 2024-12-15 12:08:20 +11:00
Julien Fischer
6d91b822e8 Fix library installation from stage 2.
tools/bootcheck:
   Link the new STANDARD_MCLAGS file into stage 2.
2024-11-10 01:03:39 +11:00
Julien Fischer
9f3bbc9db9 Fix typo.
tools/bootcheck:
    As above.
2024-10-13 21:39:22 +11:00
Zoltan Somogyi
9fd51ae7af Add --deep-std-name option to control deep prof file names.
When this new runtime option is specified, the runtime system will use
Deep.{data,procrep} as the names of the files it writes out.

runtime/mercury_engine.h:
    Add a flag to the engine that records whether this option has been
    specified or not.

runtime/mercury_wrapper.c:
    Set the flag if/when we see the --deep-std-name option.

runtime/mercury_deep_profiling.c:
    If the new flag is set, use Deep.{data,procrep} as filenames.

doc/user_guide.texi:
    Document the new option.

tools/bootcheck:
    Specify the new option for bootchecks.

tests/debugger/Mmakefile:
tests/declarative_debugger/Mmakefile:
tests/hard_coded/Mmakefile:
tests/par_conj/Mmakefile:
tests/stm/Mmakefile:
    When specifying a value of MERCURY_OPTIONS that overrides the value
    set by tools/bootcheck, include --deep-std-name in that value.
2024-10-13 19:47:06 +11:00
Julien Fischer
7f16eb78dd Fix a typo.
tools/bootcheck:
    s/mct/mtc/
2024-07-17 11:01:13 +10:00
Peter Wang
2c03de8c79 Add two bootcheck options.
Add options to the bootcheck script to help with testing of grades
in which the stage 2 compiler would be very slow, i.e. java and csharp.

tools/bootcheck:
    Add --skip-stage-3, which skips building the stage 3 directory.

    Add --test-with-stage-1-compiler, which causes the stage 1 compiler
    to be used when executing the test suite, instead of the stage 2
    compiler.

    Rename the existing mmake_stage_2 variable to build_stage_2.
2024-07-16 15:40:26 +10:00
Zoltan Somogyi
3452cbb107 Implement the MERCURY_ENABLE_COLOR envvar.
compiler/mercury_compile_main.m:
    If this new environment variable is set to always/never/1/0,
    then enable or disable the use of color as directed. Do this regardless
    of the setting of the NO_COLOR environment variable, since NO_COLOR
    is a general setting while MERCURY_ENABLE_COLOR is a specific setting.
    NO_COLOR is still consulted if MERCURY_ENABLE_COLOR is either not set,
    or is set to a value we don't recognize.

compiler/globals.m:
    Now that color diagnostics can be disabled using this new purpose-specific
    envvar, stop taking an "" or "none" value of the MERCURY_COLOR_SCHEME
    envvar as a request to disable colors in diagnostics.

compiler/options.m:
    Shorten the name of the --enable-color-diagnostics option to just
    --color-diagnostics.

compiler/handle_options.m:
    Conform to the changes above.

tools/bootcheck:
    Set MERCURY_ENABLE_COLOR to "always". Delete the unset of NO_COLOR,
    since it should not be needed.

tests/invalid/Mmakefile:
tests/invalid_make_int/Mmakefile:
tests/invalid_nodepend/Mmakefile:
tests/invalid_onlydepend/Mmakefile:
tests/invalid_purity/Mmakefile:
tests/invalid_submodules/Mmakefile:
tests/recompilation/Mmakefile:
tests/warnings/Mmakefile:
    Update the references to ---enable-color-diagnostics. Bootchecks would
    work even if we deleted them, but keeping them slightly simplifies
    running the tests outside of bootcheck.
2024-06-15 08:47:40 +10:00
Zoltan Somogyi
2526c4b8cb Split possible_cause into hint and inconsistent.
compiler/error_spec.m:
    Replace the possible_cause color name with the hint and inconsistent
    color names, as agreed on m-rev.

compiler/globals.m:
compiler/write_error_spec.m:
    Update the code handling color names and their mapping to color shades.

compiler/options.m:
    Update the invisible options that record that mapping.

tools/bootcheck:
    Update the color scheme used for the test suite.

compiler/accumulator.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/equiv_type.m:
compiler/format_call_errors.m:
compiler/inst_check.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_warn.m:
compiler/mode_errors.m:
compiler/module_qual.qual_errors.m:
compiler/parse_item.m:
compiler/parse_mutable.m:
compiler/parse_pragma.m:
compiler/parse_type_defn.m:
compiler/post_typecheck.m:
compiler/simplify_goal_call.m:
compiler/simplify_proc.m:
compiler/split_parse_tree_src.m:
compiler/state_var.m:
compiler/termination.m:
compiler/typecheck_error_overload.m:
compiler/typecheck_error_undef.m:
compiler/typecheck_errors.m:
    Replace uses of the possible_cause color with one of its replacements.
    In a few cases, adjust some other colors as well.

tests/invalid/bad_statevar_bad_context.err_exp:
tests/invalid/bind_in_negated.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/bug487.err_exp:
tests/invalid/coerce_disambig.err_exp:
tests/invalid/coerce_implied_mode.err_exp:
tests/invalid/coerce_infer.err_exp:
tests/invalid/coerce_non_du.err_exp:
tests/invalid/coerce_type_error.err_exp:
tests/invalid/coerce_unify_tvars.err_exp:
tests/invalid/conflicting_tabling_pragmas.err_exp:
tests/invalid/dcg_context.err_exp:
tests/invalid/default_ho_inst_2.err_exp:
tests/invalid/fbnf.err_exp:
tests/invalid/freefree.err_exp:
tests/invalid/functor_ho_inst_bad_1.err_exp:
tests/invalid/functor_ho_inst_bad_3.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/merge_inst_error.err_exp:
tests/invalid/mode_inf.err_exp:
tests/invalid/modes_erroneous.err_exp:
tests/invalid/multimode_dcg.err_exp:
tests/invalid/partial_implied_mode.err_exp:
tests/invalid/quant_constraint_1.err_exp:
tests/invalid/quant_constraint_2.err_exp:
tests/invalid/string_format_bad.err_exp:
tests/invalid/string_format_unknown.err_exp:
tests/invalid/test_may_duplicate.err_exp:
tests/invalid/test_may_export_body.err_exp:
tests/invalid/type_diff.err_exp:
tests/invalid/typeclass_dup_method_mode.err_exp:
tests/invalid_make_int/bad_mutable_int.int_err_exp:
tests/invalid_nodepend/duplicate_modes.err_exp:
tests/invalid_nodepend/errors_2.err_exp:
tests/invalid_nodepend/occurs.err_exp:
tests/invalid_nodepend/require_tailrec_invalid.err_exp:
tests/invalid_nodepend/test_with_type.err_exp:
tests/invalid_nodepend/unbound_type_vars.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense_1.err_exp:
tests/invalid_purity/purity_nonsense_2.err_exp:
tests/warnings/foreign_term_invalid.err_exp:
tests/warnings/format_call_multi.err_exp:
tests/warnings/format_call_warning.err_exp:
tests/warnings/table_with_inline.err_exp:
tests/warnings/warn_succ_ind.err_exp:
tests/warnings/warn_succ_ind.err_exp2:
tests/warnings/warn_succ_ind.err_exp3:
    Expect updated diagnostics.
2024-06-07 08:42:26 +10:00
Zoltan Somogyi
b3c6950cf4 Add draft support for color schemes.
compiler/write_error_spec.m:
    Delete the code that fills in the default colors for each role.

compiler/globals.m:
    Move that code here, into the implementation of
    convert_color_spec_options, which is the function that
    write_error_spec.m uses to set up the color database it uses
    by looking up the right options in the option_table.

    The main part of this diff is the addition of a new predicate,
    record_color_scheme_in_options, whose job is to *set up* those
    options.

    It does so by allowing the user to specify a *color scheme*,
    which may be a builtin scheme (of which we now support four,
    {dark,light}{16,256}), or a scheme that the user specifies directly
    using a string of the form

        specified@subject=C:correct=C:incorrect=C:possible_cause:C

    where each C is either a color name, or an SGR color number in 0..255.
    (And possibly something like rgb-R-G-B later.)

    There is also the pseudo-color-scheme named none, which is not a
    color scheme at all, but rather a way to turn off all use of color.

compiler/handle_options.m:
    Add code to allow the user to specify a color scheme using either

    - a new maybe_string option named --color-scheme, or
    - an environment variable named MERCURY_COLOR_SCHEME.

    Also add code to allow an environment variable named NO_COLOR
    to turn off the use of color regardless of any other color settings.

    Add a mechanism to avoid getting stuck in an infinite loop
    in the presence of errors in the values of environment variables
    that we use to set up the first globals structure.

compiler/options.m:
    Add the options needed by the new code in handle_options.m.
    Some are not yet documented, the rest are intended never to be documented,
    so there is no corresponding change to doc/user_guidet.texi (yet).

tools/bootcheck:
    Set the MERCURY_COLOR_SCHEME environment variable to specify
    the colors now in .err_exp files.
2024-06-06 10:15:17 +10:00
Zoltan Somogyi
104a8ebd9e Get "make cs"/"mmc --make x.cs" to build a C# file ...
... instead of building a bunch of .c files.

Our tradition of adding an "s" at the end of a suffix to mean "all of the
files with the original suffix" had a problem when we added C# as a target
language. Until then, just as "os" stood for ".o files" when it occurred
as either a mmake target, mmc --make target, or mmake variable name component.
"cs" likewise stood for ".c files", but was now also needed to mean ".cs file".
We coped by keeping "cs" meaning ".c files", and adding "csharp" as a target
name synonym to mean ".cs file".

This diff keeps that synonym, but it changes

- the name needed to refer to ".c files" from "cs" to "all_cs"
- the name needed to refer to ".o files" from "os" to "all_os"
- the name needed to refer to ".pic_o files" from "pic_os" to "all_pic_os"
- the name needed to refer to ".cs files" from "css" to "all_css"
- the name needed to refer to ".java files" from "javas" to "all_javas"
- the name needed to refer to ".opt files" from "opts" to "all_opts"
- the name needed to refer to ".trans_opt files"
        from "trans_opts" to "all_trans_opts"

It would be nice if we could apply this same change to all other similar
target names and mmake variable name suffixes, such as "ints" and "int3s",
but some of those names are already in use to mean semantically different
things. All of the names above that used to have the form "<ext>s" and
now have the form "all_<ext>s" stood for all the files with extension
".<ext>" that are prerequisites for building a linked target, i.e.
an executable or a library. But the mmake variable name suffixes
".all_mihs", ".all_mhs" and ".all_int0s" each stand for something subtly
different: the names of files that *may or may not exist", but which,
if they do exist, should be deleted by a clean or realclean target.

To make this breaking change easier to handle by users, this diff does
not simply redefine the meaning of ".all_int0s". (It does change the meaning
of the "cs" target, but the fact this will happen at some time has been
announced ages ago.) Instead, it defines three new mmake var suffixes,
".mihs_to_clean", ".mhs_to_clean" and ".int0s_to_clean", which are
synonyms for ".all_mihs", ".all_mhs" and ".all_int0s" respectively,
and announces that ".all_mihs", ".all_mhs" and ".all_int0s" are being
deprecated, and will have the above change of semantics applied to them
in the future.

NEWS.md:
    Announce the breaking change.

compiler/make.top_level.m:
    Stop treating the target "cs" as meaning "build all the .c files
    for this program".

    The code of classify_target_2 has long been semidet, but only in a way
    that was not apparent to the compiler. Change the code to allow the
    compiler to see its semidet nature while keeping the algorithm the same,
    except for the change in the paragraph above.

    This includes keeping e.g. "ints" as meaning "build all the .int/.int2
    files needed by this program".

compiler/write_deps_file.m:
    Stop generating mmake variables with suffixes ".cs", ".os", ".pic_os",
    ".javas" and ".css". The mmake variables with suffixes ".all_cs",
    ".all_os", ".all_pic_os", ".all_javas" and ".all_css" already existed.
    All had the same value as the mmake variable without the "all",
    with one exception: ".cs". However, in this case, the old (and still
    current) value of ".all_cs" is what the value of ".cs" *should* have been.

    Simplify some code.

The following changes in compiler/*.m are only cosmetic, but they helped me
rule out possible sources of problems with incomplete versions of this diff.

compiler/file_names.m:
    Add a version of a fact_table_file_name_return_dirs which does not
    return directories, since most of its callers don't need that info.

compiler/make.program_target.m:
    Clarify code by making variable names more descriptive,

compiler/make.file_names.m:
compiler/make.module_target.m:
    Conform to the changes above,

browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
grade_lib/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
    Rename os to all_os, cs to all_cs, css to all_css, javas to all_javas,
    and opts to all_opts. (There were no occurrences of trans_opts to rename.)

    Replace [s as sh command names in actions.

scripts/Mmake.vars.in:
    Specify the names of mmake variables holding the names of sets of files
    with a given extension directly, since for some of them, adding an "s"
    at the end of the name of the extension does not generate the name
    of the corresponding mmake variable anymore.

scripts/Mmake.rules:
    Use the directly specified mmake variable names from Mmake.vars.in
    in the rule for installing lbraries. Temporarily add some debugging
    output to make suree that the updated nested mmake variable references
    work as intended.

tools/bootcheck:
    Specify the names of mmake targets for making all the files in a program
    with a given extension directly, since adding an "s" at the end of the
    name of the extension does not generate the name of the corresponding
    mmake target anymore.

    Print timestamps around the action of checking namespace cleanliness,
    to allow the time taken by that action to be measured. (I kept track
    of bootchecks as they happened while working on this diff, and found
    this time to be nontrivial.)
2023-10-05 02:03:47 +11:00
Zoltan Somogyi
7d2a649b66 Implement new machinery in make.dependencies.m.
compiler/make.dependencies.m:
    The task of this module is to find which source files are needed
    to build each target file of an "mmc --make" invocation.
    (In this case, "source" and "target" files mean the files
    on the right and left hand sides of a make rule respectively.)

    The original machinery used for this purpose used three-level towers
    of closures, which made the code hard to read and to understand, and
    also made it effectively impossible to change the argument list
    of any of the predicates involved without also making the same change
    to all the other predicates used at the same tower level.

    This diff implements new machinery that replaces the towers of closures
    with

    - explicit data structures, to take over for the data in the closures, and
    - simple code walking over those data structures, to take over for
      the code in the closures.

    The new machinery is intended to replace the old machinery after
    a trial period of a week or two. Until then, we execute all operations
    using both the old and the new machinery, and compare their outputs.
    During a bootcheck in csharp grade, the comparisons detect differences
    only in about half a dozen test cases, and it is not clear whether
    they are actually due to the new machinery doing different things
    than the old machinery, or due to the same actions being repeated.

    Note that some of the infrastructure used by both sets of machinery
    still uses the old approach; switching it over to the new approach
    is future work.

    The new machinery also lacks (most of) the caches used by
    the old machinery. Adding caches to the new machinery is also future work,
    because the new machinery is more flexible in *what* can be cached
    reasonably conveniently, and therefore it is not clear whether the
    set of things cached by the old machinery is also the best set of
    things for the new machinery to cache.

    The execution of both machineries and this lack of caching by
    the new machinery will affect performance for probably a couple of weeks.

    Add comments marked with "XXX MDNEW" about ideas for future improvements.

    Add infrastructure to debug both this diff, and some other issues.

compiler/make.find_local_modules.m:
    Add infrastructure to debug some other issues.

tools/bootcheck:
    Delete the tests/*/Mercury directories before starting the execution
    of the test suite. Without this, the files left in there by one bootcheck
    can influence the outcome of the next bootcheck.

    Change the naming scheme we use to record the timestamp of files
    in the TEST_FAILS directory. The old scheme included colon characters,
    which don't play nice with some of my personal scripts :-(
2023-10-02 18:14:41 +11:00
Zoltan Somogyi
ad34bf8d84 Ignore expected stage 2/3 differences for java.
tools/bootcheck:
    Ignore differences between the stage 2 and stage 3 .java files
    where those differences are caused by the fact that the stage 1
    compiler, when generating the stage 2 .java files, is not allowed
    to evaluate calls to int.\ (the one's complement operator)
    at compile time, due to the host machine having 64 bit ints
    and the java target having 32 bit ints.
2023-09-07 08:54:27 +10:00
Zoltan Somogyi
e361ab8fe4 Ignore expected stage 2/3 differences for csharp.
tools/bootcheck:
    Ignore differences between the stage 2 and stage 3 .cs files
    where those differences are caused by the fact that the stage 1
    compiler, when generating the stage 2 .cs files, is not allowed
    to evaluate calls to int.\ (the one's complement operator)
    at compile time, due to the host machine having 64 bit ints
    and the csharp target having 32 bit ints.
2023-09-06 16:22:34 +10:00
Zoltan Somogyi
6d00821f0d Represent environments using a bespoke type.
compiler/mlds.m:
    Add the type mlds_env_defn, which is a version of mlds_class_defn
    that is specialized to represent the environment structures we use
    in the MLDS backend to implement model_non continuations. The original
    mlds_class_defn has 13 fields; mlds_env_defn has only three. This
    difference effectively encodes a whole lot of invariants about
    environments. Not only does it omit fields of mlds_class_defns
    that are always the same for all environments, it also omits
    fields of mlds_class_defns that can differ between target languages
    but which are always the same for any given target language.
    These differences are implemented by mlds_to_*_class.m.

    Add mlds_env_id as a new type to represent the ids of environment
    structures.

    Add mlds_env_type as a new function symbol in the mlds_type type
    to represent the type of environment structures.

    Include a list of mlds_env_defns in the MLDS representation of the
    translated module.

compiler/ml_elim_nested.m:
    Generate mlds_env_defns instead of mlds_class_defns to represent
    environment structures.

compiler/mlds_to_c_class.m:
compiler/mlds_to_cs_class.m:
compiler/mlds_to_java_class.m:
    Add code to write out mlds_env_defns. In each case, this code is
    a version of the code to write out mlds_class_defns, specialized
    to the invariants of environment structures.

compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
    Call the new code in mlds_to_X_class.m.

compiler/ml_rename_classes.m:
    Add utility predicates for operating on environment structures.

compiler/mercury_compile_mlds_back_end.m:
compiler/ml_accurate_gc.m:
compiler/ml_lookup_switch.m:
compiler/ml_simplify_switch.m:
compiler/ml_top_gen.m:
compiler/mlds_dump.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_export.m:
compiler/mlds_to_c_stmt.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_cs_data.m:
compiler/mlds_to_cs_type.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_type.m:
    Conform to the changes above.

tools/bootcheck:
    Redirect the input of mmake in each test directory to come from
    /dev/null, to avoid bootchecks in the Java grade being temporarily
    suspended for input from the terminal.
2023-07-14 03:48:22 +02:00
Julien Fischer
d250940f94 Update bootcheck script.
tools/bootcheck:
    The gc.mak file in the boehm_gc directory no longer
     exists.
2023-07-12 21:23:17 +10:00
Julien Fischer
0e8ad1ea39 Fixes for the bootcheck script on Windows.
tools/bootcheck:
    Fix the setting of the WORKSPACE variable when running the tests.
    Due to incorrect use of pwd it was actually pointing back at stage 1.

    If we are running under MSYS2, then set --windows automatically.
    (It's too easy to forget to do this otherwise.)

    Mention this in the documentation for the --windows option. Also,
    the --windows option does not imply anything about the library
    extension -- despite what the usage message has claimed for many
    years.
2023-07-09 20:27:20 +10:00
Julien Fischer
cabc3d016b Delete stage 2 .obj files.
tools/boocheck:
    As above.
2023-06-29 13:54:59 +10:00
Julien Fischer
adda9be7ea Fix misformed option name.
tools/bootcheck:
    As above.
2023-06-17 20:56:09 +10:00
Julien Fischer
78a61dfa23 Make the test suite work with MSYS2.
tools/bootcheck:
    On MSYS2, translate paths written to .options and _FLAGS files into
    Windows-style paths.

    On MYS2, pass -u and --strip-trailing-cr to diff.
2023-06-13 21:19:41 +10:00
Zoltan Somogyi
8df602b2da Simplify keeping track of test failures.
tools/bootcheck:
    If a directory named TEST_FAILS exists in the top level directory.
    copy tests/UNEXPECTED_FAILED_TESTS to that directory, with a name
    that contains (a) the grade, and (b) the date and time. A diff between
    two of these files with the same grade but different times will make
    it easy to see which test failures are *new*.
2023-05-08 22:09:24 +10: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
Julien Fischer
feb8b49b54 Avoid a warning from shellcheck.
tools/bootcheck:
    As above.
2022-12-31 13:37:59 +11:00
Zoltan Somogyi
86657c4b01 Minor style fixes. 2022-12-31 06:48:25 +11:00
Julien Fischer
0153d38646 Do not hardcode sed in the bootcheck script.
tools/bootcheck:
    Allow the executable name used for sed to be overridden
    in the environment. (This is useful for using the GNU
    version of sed on macOS instead of the one it ships with.)
2022-12-30 18:23:31 +11:00
Julien Fischer
d6355e85ee Reduce warnings from shellcheck in the bootcheck script.
tools/bootcheck.java:
    Use $(...) in preference to `...` for command substitutions.

    Quote variables.

    Abort if we attempt to rm / due to a variable not being set.
2022-12-30 16:17:01 +11:00
Julien Fischer
8a61889a6f Fix typo.
tools/bootcheck:
    As above.
2022-06-08 00:09:05 +10:00
Julien Fischer
ec24cfaa22 Simplify bootcheck script.
tools/bootcheck:
     Delete support for checking out the tests directory alongside
     the Mercury source tree. This was useful back when we used
     CVS, but has not been relevant since the switch to git.
2022-03-15 14:41:39 +11:00
Zoltan Somogyi
115b2f20f0 Avoid "stage 2 and stage 3 differ" messages ...
... during bootchecks in C# and Java grades by not comparing the generated
.cs and .java files of the few modules that are known to differ between
the two stages for understood reasons.
2022-03-12 21:42:44 +11:00
Julien Fischer
3040c40c47 Another fix for non-C bootchecks.
tools/bootcheck:
    Build stage 3 flags files with --use-mmc-make.
2022-02-05 00:47:38 +11:00
Julien Fischer
fc347cf998 Fix bootchecks in non-C grades.
tools/bootcheck:
    Add a missing line continuation.
2022-02-04 23:34:10 +11:00
Zoltan Somogyi
adf6c55847 Shut up mmake actions for check_namespace.
This reduces the size of the output of tools/bootcheck by 3700+ lines,
or about 25%.

Mmake.common.in:
    Don't print the actions implementing namespace cleanliness checks.
    To allow the attribution of any violations of the namespace rules,
    print the name of the C module before any list of detected
    nonallowed symbols.

    To avoid mmake printing the actions for creating the .o files
    that some of the check_namespace actions later check, rename
    the affected object files .pseudo_o files, so that we can specify
    a rule for them that is a copy of the rule for .o files, differing
    only in not printing the compilation command.

    Mark the files involved in check_namespace actions as dependencies
    of .SECONDARY, which means that mmake does not automatically delete them
    after building them as intermediate files. The reason for this is that
    there is no way to tell make to delete intermediate files *silently*,
    i.e. without writing out the rm command that deletes them.
    To make up for this, tools/bootcheck now cleans up each directory
    immediately after "mmake check_namespace" with "mmake clean_check",
    which invokes mmake rules that do not print the rm commands.

    This change does have the effect that these intermediate files *will*
    hang around if the check_namespace target is every invoked manually.
    However,

    - we just about never run check_namespace in a directory manually, and
    - when we do, a simple "mmake clean_check" will do the required cleanup.

scripts/Mmake.rules:
    Move the vim tag line to its usual place at the top.

    Replace old-school rules such as .m.err with their modern equivalents
    (such as %.err: %.m).

scripts/Mmakefile:
    Instead of printing the rules that make test_mdbrc, print only a
    "making test_mdbrc" message.

runtime/Mmakefile:
    Conform to the change of the name of a make variable in Mmake.common.in.

ssdb/Mmakefile:
    Fix an old bug that something else in this diff tickled: make the
    .depend target of each main module depend on SSDB_FLAGS, *not* just
    the phony general "depend" target. This was a bug because tools/bootcheck

    - copied across to stage 2 ONLY SSDB_FLAGS.in, and NOT SSDB_FLAGS,

    - did NOT explicitly make SSDB_FLAGS from SSDB_FLAGS.in, even though
      pretty much invocations of the Mercury compiler in this directory
      have "--flags SSDB_FLAGS" as an implicit argument, and then

    - built dependencies in the ssdb directory by invoking the top
      Mmakefile's dep_ssdb target, which (indirectly) invokes
      $(SSDB_LIB_NAME).depend.

    Due to all the above, I don't actually know how tools/bootcheck
    could ever build stage2/ssdb until now :-(

tools/bootcheck:
    Invoke "mmake clean_check" after each "mmake check_namespace".

    Change the code that explicitly builds the directory-specific
    X_FLAGS file in each directory (which is invoked only when using
    mmc --make) to actually build all such files, when previously
    it built only a subset.

tests/invalid/Mmakefile:
tests/invalid_nodepend/Mmakefile:
tests/invalid_onlydepend/Mmakefile:
tests/invalid_options_file/Mmakefile:
tests/invalid_purity/Mmakefile:
tests/invalid_submodules/Mmakefile:
tests/stm/Mmakefile:
    Fix an unintended consequence of replacing the .m.err rule in
    scripts/Mmake.rules with %.err: %.m, which is that the %.err: %.m
    rules in these mmakefiles became ineffective, because they appear
    in the makefile we construct *after* the rule in scripts/Mmake.rules,
    which specify a different action (the rules here return a nonzero
    status in the *absence* of failure, which would be ridiculous
    for the rule in scripts/Mmake.rules). Apparently, the %.err: %.m rules
    overrode the rule in scripts/Mmake.rules while it had the old form,
    but do not do so now it has the new form.

    The fix is to make replace all the "%.err: %.m" rules in these Mmakefiles
    with "$(PROGS:%=%.err): %.err: %.m" rules, which specify that they
    override the generic rule for the .err files of the test cases
    in each directory.

    In invalid_purity/Mmakefile, fix a bug: -nodepend suffixes make sense
    in only in the name of a *test*, not the name of a *program*, so
    move such a suffix from a program name to a test name. Without this,
    the program's .err file would be included in the list of .err files
    to which the ".err: .m" rule applies under the wrong name.

    In invalid_submodules/Mmakefile, fix the misleading names of some
    make variables, and fix a misspelt directory name.

    Standardize on "$(PROGS:%=%.err)" notation, replacing earlier instances
    of "$(addsuffix .err,$(PROGS))". The reason for this is that when I tried
    using "$addsuffix .int_err,$(PROGS))" in tests/invalid/invalid_make_int,
    it did not work. (A google search on "gnu make addsuffix" did not yield
    any clues as to why. Maybe you can only add suffixes that do not contain
    underscores?)
2022-01-24 17:38:35 +11:00
Zoltan Somogyi
be03537f10 Set up for --warn-stdlib-shadowing.
This diff does not implement the option itself. The reason is that we want
to turn it off in library/LIB_FLAGS.in, and we can do that only when the
installed compiler knows about the option. This diff is therefore the first
step in the two-step bootstrapping process.

compiler/options.m:
    Add a new option --warn-stdlib-shadowing, which, after the bootstrapping
    step, will cause the compiler to warn about module names that could be
    confused with the name of a module in the Mercury standard library.

    Add a new option, --output-stdlib-modules, that tools/bootcheck can use
    to test whether the compiler's list of Mercury standard library modules
    is complete.

    Rename the option name output_class_dir to output_java_class_dir
    (internally only, leaving the user-visible name unchanged), to fit in
    with the names of options related to C#, which have csharp in the name.

compiler/op_mode.m:
    Add a new op_mode for --output-stdlib-modules.

compiler/mercury_compile_main.m:
    Implement the new op_mode, using new code in library/library.m.

    Simplify some existing code.

library/library.m:
    Add an exported but undocumented predicate that mercury_compile_main.m
    can use to

    - find a list of all the Mercury standard library modules, and
    - find out for each whether it is documented or not.

    Reimplement the existing exported-but-undocumented predicate
    in terms of the new one.

library/Mmakefile:
    Add mmake targets that check whether the contents of MODULES_DOC and
    MODULES_UNDOC match the output of mmc --output-stdlib-modules.

tools/bootcheck:
    Use the new mmake targets to do that check.
2021-12-31 00:57:18 +11:00
Zoltan Somogyi
6413b4fb08 Create invalid_nodepend and invalid_onlydepend.
tests/invalid_onlydepend:
    Move the one test case in tests/invalid for which we want to check
    the error messages generated during the generation of dependencies
    to this new test directory.

tests/invalid_nodepend:
    Move all test cases in tests/invalid which get errors during the
    generation of dependencies but for which we want to check the error
    messages generated during normal compilation to this new test directory.

tests/invalid_nodepend/Mmakefile:
tests/invalid_nodepend/Mercury.options:
tests/invalid_onlydepend/Mmakefile:
tests/invalid_onlydepend/Mercury.options:
    Versions of the same files in tests/invalid, but containing only
    the entries relevant to the moved test cases.

tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
    Delete the entries that refer to the moved test cases.

tests/README:
    Document the two new test directories.

tools/bootcheck:
    Add invalid_onlydepend and invalid_nodepend to the list of
    test directories.
2021-07-28 00:59:04 +10:00
Zoltan Somogyi
439eecf23d Make --test-params the default for bootchecks. 2021-07-27 14:41:38 +10:00
Zoltan Somogyi
6b4712a2fa Report error if specified test dir does not exist. 2021-07-25 14:19:18 +10:00
Peter Wang
c4c840cb7e Delete Erlang backend from configure.
configure.ac:
m4/mercury.m4:
    Delete --enable-erlang-grade configure option.

    Don't search for erlang compiler and interpreter.

    Don't substitute @ERLC@ and @ERL@.

    Don't add erlang to libgrades.

    Don't generate erlang_conf.hrl

library/erlang_conf.hrl.in:
    Delete template file.

.dockerignore:
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/.gitignore:
library/Mmakefile:
library/library.m:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
scripts/Mercury.config*.in:
scripts/mercury_config.in:
scripts/prepare_install_dir.in:
ssdb/SSDB_FLAGS.in:
tools/bootcheck:
    Delete references to Erlang .hrl files.

    Delete references to @ERLC@ and @ERL@.
2020-10-27 11:10:11 +11:00
Zoltan Somogyi
409cbcb6a3 Unify getopt.m and getopt_io.m ...
... using an approach proposed by Peter, with an extra twist from Julien.

Instead of having two modules, getopt.m and getopt_io.m, with the former
defining predicates that do not take an I/O state pair, and the latter
defining predicates that do take an I/O state pair, put both kinds of
predicates into a single module. The versions with an I/O state pair
have an "_io" suffix added to their names for disambiguation.
Both versions are a veneer on top of a common infrastructure,
which relies on a simple type class to implement the operation
"give the contents of the file with this name". The predicate versions
with I/O state pairs have a normal implementation of this typeclass,
while the predicate versions that do not have I/O state pairs
have an implementation that always returns an error indication.

The above change just about doubles the number of exported predicates.
We already had two versions of most exported predicates that differed
in whether we returned errors in the form of a string, or in the form
of a structured representation, with names of the latter having
an "_se" suffix. Since we agreed that the structured representation
is the form we want to encourage, this diff deletes the string versions,
and deletes the "_se" suffix from the predicate names that used to have them.
(It still remains at the end of the name of a type.) This "undoubling"
should offset the effect of the doubling in the previous paragraph.

Eventually, we want to have just one module, getopt.m, containing
the updated code described above, but for now, we put the same code
into both getopt_io.m and getopt.m to prevent too big a shock to
people with existing code that uses getopt_io.m.

library/getopt.m:
library/getopt_io.m:
    Make the changes described above.

library/Mmakefile:
    Instead of building both getopt_io.m and getopt.m from getopt_template,
    build getopt.m from getopt_io.m.

tools/bootcheck:
    Delete references to getopt_template.

compiler/typecheck_errors.m:
    When a type error involves one of the getopt/getopt_io predicates
    whose interfaces are changed by this diff, tell the user about
    how these changes could have caused the error, and thus what the
    probable fix is.

compiler/handle_options.m:
browser/parse.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_dump.m:
deep_profiler/mdprof_procrep.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/mdprof_test.m:
profiler/mercury_profile.m:
slice/mcov.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
tests/hard_coded/space.m:
    Use the updated getopt interface.

compiler/compile_target_code.m:
compiler/compute_grade.m:
compiler/deforest.m:
compiler/det_report.m:
compiler/format_call.m:
compiler/globals.m:
compiler/goal_expr_to_goal.m:
compiler/make.build.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_main.m:
compiler/ml_top_gen.m:
compiler/module_cmds.m:
compiler/op_mode.m:
compiler/optimization_options.m:
compiler/options.m:
compiler/write_module_interface_files.m:
tools/make_optimization_options_middle:
tools/make_optimization_options_start:
    Replace references to getopt_io.m with references to getopt.m.

tests/invalid/getopt_io_old.{m,err_exp}:
tests/invalid/getopt_old.{m,err_exp}:
tests/invalid/getopt_old_se.{m, err_exp}:
    New test cases for the extra help

tests/invalid/Mmakefile:
    Enable the new test cases.
2020-10-09 19:30:46 +11:00