Commit Graph

256 Commits

Author SHA1 Message Date
Julien Fischer
2a366cf295 Deprecate --no-ansi and --no-ansi-c.
--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

configure.ac:
    Require the installed compiler to contain the fix for a bug that
    prevents compilation of the new code of const_prop.m in hlc grades.
2022-12-09 15:12:03 +11:00
Zoltan Somogyi
4c528d429d Add <<u and >>u to library/{int,uint}*.m ...
... along with their unchecked equivalents. These differ from <<, >> and
their unchecked equivalents in that they take the shift amount as a uint,
instead of an int.

library/int.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/int8.m:
library/uint.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
library/uint8.m:
    As above. The unchecked versions have only declarations, since
    these operations have been recognized as builtins for a while now.

NEWS:
    Document the new operations, and the recent change to recognize
    <<u and >>u as single tokens, and fix a typo in a recent addition.

configure.ac:
    Require the compiler to be sufficiently recent to be able to parse
    <<u and >>u as operators.

compiler/options.m:
    Provide a way for a later change to configure.ac to detect the presence
    of this change.

tests/hard_coded/bitwise_int.exp:
tests/hard_coded/bitwise_int.exp2:
tests/hard_coded/bitwise_int.m:
tests/hard_coded/bitwise_int16.exp:
tests/hard_coded/bitwise_int16.m:
tests/hard_coded/bitwise_int32.exp:
tests/hard_coded/bitwise_int32.m:
tests/hard_coded/bitwise_int64.exp:
tests/hard_coded/bitwise_int64.m:
tests/hard_coded/bitwise_int8.exp:
tests/hard_coded/bitwise_int8.m:
tests/hard_coded/bitwise_uint.exp:
tests/hard_coded/bitwise_uint.exp2:
tests/hard_coded/bitwise_uint.m:
tests/hard_coded/bitwise_uint16.exp:
tests/hard_coded/bitwise_uint16.m:
tests/hard_coded/bitwise_uint32.exp:
tests/hard_coded/bitwise_uint32.m:
tests/hard_coded/bitwise_uint64.exp:
tests/hard_coded/bitwise_uint64.m:
tests/hard_coded/bitwise_uint8.exp:
tests/hard_coded/bitwise_uint8.m:
    Check that <<u and >>u compute the same results as << and >> respectively.
2022-12-07 23:12:33 +11:00
Peter Wang
36f51d1445 Use value of MACOSX_DEPLOYMENT_TARGET by default.
On MacOS, make configure use the value of MACOSX_DEPLOYMENT_TARGET as
the default deployment target (if set), otherwise falling back to the
host system version.

configure.ac:
    As above.

README.MacOS:
NEWS:
    Document the change.
2022-11-29 12:09:54 +11:00
Julien Fischer
dddf3dd58f Avoid a configure abort with MSVC.
configure.ac:
    The AC_PROG_LEX macro we use to detect flex does not work with MSVC.
    Avoid its use if we are using MSVC.
2022-11-09 21:52:19 +11:00
Zoltan Somogyi
5b2f6e533b Disable unknown_format_call warnings using scopes.
configure.ac:
    Require the installed compiler to support disable_warning scopes
    for unknown_format_calls.

compiler/Mercury.options:
library/Mercury.options:
    Do not disable unknown_format_call warnings in whole files.

compiler/parse_tree_out_info.m:
compiler/pd_debug.m:
library/io.m:
library/stream.string_writer.m:
library/string.m:
    Disable unknown_format_call warnings for just the format calls
    that need it.
2022-09-07 12:18:19 +10:00
brendanzab
72ceba7afa Allow STRIP_EXE to be overriden on Darwin
configure.ac:
    Use the AC_CHECK_TOOL macro to search for the strip command on the
    PATH. This is more consistent with how other commands are configured
    (eg. ar and nm).
2022-08-18 14:13:30 +10:00
Julien Fischer
40401a6b5c Fix hlc test failures with GCC 12.
GCC 12 has new warning, -Winfinite-recursion, that is being triggered by six
tests in the directory tests/valid when compiled in high-level C grades. Since
we also enable -Werror, this is causing these test to fail. Fix these failures
by either removing the infinite recursion from them or by disabling the new GCC
warning for the affected test cases.

configure.ac:
tests/DEFNS_FOR_TESTS.in:
    Define a variable whose value is the option for disabling GCC's infinite
    recursion check.

tests/valid/higher_order5.m:
tests/valid/stack_alloc.m:
    Modify these tests so they do not trigger the infinite recursion warning
    in GCC (or Mercury for that matter).

tests/valid/mode_syntax.m:
tests/valid/same_length_2.m:
    Merge these two tests (under the first name) since they both test the same
    thing.  Delete the same_length_2 version.

tests/valid/Mmakefile:
    Conform to the above deletion.

tests/valid/Mercury.options:
    Include DEFNS_FOR_TESTS here so that mmc --make can see it.

    Disable GCC's infinite recursion check for those tests that trigger
    it.

    Shut up a bunch Mercury warnings for the mode_syntax test case that
    are unrelated to what is actually being tested.
2022-07-04 11:01:13 +10:00
Julien Fischer
04c0ead697 Workaround Github issue #103.
The basic block vectorizer optimisation in GCC 11 and 12 is generating code
that causes segmentation faults in grades that use non-local gotos.
As a workaround, disable that optimisation for GCC 11 and later.
(While this problem has presumably always existed for GCC 11, it has not shown
up previously because the affected optimisation is only enabled at -O3; with
GCC 12 it is enabled by default. GCC 10 and earlier do not appear to be
affected.)

configure.ac:
     Add the above workaround.
2022-06-25 21:49:39 +10:00
Julien Fischer
3f225fb4a5 Fix more bad configure escaping.
configure.ac:
    As above.
2022-06-19 00:58:33 +10:00
Julien Fischer
fb8aa65071 Escape square brackets in configure properly.
configure.ac:
    As above.
2022-06-19 00:46:46 +10:00
Julien Fischer
e0c7eedb49 Fix Github issue #102.
Avoid the use of the GCC option -Warray-bounds with GCC version 12 and later.

configure.ac:
scripts/mgnuc.in:
    As above.

NEWS:
    Announce the fix.
2022-06-18 20:12:03 +10:00
Peter Wang
5c8e0c6fce Disable non-local gotos on AArch64 with GCC 9+.
Programs using non-local gotos on AArch64 crash when compiled with
newer versions of GCC:

    gcc 6.3.0 (Debian 9) - ok
    gcc 8.3.0 (Debian 10) - ok
    gcc 9.3.0 (Debian 11) - crash
    gcc 10.2 (Debian 11) - crash

Specifically, the programs only crash when compiled with PIC,
but PIC is commonly the default now.

This is Mantis bug #560.

configure.ac:
    Disable non-local gotos on AArch64 when using GCC 9+.

README.Linux-aarch64:
    Mention the problem.
2022-06-01 12:07:43 +10:00
Zoltan Somogyi
b70ff36def Fix comments. 2022-03-26 03:07:32 +11:00
Julien Fischer
d0f22be99e Avoid spurious warnings from GCC.
As mentioned recently on the developers list, GCC versions 9 10 and 11 are
emitting suprious warnings with -Warray-bounds for the specialised code they
introduce for strcmp etc. Disable that warning for those versions of GCC. In
addition to this issue, according to the GCC bug database is is generating a
lot of false positives anyway.

configure.ac:
scripts/mgnuc.in:
    As above.
2022-03-05 22:39:10 +11:00
Peter Wang
f5b4f67d1a Check for gcc generating PIC by default.
In configure, we try detect the non-working combination of gcc 5+,
targeting x86, PIC, and non-local gotos. We assumed that PIC is only
generated when creating shared libraries, but gcc may have been
configured to generate PIC by default. This is very common on more
recent Linux distributions.

configure.ac:
    Extend the test mentioned above: if shared libraries are disabled,
    check whether gcc generates PIC anyway.

    Clean up the code a little.

m4/mercury.m4:
    Add helper macros MERCURY_CC_TARGETS_X86 and
    MERCURY_CC_GENERATES_PIC.

README.x86:
    Update this document.
2022-02-25 13:43:15 +11:00
Julien Fischer
02b502d2c7 Minor fix for configure script.
configure.ac:
    Delete reference to "MC_ERROR", which isn't a thing.
2022-02-09 22:18:00 +11:00
Zoltan Somogyi
77b7626316 Avoid misleading error message. 2022-02-09 12:23:20 +11:00
Zoltan Somogyi
07ffbce8e7 Implement --warn-sdtlib-shadowing.
compiler/mercury_compile_main.m:
    I added that option a week or so ago, but at that time, it did nothing.
    This diff implements the warning.

library/LIB_FLAGS.in:
    Disable the warning for the modules in the library directory.

configure.ac:
    Require the installed compiler to recognize the option, since without this,
    library/LIBFLAGS won't work.

tests/warnings/profiling_builtin.{m,exp}:
tests/warnings/time.{m,exp}:
tests/warnings/time.subtime.m:
    Two test cases for the warning. One, time, shadows the name of
    a documented library module, the other, profiling_builtin,
    shadows the name an undocumented library module.

    The purpose of time.subtime is to test the message when the module name
    *contains* a stdlib module name, but is not *identical* to it.

tests/warnings/Mmakefile:
    Do *not* turn on the new test cases, but do document why we do not do so.
2022-01-08 04:41:55 +11:00
Zoltan Somogyi
81f43b401f Require an up-to-date compiler. 2021-12-26 18:45:02 +11:00
Peter Wang
ae95a01155 Enable munmap support in Boehm GC by default.
configure:
    Change default value of enable_gc_mmap and enable_gc_munmap to yes.

    Invert sense of --enable-gc-mmap and --enable-gc-munmap options in
    the help text.

NEWS:
    Announce change.
2021-12-07 11:12:18 +11:00
Julien Fischer
19d4aee81a Avoid warnings from autoconf.
configure.ac:
     Use single quotes for quoting in configure script messages.
     Using `' results in warnings from autoconf.

     Delete a stray comma from the test for GNU make.
2021-06-26 20:32:58 +10:00
Zoltan Somogyi
d854949a9c Specify --warn-potentially-ambiguous-pragma ...
as the default for the Mercury system.

configure.ac:
    Require the installed compiler to support this option.

browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Specify this option as the default in their directories.
2021-06-23 18:33:59 +10:00
Zoltan Somogyi
0d7c8a7654 Specify pred or func for all pragmas.
*/*.m:
    As above.

configure.ac:
    Require the installed compiler to support this capability.
2021-06-16 15:23:58 +10:00
Julien Fischer
65f78b8e7e Replace more deprecated autoconf macros.
configure.ac:
    As above.
2021-06-05 01:08:26 +10:00
Julien Fischer
dc45a7082f Apply more suggestions from autoupdate.
configure.ac:
    As above.
2021-05-30 03:04:22 +10:00
Julien Fischer
02375907ac Fix argument quotation problems in the configure script.
According to the changelog for autoconf 2.70, many macros have become pickier
about argument quotation.  Add quotes to the configure script to avoid these
problems.

Delete unnecessary use of changequote (whose use the autoconf manual recommends
against anyway.)

configure.ac:
    As above.
2021-05-30 02:47:47 +10:00
Julien Fischer
567704838b Replace deprecated autoconf variables.
configure.ac:
    As above.
2021-05-29 21:12:42 +10:00
Julien Fischer
62a82af1ef Avoid another deprecated autoconf macro.
configure.ac:
    As above.
2021-05-29 04:45:35 +10:00
Julien Fischer
ff452e7040 Undo my last commit.
configure.ac:
    As above -- this broke the configure script on some of my
    test systems.
2021-05-29 04:38:23 +10:00
Julien Fischer
f4bdd2c0a9 Avoid more warnings from autoconf.
configure.ac:
    Do not escape quotes; autoconf 2.70 emits warnings about it
    by default.
2021-05-29 04:07:28 +10:00
Julien Fischer
ee44858b22 Replace more deprecated autoconf macros.
configure.ac:
     As above; the updates were done using the autoupdate script.
2021-05-29 03:48:12 +10:00
Julien Fischer
9e1f42f484 More obsolete autoconf macro replacement.
configure.ac:
    As above; most of these updates were done by the autoupdate
    script.
2021-05-25 21:38:56 +10:00
Julien Fischer
28cc1233a6 Avoid another deprecated autoconf macro.
configure.ac:
    The use of AC_OUTPUT with arguments is deprecated; replace
    it with what is recommended in the autoconf manual.
2021-05-24 21:30:12 +10:00
Julien Fischer
6d80e4c573 Add a note about autoconf 2.70+.
configure.ac:
    As above.
2021-05-24 20:59:07 +10:00
Julien Fischer
959b966533 Avoid another deprecated autoconf macro.
configure.ac:
    Replace the use of AC_FD_MSG with AS_MESSAGE_FD.
2021-05-24 19:04:11 +10:00
Julien Fischer
75e0251d43 Replace another deprecated autoconf macro.
configure.ac:
     Replace the use of the deprecated AC_PROGRAMS_CHECK macro
     with AC_CHECK_PROGS.
2021-05-24 18:59:28 +10:00
Julien Fischer
b28dcccad6 Avoid more deprecated autoconf macros.
configure.ac:
     s/AC_FD_CC/AS_MESSAGE_LOG_FD/

INSTALL.git:
    Bump the minimum required version of autoconf.
2021-05-24 18:45:33 +10:00
Julien Fischer
0383491264 Avoid the use of a deprecated autoconf macro.
configure.ac:
    Use AC_CONFIG_HEADERS in place of the deprecated AC_CONFIG_HEADER.
2021-05-24 18:24:27 +10:00
Julien Fischer
bc20b3193b Fix problems with recent versions of autoconf.
configure.ac:
    Require at least autoconf 2.69 (released 2012).

    Avoid a warning about an obsolete macro from autoconf 2.70 onwards:
    s/AC_HELP_STRING/AS_HELP_/STRING/
2021-05-24 18:16:47 +10:00
Peter Wang
e5c89216a3 Avoid potential loop when checking for SIGSEGV signal handling.
configure.ac:
    Detect a signal handler being invoked over and over in a loop for a
    single SIGSEGV signal; fail the test in that case.

    This has been observed on Ubuntu 18.04.5 amd64 (running on a VPS),
    when using gcc -m32 to target x86. As far as I understand, this is
    not supposed to happen, so it is probably a bug.
2021-05-10 15:21:22 +10:00
Peter Wang
6a18491e03 Further prevent use of non-local gotos with PIC on x86 with GCC 5+.
configure.ac:
    Run the C compiler to check if it actually targets x86-64.
    Previously we assumed if $host is x86_64 then the C compiler will be
    targeting x86-64, but that is not true if gcc -m32 or gcc -mx32 is
    used.

    Then, as before, if the C compiler targets x86 and dynamic linking
    is enabled (except on Windows) and GCC is version 5+ then disable
    selection of any grades that use gcc labels.

runtime/mercury_goto.h:
    Report an error if the user tries to use non-local gotos with PIC
    on x86 with GCC 5+.

README.x86:
    Document the issue.

README.md:
    Add reference to README.x86.
2021-05-10 15:21:04 +10:00
Julien Fischer
4abc9b550e Support asm_fast grades on aarch64 Linux.
configure.ac:
    Set CFLAGS_FOR_GOTOS appropriately for aarch64 Linux.
2021-01-23 17:17:47 +11:00