Commit Graph

931 Commits

Author SHA1 Message Date
Julien Fischer
026148c907 Update and fix copyright notices in the scripts directory.
scripts/*:
    As above.
2020-06-16 17:26:02 +10:00
Julien Fischer
93d7059457 Support 'mercury' as a synonym for 'mmc' on all platforms.
On Windows the name 'mmc' is also used for the executable for Microsoft
Management Console.  For the MSVC port on the Windows command line we have long
provided a batch file named 'mercury' as an alternative to `mmc' in order to
avoid this clash.  (Re-arranging your PATH to avoid the clash is not always an
option.)

Provide a shell script named 'mercury' that serves the same purpose elsewhere.
Its main use is to avoid the name clash on MinGW/MSYS, Cygwin etc., but
making the name available everywhere should avoid unnecessary changes in build
scripts and alike.

Document the issue with the name clash in the appropriate chapter of the user's
guide and also in the top-level Windows README file.

scripts/mercury.in:
     Add a template for the 'mercury' script.

configure.ac:
     Create the 'mercury' wrapper script.

scripts/Mmakefile:
     Add 'mercury' to the list of scripts.

doc/user_guide.texi:
     Add a paragraph describing the 'mmc' name clash on Windows and what
     to do about it.

     Unrelated change: ':' is no longer a module qualifier.

README.MS-Windows:
     Point users to the relevant chapter of the user's guide for ways
     to deal with the `mmc' name clash.

NEWS:
     Announce the addition.
2020-06-16 17:25:44 +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
Julien Fischer
d0ae4d2819 Update the reconfiguration script.
scripts/mercury_config.in:
    As above.
2020-04-14 21:55:34 +10:00
Zoltan Somogyi
1b23b4bc7c Fix a typo in user-facing documentation. 2020-04-13 06:07:29 +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
3e894a7a9d Remove the hl grade component.
As we discussed, it has fallen into disuse. Its main purpose was to
pave the way for the .net backend and later for the java and csharp grades.
Now that the .net backend is ancient history and the java and csharp grades
are established, that purpose is gone, and for every other purpose,
hlc is better because it is simpler and faster.

compiler/options.m:
    Delete the --high-level-data option. It is no longer needed,
    bacause the data representation scheme is now a direct function
    of the target language.

doc/user_guide.texi:
    Delete references to the --high-level-data option.

NEWS:
    Mention that --high-level-data is no longer supported.

compiler/compute_grade.m:
    Delete references to the hl grade component, and conform
    to the deletion of the --high-level-data option.

compiler/compile_target_code.m:
    Give some predicates more meaningful names, and conform to the
    deletion of the --high-level-data option.

compiler/const_struct.m:
compiler/du_type_layout.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/lco.m:
compiler/mercury_compile_main.m:
compiler/ml_gen_info.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_c_util.m:
    Conform to the deletion of the --high-level-data option.

grade_lib/grade_spec.m:
grade_lib/grade_vars.m:
    Delete the datarep solver variable, since the data representation
    is now a direct function of the target language.

    Delete the requirements involving the deleted solver variable.

grade_lib/grade_structure.m:
    Delete the datarep component of the representation of MLDS C grades,
    since its value would now be fixed.

grade_lib/grade_solver.m:
grade_lib/grade_string.m:
grade_lib/try_all_grade_structs.m:
grade_lib/var_value_names.m:
    Conform to the changes above.

grade_lib/Mmakefile:
    Link the grade library's test programs statically, like we do
    the executables in the other directories.

library/io.m:
library/robdd.m:
library/rtti_implementation.m:
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
runtime/mercury_hlc_types.h:
    Remove references to MR_HIGHLEVEL_DATA, as well as any code
    that was guarded by #ifdef MR_HIGHLEVEL_DATA.

scripts/Mmake.vars.in:
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
scripts/mmake.in:
scripts/mmc.in:
scripts/mtc:
scripts/parse_grade_options.sh-subr:
scripts/parse_ml_options.sh-subr.in:
    Remove references to --high-level-data options.

    In canonical_grade.sh-subr, compute the base grade more directly.

    Remove a few left-over references to the assembler backend.

    Add or fix vim modelines where relevant.

    Fix inconsistent indentation.

    Add missing ;;s in case statements.

    Switch to using ${var} references instead of just $var.

tests/invalid/Mercury.options:
    Make the test_feature_set test case run in grade java instead of hl.gc.

tests/invalid/test_feature_set.err_exp:
    Update the expected out for the grade change.
2020-04-11 19:30:58 +10:00
Julien Fischer
467a2c978d Set the executable installation directory using --bindir.
Support setting an alternative executable installation directory using the
configure script's --bindir option.

Patch contributed by Keri Harris.

scripts/Mmake.vars.in:
scripts/mdprof.in:
scripts/mmc.in:
scripts/mprof.in:
    As above.
2020-04-11 03:17:48 +10:00
Zoltan Somogyi
e21a1a1c1c Fix indentation. 2020-04-10 18:28:10 +10:00
Zoltan Somogyi
9789375cc5 Make pre-HLDS passes use file-kind-specific parse trees.
Replacing item blocks file-kind-specific kinds of section markers with
file-kind-specific parse trees has several benefits.

- It allows us to encode the structural invariants of each kind of file
  we read in within the type of its representation. This makes the detection
  of any accidental violations of those invariants trivial.

- Since each file-kind-specific parse tree has separate lists for separate
  kinds of items, code that wants to operate on one or a few kinds of items
  can just operate on those kinds of items, without having to traverse
  item blocks containing many other kinds of items as well. The most
  important consequence of this is not the improved efficiency, though
  that is nice, but the increased clarity of the code.

- The new design is much more flexible. For example, it should be possible
  to record that e.g. an interface file we read in as a indirect dependency
  (i.e. a file we read not because its module was imported by the module
  we are compiling, but because its module was imported by *another* imported
  module) should be used *only* for the purpose it was read in for. This should
  avoid situations where deleting an import of A from a module, because it
  is not needed anymore, leads the compiler to generate an error message
  about a missing import of module B. This can happen if (a) module B
  always *should* have been imported, since it is used, but (b) module A's
  import of module B lead to module B's interface being available *without*
  an import of B.

  Specifically, this flexibility should enable us to establish each module's
  .int file as the single source of truth about how values of each type
  defined in that module should be represented. When compiling each source
  file, this approach requires the compiler to read in that module's .int file
  but using only the type_repn items from that .int file, and nothing else.

- By recording a single parse tree for each file we have read, instead of
  a varying number of item blocks, it should be significantly easier to
  derive the contents of .d files directly from the records of those
  parse trees, *without* having to maintain a separate set of fields
  in the module_and_imports structure for that purpose. We could also
  trivially avoid any possibility of inconsistencies between these two
  different sources of truth. (We currently fill in the fields used to
  drive the generation of .d files using two different pieces of code,
  one used for --generate-dependencies and one used for all other invocations,
  and these two *definitely* generate inconsistent results, as the significant
  differences in .d files between (a) just after an invocation of
  --generate-dependencies and (b) just after any other compiler invocation
  can witness.)

This change is big and therefore hard to review. Therefore in many files,
this change adds "XXX CLEANUP" comments to draw attention to places that
have issues that should be fixed, but whose fixes should come later, in
separate diffs.

compiler/module_imports.m:
    The compiler uses the module_and_imports structure defined here
    to go from a raw compilation unit (essentially a module to be compiled)
    to an augmented compilation unit (a raw compilation unit together
    with all the interface and optimization files its compilation needs).
    We used to store the contents of both the source file and of
    the interface and optimization files in the module_and_imports structure
    as item blocks. This diff replaces all those item blocks with
    file-kind-specific parse trees, for the reasons mentioned above.

    Separate out the .int0 files of ancestors modules from the .intN
    files for N>0 of directly imported modules. (Their item blocks
    used to be stored in the same list.)

    Maintain a database of the source, interface and optimization files
    we have read in so far. We use it to avoid reading in interface files
    if we have already read in a file for the same module that contains
    strictly more information (either an interface file with a smaller
    number as a suffix, or the source file itself).

    Shorten some field names.

compiler/prog_item.m:
    Define data structures for storing information about include_module,
    import_module and use_module declarations, both in a form that allows
    the representation of possibly erroneous code in actual source files,
    and in checked-and-cleaned-up form which is guaranteed to be free
    of the relevant kinds of errors. Add a block comment at the start
    of the module about the need for this distinction.

    Define parse_tree_module_src, a data structure for representing
    the source code of a single module. This is different from the existing
    parse_tree_src type, which represents the contents of a single source file
    but which may contain *more* than one module, and also different from
    a raw_compilation_unit, which is based on item blocks and is thus
    unable to express to invariants such as "no clauses in the interface".

    Modify the existing parse_tree_intN types to express the distinction
    mentioned just above, and to unify them "culturally", i.e. if they
    store the same information, make them store it using the same types.

    Fix a mistake by allowing promises to appear in .opt files.
    I originally ruled them out because the code that generates .opt files
    does not have any code to write out promises, but some of the predicates
    whose clauses it writes out have goal_type_promise, which means that
    they originated as promises, and get written out as promises.

    Split the existing pragma item kind into three item kinds, which have
    different invariants applying to them.

    - The decl (short for declarative) pragmas give the compiler some
      information, such as that a predicate is obsolete or that we
      want to type specialize some predicate or function, that is in effect
      part of the module's interface. Decl pragmas may appear in module
      interfaces, and the compiler may put them into interface files;
      neither statement is true of the other two kinds of pragmas.

    - The impl (short for implementation) pragmas are named so
      precisely because they may appear only in implementation sections.
      They give the compiler information that is private to that module.
      Examples include foreign_decls, foreign_codes, foreign_procs,
      and promises of clause equivalence, and requests for inlining,
      tabling etc. These will never be put into interface files,
      though some of them can affect the compilation of other modules
      by being included in .opt files.

    - The gen (short for generated) pragmas can never (legally) appear
      in source files at all. They record the results of compiler
      analyses e.g. about which arguments of a predicate are unused,
      or what exceptions a function can throw, and accordingly they
      should only ever occur in compiler-generated interface files.

    Use the new type differences between the three kinds of pragmas
    to encode the above invariants about which kinds of pragmas can appear
    where into the various kinds of parse trees.

    Make the augmented compilation unit, which is computed from
    the final module_and_imports structure, likewise switch from
    storing item blocks to storing the whole parse trees of the
    files that went into its construction. With each such parse tree,
    record *why* we read it, since this controls what permissions
    the source module being compiled has for access to the entities
    in the parse tree.

    Simplify the contains_foreign_code type, since one of three
    function symbols was equivalent to one possible use of another
    function symbol.

    Provide a way to record which method of which class a compiler-generated
    predicate is for. (See hlds_pred.m below.)

    Move the code of almost all utility operations to item_util.m
    (which is imported by many fewer modules than prog_item.m),
    keeping just the most "popular" ones.

compiler/item_util.m:
    Move most of the previously-existing utility operations here from
    prog_item.m, most in a pretty heavily modified form.

    Add a whole bunch of other utility operations that are needed
    in more than one other module.

compiler/convert_parse_tree.m:
    Provide predicates to convert from raw compilation units to
    parse_tree_module_srcs, and vice versa (though the reverse
    shouldn't be needed much longer).

    Update the conversion operations between the general parse_tree_int
    and the specific parse_tree_intN forms for the changes in prog_item.m
    mentioned above. In doing so, use a consistent approach, based on
    new operations in item_util.m, to detect errors such as duplicate
    include_module and import/use_module declarations in all kinds
    of parse trees.

    Enforce the invariants that the types of parse trees of various kinds
    can now express in types, generating error messages for their violations.

    Delete some utility operations that have been moved to item_util.m
    because now they are also needed by other modules.

compiler/grab_modules.m:
    Delete code that did tests on raw compilation units that are now done
    when that raw compilation unit is converted to a parse_tree_module_src.
    Use the results of the checks done during that conversion to decide
    which modules are imported/used and in which module section.

    Record a single reason for why we reading in each interface and
    optimization file. The code of make_hlds_separate_items.m will use
    this reason to set up the appropriate permissions for each item
    in those files.

    Use separate code for handling different kinds of interface and
    optimization files. Using generic traversal code was acceptable economy
    when we used the same data structure for every kind of interface file,
    but now that we *can* express different invariants for different kinds
    of interface and optimization file, we want to execute not just different
    code for each kind of file, but the data structures we want to work on
    are also of different types. Using file-kind-specific code is a bit
    longer, but it is significantly simpler and more robust, and it is
    *much* easier to read and understand.

    Delete the code that separates the parts of the implementation section
    that are exported to submodules, and the part that isn't, since that task
    is now done in make_hlds_separate_items.m.

    Pass a database of the files we have read through the relevant predicates.

    Give some predicates more meaningful names.

compiler/notes/interface_files.html:
    Note a problem with the current operation of grab_modules.

compiler/get_dependencies.m:
    Add operations to gather implicit references to builtin modules
    (which have to be made available even without an explicit import_module
    or use_module declaration) in all kinds of parse trees. These have
    more code overall, but will be at runtime, since we need only look at
    the item kinds that may *have* such implicit references.

    Add a mechanism to record the result of these gathering operations
    in import_and_or_use_maps.

    Give some types, function symbols, predicates and variables
    more meaningful names.

compiler/make_hlds_separate_items.m:
    When we stored the contents of the source module and the
    interface and optimization files we read in to augment it
    in the module_and_imports structure as a bunch of item blocks,
    the job of this module was to separate out the different kinds of items
    in the item blocks, returning a single list of each kind of item,
    with each such item being packaged up with its status (which encodes
    a set of permissions saying what the source module is allowed
    to do with it).

    Now that the module_and_imports structure stores this info in
    file-kind-specific parse trees, all of which have separate lists
    for each kind of item and none of which contain item blocks,
    the job of this module has changed. Now its job is to convert
    the reason why each file was read in into the (one or more) statuses
    that apply to the different kinds of items stored in it, wrap up
    each item with its status, and return the resulting overall list
    of status/item pairs for each kind of item.

compiler/read_modules.m:
    Add predicates that, when reading an interface file, return its contents
    in the tightest possible file-kind-specific parse tree.

    Refine the database of files we have read to allow us to store
    more file-kind-specific parse trees.

    Don't require that files in the database have associated timestamps,
    since in some cases, we read files we can put into the database
    *without* getting their timestamps.

    Allow the database to record that an attempt to read a file failed.

compiler/split_parse_tree_src.m:
    Rearchitect how this module separates out nested submodules from within
    the main module in a file.

    Another of the jobs of this module is to generate error messages for
    when module A includes module B twice, whether via nesting or via
    include_module declarations, with one special exception for the case
    where A's interface contains nested submodule A.B's interface,
    and A's implementation contains nested submodule A.B's implementation.
    The problem ironically was that while it reported duplicate include_module
    declarations as errors, split_parse_tree_src.m also *generated*
    duplicate include_module declarations. Since it replaced each nested
    submodule occurrence with an include_module declaration, in the scenario
    above, it generated two include_module declarations for A.B. Even worse,
    the interface incarnation of submodule A.B could contain
    (the interface of) its own nested submodule A.B.C, while its
    implementation incarnation could contain (the implementation section of)
    A.B.C. Each occurrence of A.B.C would be its only occurrence in the
    including part of its parent A.B, which means local tests for duplicates
    do not work. (I found this out the hard way.)

    The solution we now adopt adds include_module declarations to the
    parents of any submodule only once the parse tree of the entire
    file has been processed, since only then do we know all the
    includer/included relationships among nested modules. Until then,
    we just record such relationships in a database as we discover them,
    reporting duplicates when needed (e.g. when A includes B twice
    *in the same section*), but not reporting duplicates when not needed
    (e.g. when A.B includes A.B.C in *different* sections).

compiler/prog_data.m:
    Add a new type, pf_sym_name_and_arity, that exactly specifies
    a predicate or function. It is a clone of the existing simple_call_id
    type, but its name does NOT imply that the predicate or function
    is being called.

    Add XXXs that call for some other improvements in type names.

compiler/prog_data_foreign.m:
    Give a type, and the operations on that type, a more specific name.

compiler/error_util.m:
    Add an id field to all error_specs, which by convention should be
    filled in with $pred. Print out the value in this field if the compiler
    is invoked with the developer-only option --print-error-spec-id.
    This allows a person debugging the compiler find out where in the code
    an undesired error message is coming from significantly easier
    than was previously possible.

    Most of the modules that have changes only "to conform to the changes
    above" will be for this change. In many cases, the updated code
    will also simplify the creation of the affected error_specs.

    Fix a bug that looked for a phase in only one kind of error_spec.

    Add some utility operations needed by other parts of this change.

    Delete a previously internal function that has been moved to
    mdbcomp/prim_data.m to make it accessible in other modules as well.

compiler/Mercury.options:
    Ask the compiler to warn about dead predicates in every module
    touched by this change (at least in one its earlier versions).

compiler/add_foreign_enum.m:
    Replace a check for an inappropriately placed foreign_enum declaration
    with a sanity check, since with this diff, the error should be caught
    earlier.

compiler/add_mutable_aux_preds.m:
    Delete a check for an inappropriately placed mutable declaration,
    since with this diff, the error should be caught earlier.

compiler/add_pragma.m:
    Instead of adding pass2 and pass3 pragmas, add decl and impl and
    generated pragmas.

    Delete the tests for generated pragma occurring anywhere except
    .opt files, since those tests are now done earlier.

    Shorten some too-long predicate names.

compiler/comp_unit_interface.m:
    Operate on as specific kinds of parse trees as the interface of this
    module will allow. (We could operate on more specific parse trees
    if we changed the interface, but that is future work).

    Use the same predicates for handling duplicate include_module,
    import_module and use_module declarations as everywhere else.

    Delete the code of an experiment that shouldn't be needed anymore.

compiler/equiv_type.m:
    Replace code that operated on item blocks with code that operates
    on various kinds of parse trees.

    Move a giant block of comments to the front, where it belongs.

compiler/hlds_module.m:
    Add a field to the module_info that lets us avoid generating
    misleading error messages above missing definitions of predicates
    or functions when those definitions were present but were not
    added to the HLDS because they had errors.

    Give a field and its access predicates a more specific name.

    Mark a spot where an existing type cannot express everything
    it is supposed to.

compiler/hlds_pred.m:
    For predicates which the compiler creates to represent a class method
    (the virtual function, in OOP terms), record not just this fact,
    but the id of the class and of the method. Using this extra info
    in progress messages (with mmc -V) prevents the compiler from printing e.g.

        % Checking typeclass constraints on class method
        % Checking typeclass constraints on class method
        % Checking typeclass constraints on class method

    when checking three such predicates.

compiler/make.m:
    Provide a slot in the make_info structure to allow the database
    of the files we have read in to be passed around.

compiler/make_hlds_error.m:
    Delete predicates that are needed in just one other module,
    and have therefore been moved there.

compiler/make_hlds_passes.m:
    Add decl, impl and generated pragma separately, instead of adding
    pass2 and pass3 pragmas separately.

    Do not generate error messages for clauses, initialises or finalises
    in module interfaces, since with this diff, such errors should be
    caught earlier.

compiler/mercury_compile_main.m:
compiler/recompilation.check.m:
    Explicitly pass around the expanded database of parse trees
    of files that have been read in.

compiler/module_qual.collect_mq_info.m:
compiler/module_qual.m:
compiler/module_qual.qualify_items.m:
    Collect module qualification information, and do module qualification
    respectively on parse trees of various kinds, not item blocks.
    Take information about what the module may do with the contents
    of each interface or optimization file from the record of why
    we read that file, not from the section markers in item blocks.

    Break up some too-large predicates by carving smaller ones out of them.

compiler/options.m:
    Add an option to control whether errors and/or warnings detecting
    when deciding what should go into a .intN file be printed,
    thus (potentially) preventing the creation of that file.

    Add commented-out documentation for a previously totally undocumented
    option.

doc/user_guide.texi:
    Document the new option.

NEWS:
    Announce the new option.

    Mention that we now generate warnings for unused import_module and
    use_module declarations in the interface even if the module has
    submodules.

compiler/write_module_interface_files.m:
    Let the new option control whether we filter out any messages generated
    when deciding what should go into a .intN file.

compiler/parse_item.m:
    Delete actually_read_module_opt, since it is no longer needed;
    its callers now call actually_read_module_{plain,trans}_opt instead.

    Delete unneeded arguments from some predicates.

compiler/parse_module.m:
    Delete some long unused predicates.

compiler/parse_pragma.m:
    When parsing pragmas, wrap them up in the new decl, impl or generated
    pragma kinds.

compiler/parse_tree_out.m:
    Add predicates to write out each of the file-kind-specific parse trees.

compiler/parse_tree_out_pragma.m:
    Add predicates to write out decl, impl and generated pragmas.

compiler/polymorphism.m:
    Add a conditionally-enabled progress message, which can be useful
    in tracking down problems.

compiler/prog_item_stats.m:
    Conform NOT to the changes above beyond what is needed to let this module
    compile. Let that work be done the next time the functionality of
    this module is needed, by which time the affected data structures
    maybe have changed further.

compiler/typecheck.m:
    Fix a performance problem. With intermodule optimization, we read in
    .opt files, some of which (e.g. list.opt and int.opt) contain promises.
    These promises are read in as predicates with goal_type_promise,
    but they do not have declarations of the types of their arguments
    (since promises do not have declarations as such). Those argument types
    therefore have to be inferred. That inference replaces the original
    "I don't know" argument types with their actual types.

    The performance problem is that when we change the recorded argument types
    of a predicate, we require another loop over all the predicates in the
    module, so that any calls to this predicate can be checked against
    the updated types. This is as it should be for callable predicates,
    but promises are not callable. So if all the *only* predicates whose
    recorded argument types change during the first iteration to fixpoint
    are promises, then a second iteration is not needed, yet we used to do it.

    The fix is to replace the "Have the recorded types of this predicate
    changed?" boolean flag with a bespoke enum that says "Did the checking
    of this predicate discover a need for another iteration", and not
    setting it when processing predicates whose type is goal_type_promise.

compiler/typecheck_errors.m:
    Do not generate an error message for a predicate missing its clauses
    is the clauses existed but were not added to the HLDS because they were
    in the interface section.

    When reporting on ambiguities (when a call can match more than one
    predicate or function), sort the possible matches before reporting
    them.

compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/canonicalize_interface.m:
compiler/check_for_missing_type_defns.m:
compiler/check_parse_tree_type_defns.m:
compiler/check_promise.m:
compiler/check_raw_comp_unit.m:
compiler/check_typeclass.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/compiler_util.m:
compiler/dead_proc_elim.m:
compiler/deps_map.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/du_type_layout.m:
compiler/field_access.m:
compiler/find_module.m:
compiler/float_regs.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/handle_options.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/introduce_parallelism.m:
compiler/layout_out.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/ml_top_gen.m:
compiler/mmakefiles.m:
compiler/mode_errors.m:
compiler/mode_robdd.equiv_vars.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/oisu_check.m:
compiler/old_type_constraints.m:
compiler/options_file.m:
compiler/parse_class.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_inst_mode_name.m:
compiler/parse_mutable.m:
compiler/parse_sym_name.m:
compiler/parse_type_defn.m:
compiler/parse_type_name.m:
compiler/parse_type_repn.m:
compiler/parse_types.m:
compiler/parse_util.m:
compiler/parse_vars.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/prog_event.m:
compiler/prog_mode.m:
compiler/purity.m:
compiler/qual_info.m:
compiler/recompilation.version.m:
compiler/resolve_unify_functor.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_proc.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/trace_params.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
    Conform to the changes above.

mdbcomp/prim_data.m:
    Move a utility function on pred_or_funcs here from a compiler module,
    to make it available to other compiler modules as well.

scripts/compare_s1s2_lib:
    A new script that helped debug this diff, and may help debug
    similar diffs the future. It can compare (a) .int* files, (b) .*opt
    files, (c) .mh/.mih files or (d) .c files between the stage 1 and
    stage 2 library directories. The reason for the restriction
    to the library directory is that any problems affecting the
    generation of any of these kinds of files are likely to manifest
    themselves in the library directory, and if they do, the bootcheck
    won't go on to compile any of the other stage 2 directories.

tests/debugger/breakpoints.a.m:
tests/debugger/breakpoints.b.m:
    Move import_module declarations to the implementation section
    when they are not used in the interface. Until now, the compiler
    has ignored this, but this diff causes the compiler to generate
    a warning for such misplaced import_module declarations even modules
    that have submodules. The testing of such warnings is not the point
    of the breakpoints test.

tests/invalid/Mercury.options:
    Since the missing_interface_import test case tests error messages
    generated during an invocation of mmc --make-interface, add the
    new option that *allows* that invocation to generate error messages.

tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/max_error_line_width.err_exp:
tests/warnings/ambiguous_overloading.exp:
    Expect the updated error messages for ambiguity, in which
    the possible matches are sorted.

tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_initialise_decl.m:
    Fix programming style.

tests/invalid/bad_item_in_interface.err_exp:
    Expect an error message for a foreign_export_enum item in the interface,
    where it should not be.

tests/invalid/errors.err_exp:
    Expect the expanded wording of a warning message.

tests/invalid/foreign_enum_invalid.err_exp:
    Expect a different wording for an error message. It is more "standard"
    but slightly less informative.

tests/invalid_submodules/children2.m:
    Move a badly placed import_module declaration, to avoid having
    the message the compiler now generates for it from affecting the test.

tests/submodules/parent2.m:
    Move a badly placed import_module declaration, to avoid having
    the message the compiler now generates for it from affecting the test.

    Update programming style.
2020-03-13 12:58:33 +11:00
Julien Fischer
6ddc27e782 Replace tabs with spaces in the ml script.
scripts/ml.in:
    As above.
2020-02-22 00:53:59 +11:00
Julien Fischer
f60caca91c Use trail segments by default in trailing grades.
Until now, we have supported two variants of trailing grades, those that use a
fixed-size trail (.tr) and those that use trail segments (.trseg).  This change
removes support for fixed sized trails, and renames the .trseg grade component
to .tr. The .trseg grade now acts a synonym for .tr; it is deprecated, since we
intend to eventually delete it.  Until then, the behavior of the old .tr grade
component should be available, though to developers only, by compiling the
whole system with EXTRA_CFLAGS = -DMR_USE_FIXED_SIZE_TRAIL.

runtime/mercury_conf_param.h:
    Delete the MR_TRAIL_SEGMENTS macro. Its effect is now implied by
    MR_USE_TRAIL, unless a new macro, MR_USE_FIXED_SIZE_TRAIL, is defined.
    Developers can use this new macro to disable trail segments, should the
    need for doing that arise.

runtime/mercury_grade.h:
    Add a new macro that defines a binary compatibility version number for
    trailing; use that in the grade part for trailing.

    Use "_trfix" or "_trseg" as the prefix of the trailing part of the
    MR_GRADE_VAR depending on if MR_USE_FIXED_SIZE_TRAIL is defined or
    not.

runtime/mercury_trail.[ch]:
runtime/mercury_context.h:
    Enable trail segments by default, only disabling them if
    MR_USE_FIXED_SIZE_TRAIL is enabled.

runtime/mercury_wrapper.c:
trace/mercury_trace_cmd_developer.c:
    Conform to the above changes.

compiler/compile_target_code.m:
    Do not pass options for trail segments to the C compiler.

compiler/compute_grade.m:
    Treat trseg as a synonym for tr.

compiler/options.m:
    Deprecate --trail-segments.

grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/grade_vars.m:
grade_lib/try_all_grade_structs.m:
grade_lib/var_value_names.m:
    Remove the trseg component.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
    Remove support for the --trail-segments option.

doc/user_guide.texi:
    Update the documentation for the --trail-segments.

    Comment out the documentation of the --trail-size and --trail-size-kwords
    runtime options; they are no longer useful to non-developers.

NEWS:
    Announce this change.
2020-02-18 13:07:24 +11:00
Julien Fischer
6e32d80a5e Improve support for MSYS2 builds.
MSYS2 provides a POSIX like environment and package manager for Windows.
It packages up the MinGW-w64 port of GCC.  (MSYS2 is separate from the
original MSYS.)

Make it possible to build Mercury under MSYS2 with the MinGW-w64 GCC
without having to resort to cross compilation.

configure.ac:
    Recognise the x86_64-pc-mingw* architecture returned by config.guess
    under MSYS2.

    If we are building the MSVC port under MSYS2, set up the flags for
    threads appropriately.

scripts/ml.in:
    Pass libraries to the linker correctly for static linking on all the
    different MinGW configurations.

README.MinGW:
    Update documentation for MinGW ports.
2020-01-24 17:40:22 +11:00
Julien Fischer
5a5ea709b9 Force the use of static linkage with MSVC in the ml script.
This fixes a problem that made it impossible to use mmake with MSVC.

scripts/ml.in:
     Force the use of static linkage with MSVC.
2020-01-23 20:31:31 +11:00
Julien Fischer
ca58b4c2a4 Updates for the ml script.
scripts/ml.in:
    Shared libraries are now the default on FreeBSD systems.

    Handle 64-bit Cygwin systems the same as 32-bit ones.

    Update references to the configure script source.
2020-01-23 20:15:49 +11:00
Julien Fischer
1f3812e898 Replace an old hack in the ml script.
Instead of trying to determine the type of the C compiler in the ml script
based on the name of the C compiler executable, use the C compiler type
determined by the configure script.

scripts/ml.in:
    As above.
2020-01-23 20:03:39 +11:00
Julien Fischer
ea2591f168 Delete an unused variable from the mgnuc script.
scripts/mgnuc.in:
    As above.
2020-01-19 21:24:28 +11:00
Julien Fischer
9eea60f5bf Apply workaround for bug #492 to all GCC 9 versions.
As mentioned on the reviews list, the fix for the bug is not (currently)
present on the gcc-9 branch.

compiler/compile_target_code.m:
scripts/mgnuc.in:
    As above.
2020-01-17 20:44:45 +11:00
Julien Fischer
5fcf2d2e00 Add a workaround for Mantis bug #492.
In debug grades that use global register variables, the generated C code is
triggering an internal error in GCC 9 on x86_64 machines. Force GCC to compile
at -O0 in this case as that seems to be the only workaround for the issue.

scripts/mgnuc.in:
    Force GCC to use -O0 in the above case.

compiler/compile_target_code.m:
    Do the same when GCC is invoked directly by the Mercury compiler.

    Re-arrange some of the code that applies C compiler bug workarounds
    to make this possible.

    Add an XXX about an overly broad bug workaround on darwin; I'll look
    into that separately.
2020-01-16 22:34:43 +11:00
AlaskanEmily
416fbe954a Add option for link-time optimization/link-time code generation
The option is disabled by default.

configure.ac:
    Add --enable-lto option to the configure script to enable LTO/LTCG.

scripts/mgnuc.in:
scripts/ml.in:
    Pass LTO options to the C compiler/linker.

compiler/compile_target_code.m:
compiler/options.m:
scripts/Mercury.config.in:
    Add internal options to specify C compiler and linker LTO/LTCG flags.
2019-11-15 16:51:13 +11:00
AlaskanEmily
15cb007c28 Check for GCC before setting -Wno-uninitialized in high-level code.
scripts/mgnuc.in:
    As above. This fixes compilation using MSVC.
2019-07-21 12:13:09 +10:00
Zoltan Somogyi
bc8938ba8f Add a way to debug mmake's actions.
Specifically, when the environment variable is nonempty, pass the debugging
flag -d to make.

Also, bring this script up to date with our current programming style,
including 4-space indentation.
2019-06-18 18:32:16 +02:00
Peter Wang
a68fb94745 Disable uninitialized variable warnings in high-level C grades.
scripts/mgnuc.in:
    Disable uninitialized variable warnings in high-level C grades.
    This is necessary but went (mostly) unnoticed because we happen to
    disable uninitialized variable warnings for gcc on x86/x86_64 in
    support of low-level C grades, and we suppress any and all warnings
    if using clang.
2019-05-31 16:58:51 +10:00
Peter Wang
10d29a489a Generate better man pages.
doc/make_manpage:
    Replace the old script with a new version written in awk.

    The new output should be an improvement in these ways:
      - works for tools that use spaces for indentation instead of tabs
      - uses macros for indenting proportional font text
        instead of monospace text with inconsistent leading spaces
      - option names are in bold
      - removes redundant blank lines

doc/Mmakefile:
    Adjust command line to call the new make_manpage script.

compiler/options.m:
    Minor formatting changes to --help text to keep complexity of
    make_manpage script low.

profiler/mercury_profile.m:
    Add "Name:" line to --help output for make_manpage to read.

scripts/mtags.in:
    Add "Name:" line to --help output for make_manpage to read.

    Delete initial blank line in help and usage text.

    Delete stray full stop.

scripts/mprof_merge_runs:
scripts/parse_ml_options.sh-subr.in:
    Simplify --help text for make_manpage.
2019-05-28 15:54:45 +10:00
Zoltan Somogyi
753327c7b3 Simplify handling of -fPIC for SPARCs ...
... and apply -fPIC on solaris2 even in grades other than "none", since I am
pretty sure that if it is needed in that grade, it will be needed in other
grades as well, starting with "none.gc".
2019-03-17 00:44:51 +11:00
AlaskanEmily
68346cb76b Use large PIC offset table on Sparc64 OpenBSD
scripts/mgnuc.in:
    Same as Solaris on Sparc, but for all grades on Sparc64 OpenBSD.
    This is needed at least for hlc.gc.pregen and none.gc.
    It is likely needed for all grades.
2019-03-15 00:52:47 +11:00
Peter Wang
5686126f21 Use non-minified copies of jQuery and jsTree.
The Debian packaging system complains about minified files not being
built from non-minified sources so distribute and install the
non-minified sources instead. Fixes Mantis bug #473.

scripts/jquery.slim.js
    Add non-minified copy of jQuery slim 3.3.1 from https://jquery.com/

scripts/jstree.js
scripts/jstree.style.css
    Add non-minified copy of jsTree 3.2.1 from https://www.jstree.com/

scripts/jquery.slim.min.js:
scripts/jstree.min.js:
scripts/jstree.style.min.css:
    Delete old minified files.

LICENSE:
browser/term_to_html.m:
scripts/Mmakefile
    Update paths.
2018-11-19 11:42:45 +11:00
Paul Bone
4ee7e744b7 Don't pack scripts/config.log in source tarballs
Mmakefile:
    Delete this file before making the source tarball.

scripts/Mmakefile:
    Delete this file in make realclean
2018-11-18 16:20:56 +11:00
Zoltan Somogyi
16e6459517 Add a --halt-at-warn-if-possible option to mgnuc.
scripts/mgnuc_file_opts.sh-subr:
    Parse the new option.

scripts/mgnuc.in:
    Implement the new option.
2018-07-30 09:24:06 +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
Julien Fischer
015c2b5fdf Enable the use of unboxed 64-bit integers in C grades on 64-bit machines.
Add a new internal grade component corresponding to the use of 64-bit integers.

configure.ac:
    Test whether we can use unboxed 64-bit integers.

    Extend the check for whether previously built C files are compatible with
    configure determined settings to cover whether 64-bit integer are boxed
    or not.

scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
     Set the compiler flag for unboxed 64-bit integers if configure determines
     they can be used.

runtime/mercury_grade.h:
     Add the "ubi64" grade component
2018-02-18 19:51:26 -05:00
Zoltan Somogyi
5f702679c9 Finish adding mmake variables for C#.
About a week ago, Julien added targets to */Mmakefile to build .cs files.
These referred to undefined mmake variables of the form "program_name.css".

compiler/write_deps_file.m:
    Add rules to generate definitions for "program_name.css".
    Following the pattern of similar definitions such as program_name.javas,
    these refer to other mmake variables css_subdir and cs_date_subdir.

scripts/Mmake.vars.in:
    Add definitions for css_subdir and cs_date_subdir.
2017-11-01 04:36:46 +11:00
Zoltan Somogyi
f4e0059a49 Eliminate hlc_nest and hl_nest grades ...
... by eliminating the grade component that calls for the use of gcc nested
functions.

runtime/mercury_grade.h:
compiler/compute_grade.m:
    Delete the gcc_nested_functions grade component, and the C macro
    that specifies its presence, MR_USE_GCC_NESTED_FUNCTIONS.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
    Delete the code that parses the deleted grade component,
    and delete the code that signals its absence in other grades.

compiler/options.m:
    Delete the gcc_nested_functions grade option.

    Delete also the gcc_local_labels option, since it was useful
    only if gcc_nested_functions was set.

configure.ac:
    Delete the code that sometimes added hl*_nest grades to the list of grades
    to be installed.

    Fix a bunch of comments.

compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/ml_args_util.m:
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_commit_gen.m:
compiler/ml_gen_info.m:
compiler/mlds_to_c.m:
library/backjump.m:
library/exception.m:
runtime/mercury_hlc_types.h:
runtime/mercury_tabling.c:
runtime/mercury_tabling.h:
    Delete code that was active only in grades with the deleted grade
    component.

compiler/ml_accurate_gc.m:
compiler/notes/grade_library.html:
runtime/mercury_conf_param.h:
    Delete mentions of the deleted grade component.

compiler/ml_code_gen.m:
    Delete mentions of the deleted grade component, and a bunch of other
    obsolete comments.

doc/user_guide.texi:
    Fix a line break.
2017-09-07 03:01:55 +10:00
Peter Wang
0d273769fc Add web browser-based term browsing in the debugger.
browser/browse.m:
    Add save_and_browse_browser_term_web to be called when
    "browse --web" is entered at the mdb prompt.

    Add browser_term_to_html_flat_string, a helper predicate for
    term_to_html.

    Make portray_flat_write_browser_term work take a stream parameter
    instead of writing to the current output stream. It is called by
    browser_term_to_html_flat_string, writing to a string builder
    stream.

browser/browser_info.m:
    Add web_browser_cmd field to browser_persistent_state.

browser/mdb.m:
browser/term_to_html.m:
    Add new module to generate an HTML document. The document contains a
    JavaScript represention of a Mercury term.

    (The JavaScript string escaping code is adapted from Julien's
    mercury-json project.)

browser/percent_encoding.m:
    Add new module to perform percent-encoding.

scripts/mdb_term_browser.css:
scripts/mdb_term_browser.js:
    Add JavaScript and CSS files referenced by the generated HTML file
    to create a tree view of a Mercury term using jstree.

scripts/32px.png:
scripts/40px.png:
scripts/throbber.gif:
scripts/jstree.min.js:
scripts/jstree.style.min.css:
    Add local copy of jstree files <https://www.jstree.com/>

scripts/jquery.slim.min.js:
    Add local copy of jquery <https://jquery.com/>

scripts/Mmakefile:
    Install the new files into the same directory as mdbrc and other
    mdb-related files.

trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
    Add "browse --web" and "web_browser_cmd" commands.

doc/user_guide.texi:
    Document "browse --web" and "web_browser_cmd" commands.

configure.ac:
scripts/mdbrc.in:
    Set a reasonable default command to launch a web browser from mdb.
    (Only tested on Linux.)

NEWS:
    Announce the new feature.

.README.in:
    Mention jquery and jstree licensing.

tests/debugger/Mmakefile:
tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
tests/debugger/save.exp2:
    Update debugger tests for new commands.
2017-08-15 16:14:55 +10:00
Zoltan Somogyi
e252fd3464 Don't get confused by ';'s in end-of-line comments.
Improve some comments.
2017-04-07 06:44:03 +10:00
Paul Bone
7fe8ee9596 Install documentation into paths selected by ./configure
Install the documentation, including info and man pages but not the mdb
docs, into the paths selected by ./configure.  This also makes Mercury more
up-to-date with respect to Linux Distros' file locations, using share/doc/
rather than doc/

Doing the same for other files, such as binaries, libraries and the mdb
documentation, requires more working with autoconf than I'm happy to do
right now.

scripts/Mmake.vars.in:
    As above.
2017-04-05 16:42:57 +10:00
Julien Fischer
57de4f6bcd Fix mmake's .i target
scripts/Mmake.rules:
    Add .i to the .SUFFIXES target.  It was accidently deleted
    when the IL backend was deleted.
2016-10-20 23:24:21 +11:00
Peter Wang
ef5a4fa59d Support building with AddressSanitizer and UndefinedBehaviorSanitizer.
configure.ac:
    Add configure option --enable-sanitizers.

Mmake.common.in:
scripts/Mercury.config.in:
    Add variables to be set when --enable-sanitizers is used.

scripts/mgnuc.in:
scripts/ml.in:
    Pass sanitizer options to the C compiler and the linker.

compiler/options.m:
    Add options --cflags-for-sanitizers and --linker-sanitizer-flags
    for receiving the configuration.

    Set --linker-trace-flags and --shlib-linker-trace-flags default
    values to empty instead of "-g" (likely copy error).

compiler/compile_target_code.m:
    Pass sanitizer options to the C compiler, and the linker when
    building an executable or shared library.

runtime/Mmakefile:
trace/Mmakefile:
    Pass sanitizer options to linker when building shared libraries.

README.sanitizers:
    Add instructions.
2016-10-13 17:15:10 +11:00
Julien Fischer
3f2436c68a Update prepare_install_dir script.
scripts/prepare_install_dir.in:
    Do not copy over scripts from the boehm_gc directory that no
    longer exist.
2016-10-07 11:19:35 +11:00
Julien Fischer
233434d370 Delete a left-over reference to the IL backend.
scripts/init_grade_options.sh-subr:
     Delete "il" from the list of values for the --target option.
2016-08-21 14:54:27 +10:00
Paul Bone
0bd301b59e Add thread.num_processors/3
Add a predicate that retrieves the number of processors available to this
process if known.

library/thread.m:
    As above.

runtime/mercury_context.c:
    The existing code that determines the number of processors was only used
    on thread safe low-level C grades.  Make it also available for thread
    safe high-level C grades.

    Add a fall back (less accurate) method of determining the number of
    processors.

    Remove an out-of-date comment.

runtime/mercury_context.h:
    Export the number of available processors.

scripts/ml.in:
    Link to libhwloc (if configured) on thread safe high and low-level C
    grades.

NEWS:
    Announce new predicate.

configure.ac:
    Update a --help message.
2016-05-13 16:17:52 +10:00
Julien Fischer
5c91099f0b Delete left over references to the IL backend.
scripts/final_grade_options.sh-subr:
scripts/mmake.in:
scripts/parse_grade_options.sh-subr:
    As above.
2016-04-14 16:27:45 +10:00
Julien Fischer
112d1f1320 Copy all NT_MAKEFILE variants into stage 2 dir etc.
scripts/prepare_install_dir.in:
tools/bootcheck:
    Copy all of the MSVC makefiles variants for the Boehm GC into the
    grade build directory / stage 2 directory.
2016-03-20 00:12:17 +11:00
Zoltan Somogyi
764c7ff755 Finish removing the .picreg grade component.
compiler/compute_grade.m:
compiler/file_names.m:
compiler/options.m:
scripts/parse_grade_options.sh-subr:
    Delete code that understood references to picreg.

tests/debugger/Mercury.options:
tests/hard_coded/Mercury.options:
    Don't specify picreg options.
2016-03-10 12:05:39 +11:00
Zoltan Somogyi
c8d718ec57 Remove the .regparm and .picreg grade components.
For picreg, this is only the first half of the change; it deletes code
that generates references to this grade component. When this diff has been
installed on all our machines, will come the second half, which will delete
the code that understands references to picreg. The delay is needed because
your current installed compiler is still generating such references.

runtime/mercury_grade.h:
    Remove both regparm and picreg as grade components.

doc/user_guide.texi:
    Remove the (commented out) documentation of picreg; regparm had
    no documentation to delete.

runtime/mercury_std.h:
    Remove the small bit of code that implemented regparm.

runtime/mercury_conf_param.h:
    Don't define MR_PIC_REG.

runtime/machdeps/i386_regs.h:
runtime/mercury_conf_bootstrap.h:
    Remove references to picreg.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
    Keep in place the code that accepts picreg grade components,
    but make them do nothing. Mark such do-nothing code so that
    it can be deleted when this first-half diff has been bootstrapped.

configure.ac:
    Delete the autoconfigured variable EXT_FOR_LINK_WITH_PIC_OBJECTS,
    which could be set to either 'lpic_o' or just 'o', because it is now
    *always* the latter.

scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
    Remove code that transmitted the value of EXT_FOR_LINK_WITH_PIC_OBJECTS
    to the compiler via the --link-with-pic-object-file-extension option.

compiler/options.m:
    Keep the --link-with-pic-object-file-extension and --pic-reg options,
    but mark them for deletion in the second half of this change.

compiler/compile_target_code.m:
    Change the code that dealt with the value of the
    --link-with-pic-object-file-extension and --pic-reg options to assume
    that the former is always the same as the non-pic file extension,
    and that --pic-reg is never needed. The former means that we don't need
    to handle link_with_pic as a separate category of object files from
    just plain non_pic.

compiler/compute_grade.m:
    Keep accepting picreg grades, but mark the code that does this
    for deletion.

compiler/make.program_target.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
    Conform to the changes above.
2016-02-25 16:47:16 +11:00
Julien Fischer
8e732885ff Rename the top-level of the compiler.
Currently, the compiler's top-level module is the module 'top_level'.  This
means that the executable (or Java archive, or assembly) we generate is named
after that.  However, the rest of the system requires that the compiler
executable be named 'mercury_compile', so we currently rename it after it is
generated.  (At least, we do in C grades, in non-C grades the compiler
"executable" currently has the "wrong" name.)  Making this scheme work across
multiple backends and platforms leads to quite a bit of complication in the
build system.  This change simplifies matters by repurposing the
'mercury_compile' module to be the new top-level module; this means that the
executable is generated with the correct name to begin with.

compiler/mercury_compile.m:
     Shift the existing contents of this module to  new module,
     mercury_compile_main.

     Shift this module out of the top_level package and export main/2 from it.

compiler/mercury_compile_main.m:
     New module that contains the old contents of mercury_compile.m.

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

     Delete the definition of main/2 from this module.

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

compiler/Mmakefile:
     Conform to the change in the name of the top-level module.

    Delete the rule for renaming the compiler executable.

Mmakefile:
    Update the dep_compiler target.

compiler/notes/compiler_design.html:
    Update this document.

scripts/mercury_compile.sh-csharp:
scripts/mercury_compile.sh-java:
    Update these scripts.

compiler/.gitignore:
    Conform to the above changes and generally update
    this file.

configure.ac:
tools/binary_step:
tools/bootcheck:
    Update the top-level module.
2016-02-17 20:13:33 +11:00
Julien Fischer
18c9eecbce Make it possible to run an installed compiler built in the C# grade.
scripts/mercury_compile.sh-csharp:
   Add a script script that runs an installed compiler built in the C#
   grade using Mono.  As with compilers built in the Java grade, the
   wrapper script we generate in the compiler directory only works
   in situ and we require a separate script for the installed version.

   XXX TODO: we will need to handle .NET differently, probably by simply
   renaming top_level.exe -> mercury_compile.exe.

scripts/Mmakefile:
    Install the new script if the compiler was built in the C# grade.
2015-12-18 00:04:05 +11:00
Julien Fischer
4983c7e9ce Delete stray references to Prolog generated files.
doc/user_guide.texi:
scripts/Mmake.rules:
     Delete stray references to files generated by NU-Prolog and
     SICStus.
2015-12-17 11:36:51 +11:00
Julien Fischer
cf6aa853cb Delete an unused mmake variable.
scripts/Mmake.vars.in:
    Delete the definition of the variable GCCFLAGS_FOR_PIC.  This
    was only ever required by the GCC backend.
2015-12-10 11:11:25 +11:00
Julien Fischer
94535ec121 Fix spelling and formatting throughout the system.
configure.ac:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
ssdb/*.m:
runtime/mercury_conf.h.in:
runtime/*.[ch]:
scripts/Mmake.vars.in:
trace/*.[ch]:
util/*.c:
	Fix spelling and doubled-up words.

	Delete trailing whitespace.

	Convert tabs into spaces (where appropriate).
2015-12-02 18:46:14 +11:00