Commit Graph

1005 Commits

Author SHA1 Message Date
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
Peter Wang
94e2ef3f2c Delete unnecessary test for sa_sigaction field.
configure.ac:
    Delete check for sa_sigaction field. If a call to sigaction()
    has the SA_SIGINFO flag set then the handler must be specified in
    the sa_sigaction field, not the sa_handler field.

runtime/mercury_conf.h.in:
    Delete MR_SIGACTION_FIELD macro.

runtime/mercury_signal.c:
    Don't use MR_SIGACTION_FIELD macro.

    Don't define dummy value for SA_SIGINFO.

tools/configure_mingw_cross:
    Don't set now-unused variable.
2020-10-13 13:32:32 +11:00
Peter Wang
388938ac1e Delete use of signal handlers taking sigcontext arguments.
The configure checks for sigcontext (aka sigcontext_struct) have failed
for a long time without anyone noticing. The MR_GET_FAULT_ADDR macro
that is also needed for the sigcontext code paths was only ever defined
for __i386__ and __mc68000__.

According to the sigaction(2) man page, the struct sigcontext
argument was obsoleted by the introduction of the SA_SIGINFO flag
(which we also have code for, though also not working either).

configure.ac:
    Delete checks related to struct sigcontext.

    Delete check for asm/sigcontext.h

runtime/mercury_conf.h.in:
    Delete macros that are no longer defined.

runtime/mercury_memory_handlers.c:
runtime/mercury_signal.c:
runtime/mercury_signal.h:
    Delete code for using signal handlers that take a sigcontext argument.

    Add XXX where native GC casts a context parameter to
    struct sigcontext * when it should be a ucontext_t *.
    Possibly never tested.

runtime/mercury_faultaddr.h:
    Delete this file containing only the MR_GET_FAULT_ADDR macro which is
    no longer used.

runtime/RESERVED_MACRO_NAMES:
ssdb/RESERVED_MACRO_NAMES:
trace/RESERVED_MACRO_NAMES:
    Delete macros that are no longer defined.

tools/configure_mingw_cross:
    Don't need to set variables mercury_cv_sigcontext_struct_2arg and
    mercury_cv_sigcontext_struct_3arg any more.
2020-10-13 13:32:32 +11:00
Zoltan Somogyi
39377c939e Commit to the new build_srcdist.
tools/build_srcdist:
    Delete the old build_srcdist, and rename build_srcdist2 as build_srcdist.
    Make it refer to the tar target designed for it, tar2, under its new name
    tar.

Mmakefile:
    Delete the old tar target (which worked with the old build_srcdist),
    and rename the old tar2 target (which works with the new build_srcdist)
    as just plain tar.
2020-10-11 22:22:55 +11:00
Zoltan Somogyi
d493841c99 Move imports from interface to implementation. 2020-10-11 11:44:13 +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
Zoltan Somogyi
223c6eddbc Break up a large predicate to avoid JVM limits.
tools/make_optimization_options_middle:
    Generate a separate predicate for each arm of the switch
    in update_opt_tuple that handles a bool or int option.
    These form the vast majority of switch arms. This means that
    so that the Java code we generate for update_opt_tuple,
    which used to break the 64k limit on the maximum bytecode size
    of a method (Mantis bug #522), should not break it anymore.

compiler/optimization_options.m:
    Rebuild the contents of this file using the updated generator script
    above.
2020-10-09 05:11:22 +11:00
Zoltan Somogyi
cf22c0af9a Fix typo. 2020-10-06 23:10:09 +11:00
Zoltan Somogyi
be3f9443b1 Simplify the setup of mdbrc for tests.
We used to set up *two* mdbrc files for use by test cases:
scripts/test_mdbrc, and tests/mdbrc. Tools/bootcheck said
the tests should use the former, while tests/Mmake.common
said they should use the latter. This diff deletes the latter,
and uniformly uses the former.

The setup code was also scattered, with parts being done by
the configure script, and part being done by tools/bootcheck.
Move it all to scripts/Mmakefile, since that is the natural
place to put code to build scripts/test_mdbrc.

Mmakefile:
    Fix the action for cleaning up the tests directory.
    This started out as the reason for this whole change.
    As it happens, a *working* action for cleaning up the tests
    broke things, because it deleted an autoconfigured file
    (tests/mdbrc) that there was no rule for rebuilding.
    This issue is what required the rest of this diff.

    When doing "mmake clean/realclean", clean the extras as well.

configure.ac:
    Delete the code creating tests/mdbrc.in.

scripts/Mmakefile:
    Add a rule to build test_mdbrc, as mentioned above.

tests/Mmake.common:
    Switch to using scripts/test_mdbrc in test cases
    run under mdb.

    Mark the rules that clean up mdbrc and mdbrc.in
    as obsolete, since we will now stop creating those files.

tools/bootcheck:
    Delete the code that used to build tests/mdbrc. Instead,
    rebuild scripts/test_mdbrc (in case the workspace was moved),
    and use that.

tests/Mmakefile:
    When cleaning the tests directory, clean its subdirectories
    (since the top level directory does not have much clean).
2020-10-04 23:00:29 +11:00
Zoltan Somogyi
91560d2dd7 Make --everything-in-one-c-function a bool option.
It used to be a special option that just set procs_per_c_function
to the special value of zero, but this behavior is inconsistent with
optimization_options taking the max of the old and new values of
integer options. This meant that --procs-per-c-function=5 -O6
would not put all procedures into one C function.

tools/make_optimization_options_db:
tools/make_optimization_options_end:
compiler/optimization_options.m:
    As above: make --everything-in-one-c-function a bool option,
    named use_just_one_c_func for brevity.

compiler/options.m:
    Move the code handling --everything-in-one-c-function next to the
    other optimization options.

compiler/mercury_compile_llds_back_end.m:
    When deciding which procedures should be put into which C functions,
    use the logic: if use_just_one_c_func, then put all procs into the
    same C function, otherwise, put them into one or more C functions
    with up to procs_per_c_function procedures per function.

    This is now the *only* place in the compiler that looks at
    procs_per_c_function; everywhere else looks at use_just_one_c_func.

compiler/code_util.m:
    Replace a maybe pair type that used to store the value of
    procs_per_c_function with a bespoke type storing use_just_one_c_func,
    which documents its meaning.

compiler/code_info.m:
    Replace a bool type with a bespoke type, again documenting
    its meaning.

compiler/call_gen.m:
compiler/closure_gen.m:
compiler/middle_rec.m:
compiler/pragma_c_gen.m:
compiler/proc_gen.m:
compiler/rtti_out.m:
    Conform to the changes above.

compiler/llds.m:
    Fix blank lines.
2020-09-29 10:25:42 +10:00
Zoltan Somogyi
81cddd5572 Make --optx=N work after -O... sets it to >N.
tools/make_optimization_options_middle:
tools/make_optimization_options_end:
    Differentiate between an option being set explicitly and an option
    being set implicitly by -O<N>. In the explicit case, always set integer
    values exactly as they are, which allows such options to both increase
    and decrease their values. In the implicit case, set the maximum of
    the old and new values, which allows -O<N> to increase their values
    but not to decrease them.

compiler/optimization_options.m:
    Update the auto-generated code.
2020-09-28 18:42:36 +10:00
Zoltan Somogyi
181ada0dbf Avoid -O<n> resetting previously set options.
This implements Mantis feature request #495.

NEWS:
    Announce the change.

compiler/optimization_options.m:
    A new module for managing optimization options.

    It defines a separate bespoke type for every boolean optimization option
    to make it harder to confuse them. It defines a tuple type (opt_tuple)
    for accessing optimization options quickly. It implements the turning on
    (but NOT turning off) of optimizations when a given optimization level
    is selected.

tools/make_optimization_options_middle:
tools/make_optimization_options_db:
    The script that generates the meat of optimization_options.m,
    and the database of option names, kinds and initial values
    that it uses as its input. The script also generates some code
    for the special_handler predicate in compiler/options.m.

tools/make_optimization_options_start:
tools/make_optimization_options_end:
    The handwritten initial and final parts of optimization_options.m.

tools/make_optimization_options:
    The script that pulls these parts together to form optimization_options.m.

compiler/options.m:
    Make every optimization option a special option, to be handled by
    the special_handler predicate. That handling consists of simply
    adding a representation of the option to the end of a cord of
    optimization options, to be processed later by optimization_options.m.
    That processing will record the values of these options in the opt_tuple,
    which is where every other part of the compiler should get them from.

    Change the interface of special_handler to make the above possible.

    Add an "optopt_" (optimization option) prefix to the name of
    every optimization option, to make them inaccessible to the rest
    of the compiler under their old name, and thus help enforce the switch
    to using the opt_tuple. Any access to these options to look up
    their values would fail anyway, since the option data would no longer be
    e.g. bool(yes), but bool_special, but the name change makes this failure
    happen at compile time, not runtime.

    Reclassify a few options to make the above make sense. Some options
    (unneeded_code_debug, unneeded_code_debug_pred_name, and
    common_struct_preds) were classified as oc_opt even though they
    control only the *debugging* of optimizations, while some options
    (c_optimize and inline_alloc) were not classified as oc_opt
    even though we do set them automatically at some optimization levels.

    Delete the opt_level_number option, since it was not used anywhere.

    Delete the code for handling -ON and --opt-space, since that is now
    done in optimization_options.m.

    Add some XXXs.

compiler/handle_options.m:
    Switch to using getopt_io.process_options_userdata_se, as required
    by the new interface of the special_handler in options.m.
    In the absence of errors, invoke optimization_options.m to initialize
    the opt_tuple. Then update the opt_tuple incrementally when processing
    option implications that affect optimization options.

compiler/globals.m:
    Put the opt_tuple into a new field of the globals structure.

compiler/accumulator.m:
compiler/add_pragma_type_spec.m:
compiler/add_trail_ops.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/compile_target_code.m:
compiler/const_struct.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/disj_gen.m:
compiler/erl_code_gen.m:
compiler/format_call.m:
compiler/global_data.m:
compiler/grab_modules.m:
compiler/higher_order.m:
compiler/hlds_pred.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/ite_gen.m:
compiler/jumpopt.m:
compiler/libs.m:
compiler/llds_out_code_addr.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_instr.m:
compiler/llds_out_util.m:
compiler/matching.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/mercury_compile_mlds_back_end.m:
compiler/ml_disj_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_optimize.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/optimize.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/proc_gen.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_scope.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/simplify_tasks.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/tag_switch.m:
compiler/tupling.m:
compiler/unify_gen_construct.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
    Conform to the changes above, mostly by looking up optimization options
    in the opt_tuple. In some places, replace bools containing optimization
    options with the bespoke type of that specific optimization option.

library/getopt_template:
    Fix a bug that screwed up an error message.

    The bug happened when processing a --file option. If one of the
    options in the file was a special option whose special handler failed,
    the code handling that failing option returned both an error indication,
    and the rest of the argument list read in from the file. The code
    handling the --file option then *ignored* the error indication from
    the failed special option, and returned an error message of its own
    complaining about the unconsumed remaining arguments in the file,
    believing them to be non-option arguments, even though these arguments
    were never looked it to see if they were options.

    The fix is for the code handling --flag options to check whether
    the code processing the file contents found any errors, and if so,
    return that error *without* looking at the list of remaining arguments.

    In an unrelated change, factor out a duplicate call.
2020-09-28 18:16:13 +10:00
Zoltan Somogyi
2cf8818d0e Make source distribution building less error-prone.
tools/build_srcdist2:
    A new version of the existing build_srcdist script that does *not*
    destroy the workspace it is invoked in by deleting from it
    the files we don't want to put into the source distribution's tar file.
    Instead, it makes a copy of a named workspace, deletes the unwanted
    files only from that copy, and puts the generated tar file where its
    caller wants it to go.

    Unlike the old build_srcdist, build_srcdist2 leaves deciding on the
    version name, and compressing the tar file, to its invoker. This is
    because the invoker has to know the tar file name, and hence the
    version name anyway, and it is simpler to test whether xz compression
    is available in the invoker only, rather than in both build_srcdist2
    and the invoker (since the invoker can't e.g. move a .xz file
    that does not exist).

Mmakefile:
    Add a new variant of the "make tar" target that conforms to
    the expectations of the new build_srcdist2 script.
2020-09-20 22:53:42 +10:00
Julien Fischer
b3d4fad5bb Do not symlink getopt*.m into stage 2.
tools/bootcheck:
    As above.
2020-09-20 21:55:36 +10:00
Zoltan Somogyi
6d91b39230 Update programming style. 2020-09-19 08:25:31 +10:00
Zoltan Somogyi
dd8424045f Ensure the building of getopt.m and getopt_io.m.
library/Mmakefile:
    Ensure that getopt.m and getopt_io.m are built in freshly checked out
    workspaces before starting making the dependencies.

    Include getopt_template as a source file when building the tags file.

tools/bootcheck:
    Copy getopt_template to the stage 2 and 3 libraries, to allow
    the rule for ensuring the existence of the tags file to work.
2020-09-19 07:30:08 +10:00
Zoltan Somogyi
155fbdd7fd Make programming style consistent. 2020-08-09 20:31:46 +10:00
Zoltan Somogyi
c644e8d19f Consistently ${var} instead of $var. 2020-06-13 22:17:28 +10:00
Zoltan Somogyi
ac50b3cbd1 Do not use exceptions in options_file.m.
And add tests for how the compiler handles both valid and invalid
options files.

compiler/options_file.m:
    This diff rewrites options_file.m in a straightforward, direct style that
    returns indications of errors as error_specs rather than as exceptions.
    A recent diff started on this task; this diff finishes it.

    The new approach has several advantages.

    - The control flow is much simpler, and therefore more understandable.
      Correctness arguments for propositions such as "this code closes
      all the file streams that it opens" are now much simpler to make.

    - We now report errors using error_specs, which contain context
      information, while previously, each error was described only
      by a string, without context info.

    - Once we detect and report one error, we can continue to read the
      rest of the input. This allows a single compiler invocation to find
      and report several errors, not just the first.

    - Since we now return the gathered set of error_specs instead of printing
      them, the predicates of this file don't have to take globals structures
      as arguments, which allows our callers to avoid constructing those
      structures.

    - Deep profiling, which cannot handle exceptions, now works on
      the code of this module.

    Change over to using trace goals for debugging prints, since continuing
    to use debug_make_msg would require a globals structure.

    Add an XXX on a likely bug.

    Add a mechanism for writing out a database of variable names and values.

compiler/mercury_compile_main.m:
    Conform to the changes in options_file.m. Document where exactly
    we could avoid constructing a globals just for options_file.m.

    If the right option is given, get options_file to write out the database
    of variable names and values it has just read in, to enable the
    functionality of this module to be tested.

compiler/options.m:
doc/user_guide.texi:
    Add a new developer option, --dump-options-file, to control the above.

compiler/make.build.m:
compiler/make.m:
compiler/make.program_target.m:
    Conform to the changes in options_file.m.

compiler/file_util.m:
    Fix an error message.

tests/Mmakefile:
tools/bootcheck:
    List options_file and invalid_options_file as two new test directories.

    Fix a command in bootcheck.

tests/options_file/Mmakefile:
    Add a mechanism for testing whether options_file.m builds mapping
    from make variable names to values that we expect.

tests/Mmake.common:
    Provide a mechanism for comparing dumped options_files against
    their expected contents, for use by tests/invalid_options_file/Mmakefile.

    Fix a comment.

tests/options_file/basic_test.m:
tests/options_file/basic_test.optfile_exp:
tests/options_file/basic_test.options_file:
tests/options_file/basic_test.options_file.sub0:
tests/options_file/basic_test.options_file.sub1:
    A simple test case for exercising all the usual options_file constructs.

tests/invalid_options_file/Mmakefile:
    Add a mechanism for testing whether options_file.m generates
    the error messages we expect for various kinds of errors in options files.

tests/invalid_options_file/no_assign.{m,options_file,err_exp}:
tests/invalid_options_file/no_var.{m,options_file,err_exp}:
tests/invalid_options_file/nonexistent_file.{m,options_file,err_exp}:
tests/invalid_options_file/undefined_var.{m,options_file,err_exp}:
tests/invalid_options_file/unterminated_string.{m,options_file,err_exp}:
tests/invalid_options_file/unterminated_var.{m,options_file,err_exp}:
    Six test cases to test six different kinds of errors that can be
    detected by options_file.m.
2020-06-12 04:14:00 +10:00
Zoltan Somogyi
1f45f91886 Make "mmake runtests" work again.
My commit afe2887882 broke the ability
to run the test suite outside of a bootcheck by executing "mmake runtests"
in the tests directory. This diff fixes that.

tests/Mmake.common:
    Don't define "TESTS_DIR = ..". While every single tests/*/Mmakefile
    defined it as such, I overlooked the fact that tests/Mmakefile itself
    defined it ".", referring to the same directory from a different starting
    point. Document this easily-overlooked fact.

    Rename the old runtests target, which after afe2887 runs the tests
    in a single directory, as runtests_dir, to leave the target name
    "runtests" itself free for tests/Mmakefile to use.

tests/Mmakefile:
    Define "TESTS_DIR = .", and add a target "runtests" which invokes
    "mmake runtests_dir" in each test directory.

tools/bootcheck:
    Invoke "mmake runtests_dir" instead of "mmake runtests" in each
    test directory.

    Initialize a variable just before it is used.

tests/*/Mmakefile:
    Add back the definition "TESTS_DIR = .."
2020-06-10 01:05:15 +10:00
Zoltan Somogyi
fe44a831bd Remove a workaround for NFS. 2020-05-30 23:35:53 +10:00
Zoltan Somogyi
79d81d09d8 Fix bugs and nits pointed out by shellcheck.
scripts/mgnuc.in:
    Delete the unused variables AS, AS_OPTS, HLD_OPTS and ARG_OPTS.
    The first two are hstorical relics, HLD_OPTS lost its raison d'etre
    when we deleted the hl grades; I don't know what we used ARG_OPTS for.

    Make the unused variable CFLAGS_FOR_ANSI used.

    Fix a spelling inconsistency: DEBUG_OPT vs DEBUG_OPTS.

scripts/ml.in:
    Delete the unused variables NONSHARED_LIB_DIR and DL_LIBRARY.

scripts/parse_grade_options.sh-subr:
    Fix typos that prevented an almost-never-used option from working.

scripts/parse_ml_options.sh-subr.in:
    Fix a quoting error.

tools/bootcheck:
    Comment out the definition of an unused variable. (Its parallel
    exists and is used in c2init.in, which is why it is not deleted.)

    Fix typos in spelling SSDB_LIB_NAME.

    Quote a variable value that may contain spaces.

    Replace "cat file | cmd" with "cmd < file".
2020-05-29 21:18:08 +10:00
Zoltan Somogyi
a67a33d639 Specify ft=sh in the vim modeline. 2020-04-28 11:50:33 +10:00
Zoltan Somogyi
58ff05ebaf Allow bootcheck in C# grade after grade_lib changes.
tools/bootcheck:
    Build grade_lib/GRADE_LIB_FLAGS before building stage 2.

    Make dependencies in grade_lib/ before building stage 3.

grade_lib/Mmakefile:
    Get the "make dependencies" step in stage 3 build GRADE_LIB_FLAGS.
2020-04-16 12:01:29 +10:00
Zoltan Somogyi
0c40f3b5f0 Build the grade_lib directory by default.
This should prevent bit rot in its code, such as that caused by the
move of the one_or_more type from list.m to one_or_more.m.

Mmakefile:
    Add grade_lib to the list of directories to build, to the list of
    directories in which dependencies are made, the list of directories
    in which tags files are made, and the list of directories to clean.

    Do not include the grade library in source distributions. In the
    intended use case, the grade library modules that the compiler needs
    will be present in the source distribution in the *compiler* directory.

    Add mfilterjavac to the list of directories for tags files; its former
    absence was an oversight.

    Fix inconsistent indentation.

tools/bootcheck:
    Build the grade library during stages 2 and 3. Compare its stage 2 and 3
    versions as we do for other directories.

    Put the commands that create stages 2 and 3 into recognizable blocks.

grade_lib/Mmakefile:
    Add the targets needed by either by bootcheck or by the top level
    Mmakefile.

    Document the intended usage of the grade library.

grade_lib/.mgnuc_copts:
grade_lib/.mgnuc_opts:
    Use the same .mgnu_*opts files as e.g. the profiler directory.
    The common command sequence used by bootcheck to build the
    stage 2 and 3 directories assumes their presence.

library/Mmakefile:
    Make it clear that some rules previously separated by dividing lines
    are actually related.
2020-04-14 09:35:55 +10:00
Zoltan Somogyi
aea3b98033 Test the process of making .int files.
tests/Mmakefile:
tools/bootcheck:
    Add invalid_make_int and valid_make_int as new test directories.

tests/invalid_make_int/missing_interface_import.m:
tests/invalid_make_int/missing_interface_import.int_err_exp:
tests/invalid_make_int/missing_interface_import.int_err_exp2:
    Move this test case from invalid to invalid_make_int, since it was
    *already* testing the error message we get from "mmc --make-interface".

tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
    Set up testing of whether we get the right error messages during
    the process of making .int files.

tests/Mmake.common:
    Provide a way for tests in invalid_make_int to compare a .int_err file
    against several .int_err_exp* files.

tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
    Delete references to the test case moved to invalid_make_int.

tests/valid_make_int/bug499.m:
    Add the test case that motivated this change.

tests/valid_make_int/Mercury.options:
tests/valid_make_int/Mmakefile:
    Set up testing of whether we can generate .int files for modules.
2020-04-13 04:14:51 +10:00
Zoltan Somogyi
b8b845a568 Fix mmakefile rules for os,cs,css,javas.
The main objective of this change is to get bootchecks in the csharp
and java grades to actually build the slice, profiler, deep_profiler
and mfilterjavac directories, which (due to the bug this diff fixes)
they weren't doing before.

However, since one side effect of this change is to eliminate
one source of annoying warnings from mmake about references to undefined
variables, a subsidiary objective is to eliminate other sources of such
warnings as well, which mostly come from the rules for making tags files.

browser/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
    When creating stage 3, the bootcheck builds, in each directory,
    only the files that it wants to compare against their stage 2 versions.
    This means that it wants to build all the .c, .cs or .java files,
    which it does via the cs, css and javas mmake targets.

    The correct definitions of the rules of these targets depends on
    whether mmc --make is being used or not, so we need at least two
    sets of definitions: one for mmc --make, and for no mmc --make,
    and conditionally selecting the appropriate one. The latter definition
    has the problem that it refers to mmake variables that are intended
    to be defined in .dv files created by mmc --generate-dependencies,
    but until that has been run, those mmake variables are undefined.

    Until now, the only directories that had both the mmc --make
    and the no mmc --make definitions were the ones needed to build
    the compiler. Bootchecks in the csharp and java grades, which
    always use --make make, got errors when they tried to build
    the directories that bootcheck builds after the compiler:
    the slice, profiler, deep_prof and mfilterjavac directories.

    This diff ensures that all directories we build in bootcheck
    get all both versions of the os, cs, css, and javas targets.
    In fact, they get two subversions of the no mmc --make version:
    one for use in the presence of .dv files, and one for use in their
    absence. The latter just builds the .dv files and invokes mmake
    again. This avoids one source of warnings about undefined mmake
    variables.

    To avoid another source, make the rules for tags files and their
    proxies depends on *.m instead of mmake variables such as $(mcov.ms),
    since this makes sense even before making dependencies. The only price
    is that any untracked Mercury source files in the directory have to
    either be given some other suffix, or moved somewhere else.

    Where relevant, make the mtags invocation prefer the master versions
    of files that are copied from the mdbcomp directory to other directories,
    since this is the only writeable version.

    Make the os and cs rules consistently NOT build the _init.[co] files.
    The way we use those files in bootcheck, we never need them;
    when we need them, the right target to give is the executable anyway.

    In the slice directory, don't put mcov between mtc_union and mtc_diff.

    Eliminate unnecessary duplication, e.g. of sources in rules.

    Eliminate double negatives in conditionals.

    Fix formatting.

Mmake.common.in:
bindist/Mmakefile:
bytecode/Mmakefile:
compiler/Mmakefile:
doc/Mmakefile:
grade_lib/Mmakefile:
robdd/Mmakefile:
samples/Mmakefile:
scripts/Mmakefile:
tools/Mmakefile:
trace/Mmakefile:
util/Mmakefile:
    Add "ft=make" to vim modelines. This is redundant for the files whose
    names is Mmakefile, but it is needed for Mmake.common.
2020-04-11 20:10:38 +10:00
Zoltan Somogyi
5ec867b2c5 Added another new tool. 2020-03-25 11:56:31 +11:00
Zoltan Somogyi
778c735524 Added a new tool. 2020-03-24 19:54:29 +11:00
Zoltan Somogyi
c0293832b7 Allow "mmc -C foo.m" when file.m contains module bar ...
... provided the source file map in Mercury.modules records this fact.

compiler/read_modules.m:
    When asked to compile a given file, look up the name of the module
    that we expect to find in that file in Mercury.modules, if it exists,
    instead of just assuming that it corresponds *exactly* to the filename.

compiler/source_file_map.m:
    Provide a predicate to provide the filename-to-modulename lookup
    now needed by read_modules.m. (Previously, we had only modulename-to-
    filename lookup.)

    Make the code constructing some error messages easier to read.

tools/make_arena:
    Copy compiler/Mercury.modules to the arena along with compiler/*.m.
    (The motivation for this change was that I wanted to profile the
    .profdeep compiler in workspace N by simply invoking "lmcN -C *.m"
    in the arena directory.)
2020-03-12 13:53:19 +11:00
Zoltan Somogyi
66aa649378 Keep the .log files of successful tests if requested.
Sometimes, when a test case fails in a workspace even though it has passed
before, it is not clear whether the cause of the failure is that the
updated code in the workspace is generating a different sequence of
mmc invocations, or whether the same invocations do something different.
The new option allows developers to answer that question by keeping the logs
from a bootcheck in an unchanged workspace, and comparing the logs
between the workspaces.

tools/bootcheck:
    If given the --keep-success-log-files option, set an environment variable
    that records this fact.

tests/run_one_test:
    If this environment variable is set, then rename the .log files of
    successful test cases as .kept_log files instead of deleting them.

    Note that we cannot keep the .log files around under their original name,
    because we currently interpret the presence of *any* .log file
    in a test directory as meaning "some tests failed in this test directory".
2020-03-08 13:41:57 +11:00
Zoltan Somogyi
078e1dbfbc Enable the tests in the feedback directory. 2019-08-15 09:15:37 +10:00
Zoltan Somogyi
bd7d7db57d Move nested-module programs from invalid to invalid_submodules.
This is to compile them with "mmake -j1", and thus avoid the intermittent
failures caused by interface files of nested submodules not being ready
when another job, executed in parallel by mmake, wants to read them.

tests/invalid_submodules/children.m:
tests/invalid_submodules/children2.m:
tests/invalid_submodules/duplicate_module.m:
tests/invalid_submodules/duplicate_module_test.err_exp:
tests/invalid_submodules/duplicate_module_test.m:
tests/invalid_submodules/exported_unify3.err_exp:
tests/invalid_submodules/exported_unify3.err_exp2:
tests/invalid_submodules/exported_unify3.m:
tests/invalid_submodules/func_class.err_exp:
tests/invalid_submodules/func_class.m:
tests/invalid_submodules/import_in_parent.err_exp:
tests/invalid_submodules/import_in_parent.m:
tests/invalid_submodules/missing_parent_import.err_exp:
tests/invalid_submodules/missing_parent_import.m:
tests/invalid_submodules/nested_impl_in_int.err_exp:
tests/invalid_submodules/nested_impl_in_int.m:
tests/invalid_submodules/sub_a.m:
tests/invalid_submodules/sub_c.err_exp:
tests/invalid_submodules/sub_c.m:
tests/invalid_submodules/undef_mod_qual.err_exp:
tests/invalid_submodules/undef_mod_qual.m:
tests/invalid_submodules/unresolved_overloading.err_exp:
tests/invalid_submodules/unresolved_overloading.m:
    Move these files, which contain the source code and expected outputs
    of the affected test cases, from the invalid directory to the new
    invalid_submodules directory.

tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
    Delete any mentions of the moved test cases.

    Improve sh programming style in actions.

tests/invalid_submodules/Mercury.options:
tests/invalid_submodules/Mmakefile:
    List *only* the moved test cases. Specify the -j1 flag for mmake.

tests/Mmakefile:
tools/bootcheck:
    Mention the new test directory.

    Request that the list of test directories in these two places be kept
    in sync.

    Note that the feedback test directory is not yet ready.
2019-08-14 23:28:00 +10:00
Zoltan Somogyi
c4df961c86 Move Deep.procrep with Deep.data. 2019-07-29 10:46:34 +02:00
Julien Fischer
8e4fc73fc6 Support parallel bootchecks using --use-mmc-make.
Parallel bootchecks using --use-mmc-make do not currently work because mmake
creates multiple instances of mmc --make per directory and these conflict with
each other.  Modify the bootcheck script so that when --use-mmc-make is
enabled, we do not build affected directories with mmake's -j option but
instead pass the -j option directly to Mercury compiler.

tools/bootcheck:
   As above.
2019-07-09 12:25:23 +10:00
Julien Fischer
d79a07f13a Handle macOS shared libraries in a spot.
tools/bootcheck:
    As above.
2019-07-08 20:54:27 +10:00
Zoltan Somogyi
4bf9dd6ca3 Build more directories in stages 2 and 3.
tools/bootcheck:
    Build the deep_profiler and mfilterjavac directories in stage 2.

    Build the slice, profiler, deep_profiler and mfilterjavac directories
    in stage 3. (We already used to build slice and profiler in stage 2.)

    Compare target language files in the stage 2 and stage 3 versions
    of the slice, profiler, deep_profiler and mfilterjavac directories,
    to make bootcheck a tougher test. This requires copying these directories
    to stage 3, instead of just linking them.

    Don't make dependencies in a directory if we had already done them
    earlier.

mfilterjavac/Mmakefile:
    Add targets for building C# and Java files.

slice/Mmakefile:
    Include the modules of the mcov and mtc_diff programs in the
    existing targets for building C, C# and Java files.

deep_profiler/Mmakefile:
profiler/Mmakefile:
    These makefiles already had targets for building C# and Java files.
    Fix grammar and/or indentation.

compiler/Mmakefile:
    Fix grammar and/or indentation.
2019-06-25 14:22:53 +02:00
Zoltan Somogyi
507ca6c250 Find out which module_and_imports fields are used when.
compiler/module_imports.m:
    We construct module_and_imports structures in three different ways.
    Each way fills in only a subset of the its fields with meaningful
    information. To see whether this is OK, we need to know whether the
    fields filled in with dummies are ever accessed. This diff thus adds
    an extra field to module_and_imports structures that says how they
    were constructed, and if the right compile time flag is set, it records,
    for each construction method, which fields have been accessed.

compiler/mercury_compile_main.m:
    If that same compile time flag is set, append the recorded information
    to a file.

tools/mai_stats:
    This tool summarizes the information in that file.
2019-05-09 21:25:24 +10:00
Peter Wang
987385df21 Add import_srcdist script.
tools/import_srcdist:
    Add script to import a source distribution tarball into the
    mercury-srcdist repository.
2019-02-05 10:21:13 +11:00
Zoltan Somogyi
536fdc3b5f Let "binary" find bugs in the browser, and in nonstandard grades.
tools/binary:
tools/binary_step:
    As above.

    Also, fix some old bitrot.
2019-01-14 09:20:02 +11:00
Zoltan Somogyi
a4e1988366 Add ad-hoc profiling for module name to file name translations.
compiler/file_names.m:
    If the right compile time and runtime flags are set, then record
    each module name to file name translation in a map, and append
    the contents of this map to a central file when asked.

compiler/mercury_compile_main.m:
    Ask file_names.m to do so just before the compiler exits.
    (Unless the right compile time and runtime flags were set,
    this will be a no-op.)

tools/file_name_translation_stats:
    Add this new awk script, whose job is to summarize the new profiling
    information.
2018-10-22 00:54:43 +11:00
Julien Fischer
cabaf551d9 Save the commit id in srcdist packages.
tools/build_srcdist:
    Save the git commit id a srcdist is based upon in a file
    within that srcdist.
2018-07-31 14:48:12 +10:00
Peter Wang
1daf4d6081 Parallelise make_java_csharp_arena_{base,diff}
tools/make_java_csharp_arena_base:
tools/make_java_csharp_arena_diff:
    Use xargs -P to run multiple instances of the compiler in parallel.

    Allow the environment variable PARALLEL to control the number of
    parallel tasks.
2018-07-26 14:54:51 +10:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.

COPYING.LIB:
    Add a special linking exception to the LGPL.

*:
    Update references to COPYING.LIB.

    Clean up some minor errors that have accumulated in copyright
    messages.
2018-06-09 17:43:12 +10:00
Zoltan Somogyi
4ffaa6f573 Don't apply stage 2 settings to stage 1.
tools/bootcheck:
    We compute the values of $use_subdirs and $use_mmc_make based on
    the grade specified for the stage 2 compiler. So use them to set
    the values of MMAKE_USE_SUBDIRS and MMAKE_USE_MMC_MAKE respectively
    only *after* we finished the last mmake invocation on stage 1.
    Setting them *before* then could screw up the stage 1 if it was built
    with different settings of those variables.

    This fixes Mantis #459.
2018-05-06 23:04:24 +02:00
Zoltan Somogyi
4c5831b032 Fix typo. 2018-03-15 23:30:09 +11:00
Peter Wang
dd2a1c2ef5 Avoid which utility.
tools/configure_mingw_cross:
    Use shell builtin `command -v' instead of which(1).
2018-03-07 10:58:22 +11:00
Peter Wang
7f9ca8666b Replace some run-time configure tests with compile-time tests.
m4/mercury.m4:
    Add a macro MERCURY_TRY_STATIC_ASSERT for testing a single
    compile-time expression.

configure.ac:
    Replace some run-time tests (using AC_TRY_RUN) with compile-time
    tests (using MERCURY_TRY_STATIC_ASSERT), allowing said tests to work
    when cross-compiling.

    Delete code handling mercury_cv_bits_per_word = 16;
    we do not support it.

tools/configure_mingw_cross:
    Delete some variables that can now be detected by configure when
    cross-compiling.
2018-03-07 10:58:22 +11:00
Zoltan Somogyi
c855ba6fb7 Don't try to compile modules with bitrot. 2018-03-06 00:59:55 +11:00
Zoltan Somogyi
310048037c Try to guard against future bitrot.
tools/bootcheck:
    Build the dependencies for auxiliary programs, and the programs themselves,
    in the browser and profiler directories.

Mmakefile:
    Provide targets for bootcheck to use to make dependencies for the
    auxiliary programs in the browser and profiler directories.

browser/Mmakefile:
    Take the two aux programs in this directory out of the "all" target.
    Due to past bitrot, one gets errors during compilation, the other
    during linking. (The "all" target is not used by default, which is why
    this has not been a problem.)

    Add depend_aux and aux targets that should build these programs
    if they are ever fixed. The aux target is empty for now; the depend_aux
    target does make dependencies for both aux programs (since that still
    works, and we want to keep it that way).

profiler/Mmakefile:
    Add depend_aux and aux targets that build the one auxiliary program
    in this directory that works now. Add a comment about the other program
    that doesn't.
2018-01-09 01:05:42 +11:00