[m-rev.] for review: deprecate --no-ansi and --no-ansi-c

Julien Fischer jfischer at opturion.com
Wed May 31 12:47:21 AEST 2023


For review by anyone.
---------------------

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.

Julien.

diff --git a/NEWS.md b/NEWS.md
index e3df315..f9682f7 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1132,6 +1132,9 @@ Changes to the Mercury compiler
    `MACOSX_DEPLOYMENT_TARGET` environment variable as the default value for the
    deployment target, if set.

+* The `--no-ansi-c` option has been deprecated and will be removed in a future
+  release.  The option has not had any effect for a long time.
+
  Changes to the Mercury debugger
  -------------------------------

diff --git a/bytecode/Mmakefile b/bytecode/Mmakefile
index 56f7e5a..0e5931d 100644
--- a/bytecode/Mmakefile
+++ b/bytecode/Mmakefile
@@ -91,8 +91,6 @@ MERCURY_INC	= \

  CFLAGS		= $(MERCURY_INC) -DMR_BYTECODE_CALLABLE -g

-MGNUCFLAGS-mb_disasm = --no-ansi
-
  MCFLAGS		= --trace shallow --generate-bytecode -O 0

  MLFLAGS		= --trace
diff --git a/compiler/Mercury.options b/compiler/Mercury.options
index 9920e4f..bbafe12 100644
--- a/compiler/Mercury.options
+++ b/compiler/Mercury.options
@@ -73,27 +73,10 @@ MCFLAGS-libs.md5                          = --no-warn-unused-imports
  MCFLAGS-libs.process_util                 = --no-warn-unused-imports
  MCFLAGS-make.build                        = --no-warn-unused-imports

-# process_util.m uses `kill' and `struct sigaction' from <signal.h>,
-# which are not available with `--ansi'.
-MGNUCFLAGS-libs.process_util              = --no-ansi
-
-# make.util.m uses POSIX IPC.
-MGNUCFLAGS-make.util                      = --no-ansi
-
-# If intermodule optimization is enabled, we also need to use `--no-ansi'
-# for the following modules, because they import process_util.
-MGNUCFLAGS-make.module_dep_file           = --no-ansi
-MGNUCFLAGS-make.module_target             = --no-ansi
-MGNUCFLAGS-make.program_target            = --no-ansi
-
  MCFLAGS-check_hlds.modes                  = --inline-vars-threshold 10000
  MCFLAGS-check_hlds.unique_modes           = --inline-vars-threshold 10000

-MCFLAGS-libs.process_util                 += --no-ansi-c
-MCFLAGS-make.module_dep_file              += --no-ansi-c
-MCFLAGS-make.module_target                += --no-ansi-c
-MCFLAGS-make.program_target               += --no-ansi-c
-MCFLAGS-make.util                         += --no-ansi-c --no-halt-at-warn
+MCFLAGS-make.util                         += --no-halt-at-warn

  MCFLAGS-backend_libs.bytecode_data           += --no-warn-implicit-stream-calls
  MCFLAGS-bytecode_backend.bytecode            += --no-warn-implicit-stream-calls
diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
index 23a2a83..9b0d217 100644
--- a/compiler/compile_target_code.m
+++ b/compiler/compile_target_code.m
@@ -414,14 +414,6 @@ gather_c_compiler_flags(Globals, PIC, AllCFlags) :-
          OptimizeC = do_not_opt_c,
          OptimizeOpt = ""
      ),
-    globals.lookup_bool_option(Globals, ansi_c, Ansi),
-    (
-        Ansi = yes,
-        globals.lookup_string_option(Globals, cflags_for_ansi, AnsiOpt)
-    ;
-        Ansi = no,
-        AnsiOpt = ""
-    ),
      InlineAlloc = OptTuple ^ ot_inline_alloc,
      (
          InlineAlloc = inline_alloc,
@@ -500,7 +492,6 @@ gather_c_compiler_flags(Globals, PIC, AllCFlags) :-
          SanitizerOpts, " ",
          TypeLayoutOpt,
          InlineAllocOpt,
-        AnsiOpt, " ",
          C_FnAlignOpt,
          WarningOpt, " ",
          CFLAGS, " ",
diff --git a/compiler/options.m b/compiler/options.m
index ac1b4fe..ecbab5a 100644
--- a/compiler/options.m
+++ b/compiler/options.m
@@ -6333,9 +6333,7 @@ options_help_target_code_compilation(Stream, !IO) :-
          "\tDon't enable the C compiler's optimizations.",

          "--no-ansi-c",
-        "\tDon't specify to the C compiler that the ANSI dialect",
-        "\tof C should be used. Use the full contents of system",
-        "\theaders, rather than the ANSI subset.",
+        "\tThis option is deprecated and does not have any effect.",

          "--c-debug",
          "\tEnable debugging of the generated C code.",
@@ -6368,13 +6366,14 @@ options_help_target_code_compilation(Stream, !IO) :-

          % The --cflags-for-regs, --cflags-for-gotos,
          % --cflags-for-threads, --cflags-for-pic, --cflags-for-lto,
-        % --cflags-for-warnings, --cflags-for-ansi,
-        % --cflags-for-optimization, --cflags-for-sanitizers,
-        % --c-flag-to-name-object-file,
+        % --cflags-for-warnings, --cflags-for-optimization,
+        % --cflags-for-sanitizers, --c-flag-to-name-object-file,
          % --object-file-extension and --pic-object-file-extension
          % options are reserved for use by the `mmc' script;
          % they are deliberately not documented.

+        % --cflags-for-ansi is deprecated and no longer has any effect.
+
          "--javac <javac>",
          "--java-compiler <javac>",
          "\tSpecify which Java compiler to use. The default is `javac'.",
diff --git a/configure.ac b/configure.ac
index 7c205f7..69d87ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4388,24 +4388,6 @@ OPT_FLAGS_FOR_CLANG="-O0"
  case "$mercury_cv_cc_type" in

      gcc*)
-        # We no longer pass -ansi to GCC on any system for the following
-        # reasons:
-        #
-        # * It restricts the dialect of C used to C90 and that prevents us
-        #   from using various C99 library features. Every version of GCC we
-        #   support provides those features so there is no point in doing this.
-        # * It causes complications with the header files on some systems.
-        #   Notably with the definitions of the types off_t and off64_t
-        #   on MinGW systems.
-        # * This setting also affects the compilation of user written C code in
-        #   foreign_proc and foreign code pragmas.
-        #
-        # NOTE: the --no-ansi option supported by the mgnuc script does
-        # more than simply pass the value of CFLAGS_FOR_ANSI to the C compiler.
-        # (See that script for details.)
-        #
-        CFLAGS_FOR_ANSI=
-
          # For a full list of the other gcc warnings that we don't enable,
          # and why, see scripts/mgnuc.in.
          CFLAGS_FOR_WARNINGS="-Wall -Wwrite-strings -Wshadow -Wmissing-prototypes -Wno-unused -Wno-uninitialized -Wstrict-prototypes"
@@ -4443,11 +4425,6 @@ case "$mercury_cv_cc_type" in
          ;;

      clang*)
-
-        # We do not compile with -ansi when using clang because that (currently) puts
-        # clang into C89 mode and we want to use C99's inline keyword with clang.
-        CFLAGS_FOR_ANSI=
-
          # XXX we need go through the warning and optimization options for clang
          # more carefully.
          CFLAGS_FOR_WARNINGS="-w"
@@ -4469,7 +4446,6 @@ case "$mercury_cv_cc_type" in
          ;;

      msvc*)
-        CFLAGS_FOR_ANSI=
          # Suppress the MSVC banner message.
          CFLAGS_FOR_WARNINGS="-nologo"
          CFLAGS_FOR_OPT=
@@ -4485,7 +4461,6 @@ case "$mercury_cv_cc_type" in
          ;;

      *)
-        CFLAGS_FOR_ANSI=
          CFLAGS_FOR_OPT="-O"
          CFLAGS_FOR_WARNINGS=
          CFLAGS_FOR_DEBUG="-g"
@@ -4496,7 +4471,6 @@ esac

  CFLAGS_FOR_OPT="$CFLAGS_FOR_OPT $CFLAGS_FOR_NO_STRICT_ALIASING"

-AC_SUBST([CFLAGS_FOR_ANSI])
  AC_SUBST([CFLAGS_FOR_WARNINGS])
  AC_SUBST([CFLAGS_FOR_OPT])
  AC_SUBST([CFLAGS_FOR_DEBUG])
diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index 07682ce..a06b1f5 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -9977,9 +9977,7 @@ Don't enable the C compiler's optimizations.
  @sp 1
  @item --no-ansi-c
  @findex --no-ansi-c
-Don't specify to the C compiler that the ANSI dialect
-of C should be used.  Use the full contents of system
-headers, rather than the ANSI subset.
+This option is deprectaed and has no effect.

  @sp 1
  @item --inline-alloc
diff --git a/extras/odbc/odbc.m b/extras/odbc/odbc.m
index 0aad8ff..dba2635 100644
--- a/extras/odbc/odbc.m
+++ b/extras/odbc/odbc.m
@@ -46,8 +46,6 @@
  %   removed from sqltypes.h.
  %   (For legal reasons a patch cannot be included in the Mercury
  %   distribution.)
-%   The Microsoft ODBC header files also use some C++ style comments,
-%   so you need to use the `--no-ansi' option to mgnuc.
  %
  % To do:
  %
diff --git a/library/Mercury.options b/library/Mercury.options
index 6a62178..2442c70 100644
--- a/library/Mercury.options
+++ b/library/Mercury.options
@@ -33,11 +33,6 @@ MCFLAGS-std_util                += --no-halt-at-warn
  MCFLAGS-dir                     += --no-halt-at-warn
  MCFLAGS-exception               += --no-halt-at-warn

-# io.m uses library features that are supported by POSIX but which are not
-# part of ANSI C, such as `struct stat', fileno(), and putenv().
-# We need to pass --no-ansi to mgnuc to ensure that these are declared.
-MGNUCFLAGS-io                   += --no-ansi
-
  # This is needed to avoid errors on the calls that implement e.g. io.format/3
  # in terms of io.format/4, and string.format/2 in terms of string.format/3.
  # varset.trans_opt includes the relevant part of string.opt.
diff --git a/runtime/Mmakefile b/runtime/Mmakefile
index d28fbbe..19004ac 100644
--- a/runtime/Mmakefile
+++ b/runtime/Mmakefile
@@ -250,7 +250,7 @@ CFLAGS	+= $(DLL_CFLAGS)
  # in the runtime can be debugged without having to recompile it. The cost
  # of doing this is negligible. The runtime can be compiled without
  # debugging enabled by removing the `--c-debug' flag below.
-MGNUCFLAGS	+= --c-debug --no-ansi
+MGNUCFLAGS	+= --c-debug

  #-----------------------------------------------------------------------------#

diff --git a/scripts/Mercury.config.bootstrap.in b/scripts/Mercury.config.bootstrap.in
index 69d7888..e01eb26 100644
--- a/scripts/Mercury.config.bootstrap.in
+++ b/scripts/Mercury.config.bootstrap.in
@@ -63,7 +63,6 @@ DEFAULT_MCFLAGS=\
  		--csharp-compiler-type "$(MERCURY_CSHARP_COMPILER_TYPE)" \
  		--cli-interpreter "$(MERCURY_CLI_INTERPRETER)" \
  		--grade "$(MERCURY_DEFAULT_GRADE)" \
-		--cflags-for-ansi "@CFLAGS_FOR_ANSI@" \
  		--cflags-for-optimization "@CFLAGS_FOR_OPT@" \
  		--cflags-for-warnings "@CFLAGS_FOR_WARNINGS@" \
  		--cflags-for-threads "@CFLAGS_FOR_THREADS@" \
diff --git a/scripts/Mercury.config.in b/scripts/Mercury.config.in
index adeaf23..1ec5704 100644
--- a/scripts/Mercury.config.in
+++ b/scripts/Mercury.config.in
@@ -58,7 +58,6 @@ DEFAULT_MCFLAGS=\
  		--csharp-compiler "$(MERCURY_CSHARP_COMPILER)" \
  		--csharp-compiler-type "$(MERCURY_CSHARP_COMPILER_TYPE)" \
  		--cli-interpreter "$(MERCURY_CLI_INTERPRETER)" \
-		--cflags-for-ansi "@CFLAGS_FOR_ANSI@" \
  		--cflags-for-optimization "@CFLAGS_FOR_OPT@" \
  		--cflags-for-warnings "@CFLAGS_FOR_WARNINGS@" \
  		--cflags-for-threads "@CFLAGS_FOR_THREADS@" \
diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in
index 45e65e6..c836105 100644
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -5,7 +5,7 @@
  # @configure_input@
  #---------------------------------------------------------------------------#
  # Copyright (C) 1995-2007, 2010-2012 The University of Melbourne.
-# Copyright (C) 2013-2020, 2022 The Mercury team.
+# Copyright (C) 2013-2020, 2022-2023 The Mercury team.
  # This file may only be copied under the terms of the GNU General
  # Public License - see the file COPYING in the Mercury distribution.
  #---------------------------------------------------------------------------#
@@ -37,7 +37,6 @@ TMPDIR=${TMPDIR=/tmp}

  case "${C_COMPILER_TYPE}" in
      gcc*)
-        ANSI_OPTS="${CFLAGS_FOR_ANSI}"
          CHECK_OPTS="
              -Wall -Wwrite-strings
              -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wno-unused"
@@ -77,7 +76,6 @@ case "${C_COMPILER_TYPE}" in
          COMPILER=gcc
          ;;
      clang*)
-        ANSI_OPTS=
          CHECK_OPTS="-w"
          OPT_OPTS="@OPT_FLAGS_FOR_CLANG@ ${CFLAGS_FOR_NO_STRICT_ALIASING} -fomit-frame-pointer"
          DEBUG_OPTS="-g"
@@ -86,7 +84,6 @@ case "${C_COMPILER_TYPE}" in
          COMPILER=clang
          ;;
      msvc*)
-        ANSI_OPTS=""
          CHECK_OPTS="-nologo"    # Suppress the MSVC banner message.
          OPT_OPTS="-O1"
          # See README.MS-VisualC for why we don't enable C level debugging.
@@ -97,7 +94,6 @@ case "${C_COMPILER_TYPE}" in
          COMPILER=cl
          ;;
      *)
-        ANSI_OPTS=
          CHECK_OPTS=
          OPT_OPTS="-O"
          DEBUG_OPTS="-g"
@@ -131,7 +127,7 @@ Options:
      -v, --verbose
          Echo gcc command before executing it.
      --no-ansi
-        Use the full contents of system headers, rather than the ANSI subset.
+        This option is deprecatd and no longer has any effect.
      --no-check
          Don't enable any of gcc's warnings.
      -g, --c-debug
@@ -156,8 +152,8 @@ ${grade_usage}

  Description:
      This runs gcc with the appropriate options for compiling Mercury programs.
-    Normally it invokes gcc in ANSI mode with almost all warnings enabled,
-    but this can be changed using the \`--no-ansi' or \`--no-check' options.
+    Normally it invokes gcc with almost all warnings enabled,
+    but this can be changed using \`--no-check' option.
  Environment variables:
      MERCURY_DEFAULT_GRADE.
  Files:
@@ -309,15 +305,6 @@ esac
  case ${thread_safe} in
      true)
          THREAD_OPTS="-DMR_THREAD_SAFE ${CFLAGS_FOR_THREADS}"
-        case ${FULLARCH} in
-            *linux*)
-                # Don't use -ansi under Linux or we get parse errors
-                # at sigset_t in the pthreads headers. This doesn't seem
-                # to be necessary for recent versions of Linux/glibc
-                # (e.g. glibc 2.1.2), but I've left it in so we can remain
-                # compatible with older versions.
-                ANSI_OPTS=""
-        esac
          ;;
      false)
          THREAD_OPTS=""
@@ -561,14 +548,6 @@ case "${FULLARCH}" in
                  ;;
          esac
          ;;
-    *-solaris*|*-sunos*)
-        # The solaris headers for pthreads are not ANSI :-(
-        case ${thread_safe} in
-            true)
-                ANSI_OPTS=""
-                ;;
-        esac
-        ;;
  esac
  # gcc versions 9-12 replace calls to strcmp and related functions with
  # specialised code when some of the arguments are string constants.
@@ -692,7 +671,6 @@ case ${asm_labels},${do_filter_cc} in
  esac

  ALL_CC_OPTS="${MERC_ALL_C_INCL_DIRS}\
-    ${ANSI_OPTS}\
      ${CHECK_OPTS}\
      ${OPT_OPTS}\
      ${LTO_OPTS}\
diff --git a/scripts/mgnuc_file_opts.sh-subr b/scripts/mgnuc_file_opts.sh-subr
index 22e3a8a..f217af3 100644
--- a/scripts/mgnuc_file_opts.sh-subr
+++ b/scripts/mgnuc_file_opts.sh-subr
@@ -1,7 +1,8 @@
  #---------------------------------------------------------------------------#
  # vim: ts=4 sw=4 expandtab ft=sh
  #---------------------------------------------------------------------------#
-# Copyright (C) 2005 The University of Melbourne.
+# Copyright (C) 2005, 2010 The University of Melbourne.
+# Copyright (C) 2014, 2018, 2020, 2022 The Mercury team.
  # This file may only be copied under the terms of the GNU General
  # Public License - see the file COPYING in the Mercury distribution.
  #---------------------------------------------------------------------------#
@@ -30,7 +31,6 @@
              ;;

          --no-ansi)
-            ANSI_OPTS=
              ;;

          --no-check)
diff --git a/tests/hard_coded/Mercury.options b/tests/hard_coded/Mercury.options
index 9b3e4d1..1d2e33d 100644
--- a/tests/hard_coded/Mercury.options
+++ b/tests/hard_coded/Mercury.options
@@ -79,7 +79,6 @@ MCFLAGS-reuse_double =          --ctgc
  MCFLAGS-reuse_ho =              --ctgc --no-optimise-higher-order
  MCFLAGS-sharing_comb =          --ctgc --structure-sharing-widening 2
  MCFLAGS-simplify_multi_arm_switch = -O3
-MCFLAGS-spawn_native =          --no-ansi-c
  MCFLAGS-string_alignment_bug =  --no-warn-obsolete
  MCFLAGS-subtype_pack =          --allow-packing-dummies
  MCFLAGS-subtype_rtti = \
diff --git a/tests/valid/Mercury.options b/tests/valid/Mercury.options
index 520c6b8..d48fd42 100644
--- a/tests/valid/Mercury.options
+++ b/tests/valid/Mercury.options
@@ -133,7 +133,5 @@ MCFLAGS-unify_typeinfo_bug	= -O3
  MCFLAGS-uniq_mode_inf_bug	= --infer-all
  MCFLAGS-vn_float		= -O5
  MCFLAGS-zero_arity		= --infer-modes
-MGNUCFLAGS-reg_bug		= --no-ansi
-MCFLAGS-reg_bug			= --no-ansi-c
  MCFLAGS-unknown_warning		= --no-halt-at-warn
  MCFLAGS-use_import_only_for_instance	= --warn-unused-imports --halt-at-warn
diff --git a/trace/Mmakefile b/trace/Mmakefile
index eb5f6f1..631265a 100644
--- a/trace/Mmakefile
+++ b/trace/Mmakefile
@@ -173,7 +173,7 @@ Mmake.trace.params: ;
  #-----------------------------------------------------------------------------#

  CFLAGS		+= $(DLL_CFLAGS)
-MGNUCFLAGS	+= --c-debug --no-ansi
+MGNUCFLAGS	+= --c-debug

  #-----------------------------------------------------------------------------#

diff --git a/util/Mmakefile b/util/Mmakefile
index 54674dd..9c8d280 100644
--- a/util/Mmakefile
+++ b/util/Mmakefile
@@ -31,9 +31,6 @@ else
      GETOPT_SRC=
  endif

-# mkinit.c needs `struct stat'
-MGNUCFLAGS-mkinit = --no-ansi
-
  # For the C distribution mfiltercc may not be available until after we build
  # it here.
  MGNUCFLAGS-mfiltercc = --no-filter-cc


More information about the reviews mailing list