1/19 modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite.

Message ID E1ohukQ-00BlzX-GX@lancelot
State New
Headers
Series 1/19 modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite. |

Commit Message

Gaius Mulley Oct. 10, 2022, 3:31 p.m. UTC
  This patch set contains the non machine generated changes found in /
for example the language die and documentation changes.  It also
contains the changes to the top level build Makefile infastructure
and the install.texi sourcebuild.texi documentation.

 
------8<----------8<----------8<----------8<----------8<----------8<----
  

Comments

Richard Biener Nov. 11, 2022, 1:47 p.m. UTC | #1
On Mon, Oct 10, 2022 at 5:36 PM Gaius Mulley via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
>
> This patch set contains the non machine generated changes found in /
> for example the language die and documentation changes.  It also
> contains the changes to the top level build Makefile infastructure
> and the install.texi sourcebuild.texi documentation.

I couldn't spot any issue besides the docs now being written in
Sphinx, so this part
is OK (with the docs ported)

Thanks,
Richard.

>
> ------8<----------8<----------8<----------8<----------8<----------8<----
> diff -ruw gcc-git-master/configure.ac gcc-git-devel-modula2/configure.ac
> --- gcc-git-master/configure.ac 2022-10-07 20:21:09.001978462 +0100
> +++ gcc-git-devel-modula2/configure.ac  2022-10-07 20:21:18.522095368 +0100
> @@ -140,7 +140,7 @@
>  # binutils, gas and ld appear in that order because it makes sense to run
>  # "make check" in that particular order.
>  # If --enable-gold is used, "gold" may replace "ld".
> -host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools c++tools"
> +host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gm2tools gotools c++tools"
>
>  # these libraries are built for the target environment, and are built after
>  # the host libraries and the host tools (which may be a cross compiler)
> @@ -162,6 +162,7 @@
>                 target-libffi \
>                 target-libobjc \
>                 target-libada \
> +               target-libgm2 \
>                 target-libgo \
>                 target-libphobos \
>                 target-zlib"
> @@ -459,6 +460,14 @@
>    noconfigdirs="$noconfigdirs gnattools"
>  fi
>
> +AC_ARG_ENABLE(libgm2,
> +[AS_HELP_STRING([--enable-libgm2], [build libgm2 directory])],
> +ENABLE_LIBGM2=$enableval,
> +ENABLE_LIBGM2=no)
> +if test "${ENABLE_LIBGM2}" != "yes" ; then
> +  noconfigdirs="$noconfigdirs gm2tools"
> +fi
> +
>  AC_ARG_ENABLE(libssp,
>  [AS_HELP_STRING([--enable-libssp], [build libssp directory])],
>  ENABLE_LIBSSP=$enableval,
> @@ -3616,6 +3625,7 @@
>  NCN_STRICT_CHECK_TARGET_TOOLS(GFORTRAN_FOR_TARGET, gfortran)
>  NCN_STRICT_CHECK_TARGET_TOOLS(GOC_FOR_TARGET, gccgo)
>  NCN_STRICT_CHECK_TARGET_TOOLS(GDC_FOR_TARGET, gdc)
> +NCN_STRICT_CHECK_TARGET_TOOLS(GM2_FOR_TARGET, gm2)
>
>  ACX_CHECK_INSTALLED_TARGET_TOOL(AR_FOR_TARGET, ar)
>  ACX_CHECK_INSTALLED_TARGET_TOOL(AS_FOR_TARGET, as)
> @@ -3654,6 +3664,8 @@
>                 [gcc/gccgo -B$$r/$(HOST_SUBDIR)/gcc/], go)
>  GCC_TARGET_TOOL(gdc, GDC_FOR_TARGET, GDC,
>                 [gcc/gdc -B$$r/$(HOST_SUBDIR)/gcc/], d)
> +GCC_TARGET_TOOL(gm2, GM2_FOR_TARGET, GM2,
> +               [gcc/gm2 -B$$r/$(HOST_SUBDIR)/gcc/], m2)
>  GCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD, [ld/ld-new])
>  GCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO)
>  GCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM, [binutils/nm-new])
> @@ -3780,6 +3792,9 @@
>  # Specify what files to not compare during bootstrap.
>
>  compare_exclusions="gcc/cc*-checksum\$(objext) | gcc/ada/*tools/*"
> +compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/M2Version*"
> +compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/SYSTEM*"
> +compare_exclusions="$compare_exclusions | gcc/m2/gm2version*"
>  case "$target" in
>    hppa*64*-*-hpux*) ;;
>    powerpc*-ibm-aix*) compare_exclusions="$compare_exclusions | *libgomp*\$(objext)" ;;
> diff -ruw gcc-git-master/gcc/doc/sourcebuild.texi gcc-git-devel-modula2/gcc/doc/sourcebuild.texi
> --- gcc-git-master/gcc/doc/sourcebuild.texi     2022-10-07 20:21:09.761987791 +0100
> +++ gcc-git-devel-modula2/gcc/doc/sourcebuild.texi      2022-10-07 20:21:18.606096399 +0100
> @@ -97,6 +97,9 @@
>  @item libgfortran
>  The Fortran runtime library.
>
> +@item libgm2
> +The Modula-2 runtime library.
> +
>  @item libgo
>  The Go runtime library.  The bulk of this library is mirrored from the
>  @uref{https://github.com/@/golang/go, master Go repository}.
> @@ -187,13 +190,12 @@
>  @item @var{language}
>  Subdirectories for various languages.  Directories containing a file
>  @file{config-lang.in} are language subdirectories.  The contents of
> -the subdirectories @file{c} (for C), @file{cp} (for C++),
> -@file{objc} (for Objective-C), @file{objcp} (for Objective-C++),
> -and @file{lto} (for LTO) are documented in this
> -manual (@pxref{Passes, , Passes and Files of the Compiler});
> -those for other languages are not.  @xref{Front End, ,
> -Anatomy of a Language Front End}, for details of the files in these
> -directories.
> +the subdirectories @file{c} (for C), @file{cp} (for C++), @file{m2}
> +(for Modula-2), @file{objc} (for Objective-C), @file{objcp} (for
> +Objective-C++), and @file{lto} (for LTO) are documented in this manual
> +(@pxref{Passes, , Passes and Files of the Compiler}); those for other
> +languages are not.  @xref{Front End, , Anatomy of a Language Front
> +End}, for details of the files in these directories.
>
>  @item common
>  Source files shared between the compiler drivers (such as
> diff -ruw gcc-git-master/gcc/doc/install.texi gcc-git-devel-modula2/gcc/doc/install.texi
> --- gcc-git-master/gcc/doc/install.texi 2022-10-07 20:21:09.749987645 +0100
> +++ gcc-git-devel-modula2/gcc/doc/install.texi  2022-10-07 20:21:18.602096351 +0100
> @@ -1832,18 +1832,19 @@
>  @smallexample
>  grep ^language= */config-lang.in
>  @end smallexample
> -Currently, you can use any of the following:
> -@code{all}, @code{default}, @code{ada}, @code{c}, @code{c++}, @code{d},
> -@code{fortran}, @code{go}, @code{jit}, @code{lto}, @code{objc}, @code{obj-c++}.
> -Building the Ada compiler has special requirements, see below.
> -If you do not pass this flag, or specify the option @code{default}, then the
> -default languages available in the @file{gcc} sub-tree will be configured.
> -Ada, D, Go, Jit, and Objective-C++ are not default languages.  LTO is not a
> -default language, but is built by default because @option{--enable-lto} is
> -enabled by default.  The other languages are default languages.  If
> -@code{all} is specified, then all available languages are built.  An
> -exception is @code{jit} language, which requires
> -@option{--enable-host-shared} to be included with @code{all}.
> +Currently, you can use any of the following: @code{all},
> +@code{default}, @code{ada}, @code{c}, @code{c++}, @code{d},
> +@code{fortran}, @code{go}, @code{jit}, @code{lto}, @code{m2},
> +@code{objc}, @code{obj-c++}.  Building the Ada compiler has special
> +requirements, see below.  If you do not pass this flag, or specify the
> +option @code{default}, then the default languages available in the
> +@file{gcc} sub-tree will be configured.  Ada, D, Go, Jit,
> +Objective-C++ and Modula-2 are not default languages.  LTO is not a
> +default language, but is built by default because
> +@option{--enable-lto} is enabled by default.  The other languages are
> +default languages.  If @code{all} is specified, then all available
> +languages are built.  An exception is @code{jit} language, which
> +requires @option{--enable-host-shared} to be included with @code{all}.
>
>  @item --enable-stage1-languages=@var{lang1},@var{lang2},@dots{}
>  Specify that a particular subset of compilers and their runtime
> @@ -1866,6 +1867,10 @@
>  previous Ada build procedures, when it was required to explicitly
>  do a @samp{make -C gcc gnatlib_and_tools}.
>
> +@item --disable-libgm2
> +Specify that the run-time libraries and tools used by Modula-2 should not
> +be built.  This can be useful for debugging.
> +
>  @item --disable-libsanitizer
>  Specify that the run-time libraries for the various sanitizers should
>  not be built.
> @@ -3126,10 +3131,10 @@
>  In order to run sets of tests selectively, there are targets
>  @samp{make check-gcc} and language specific @samp{make check-c},
>  @samp{make check-c++}, @samp{make check-d} @samp{make check-fortran},
> -@samp{make check-ada}, @samp{make check-objc}, @samp{make check-obj-c++},
> -@samp{make check-lto}
> -in the @file{gcc} subdirectory of the object directory.  You can also
> -just run @samp{make check} in a subdirectory of the object directory.
> +@samp{make check-ada}, @samp{make check-m2}, @samp{make check-objc},
> +@samp{make check-obj-c++}, @samp{make check-lto} in the @file{gcc}
> +subdirectory of the object directory.  You can also just run
> +@samp{make check} in a subdirectory of the object directory.
>
>
>  A more selective way to just run all @command{gcc} execute tests in the
> diff -ruw gcc-git-master/gcc/dwarf2out.cc gcc-git-devel-modula2/gcc/dwarf2out.cc
> --- gcc-git-master/gcc/dwarf2out.cc     2022-10-07 20:21:09.769987890 +0100
> +++ gcc-git-devel-modula2/gcc/dwarf2out.cc      2022-10-07 20:21:18.614096498 +0100
> @@ -25206,6 +25206,8 @@
>      }
>    else if (strcmp (language_string, "GNU F77") == 0)
>      language = DW_LANG_Fortran77;
> +  else if (strcmp (language_string, "GNU Modula-2") == 0)
> +    language = DW_LANG_Modula2;
>    else if (dwarf_version >= 3 || !dwarf_strict)
>      {
>        if (strcmp (language_string, "GNU Ada") == 0)
> diff -ruw gcc-git-master/Makefile.def gcc-git-devel-modula2/Makefile.def
> --- gcc-git-master/Makefile.def 2022-10-07 20:21:08.985978266 +0100
> +++ gcc-git-devel-modula2/Makefile.def  2022-10-07 20:21:18.510095220 +0100
> @@ -186,6 +186,7 @@
>  target_modules = { module= zlib; bootstrap=true; };
>  target_modules = { module= rda; };
>  target_modules = { module= libada; };
> +target_modules = { module= libgm2; lib_path=.libs; };
>  target_modules = { module= libgomp; bootstrap= true; lib_path=.libs; };
>  target_modules = { module= libitm; lib_path=.libs; };
>  target_modules = { module= libatomic; bootstrap=true; lib_path=.libs; };
> @@ -308,6 +309,8 @@
>  flags_to_pass = { flag= GOCFLAGS_FOR_TARGET ; };
>  flags_to_pass = { flag= GDC_FOR_TARGET ; };
>  flags_to_pass = { flag= GDCFLAGS_FOR_TARGET ; };
> +flags_to_pass = { flag= GM2_FOR_TARGET ; };
> +flags_to_pass = { flag= GM2FLAGS_FOR_TARGET ; };
>  flags_to_pass = { flag= LD_FOR_TARGET ; };
>  flags_to_pass = { flag= LIPO_FOR_TARGET ; };
>  flags_to_pass = { flag= LDFLAGS_FOR_TARGET ; };
> @@ -619,6 +622,8 @@
>  dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
>  dependencies = { module=all-target-libgo; on=all-target-libffi; };
>  dependencies = { module=all-target-libgo; on=all-target-libatomic; };
> +dependencies = { module=configure-target-libgm2; on=all-target-libstdc++-v3; };
> +dependencies = { module=all-target-libgm2; on=all-target-libatomic; };
>  dependencies = { module=configure-target-libphobos; on=configure-target-libbacktrace; };
>  dependencies = { module=configure-target-libphobos; on=configure-target-zlib; };
>  dependencies = { module=all-target-libphobos; on=all-target-libbacktrace; };
> @@ -678,6 +683,8 @@
>  languages = { language=go;     gcc-check-target=check-go;
>                                 lib-check-target=check-target-libgo;
>                                 lib-check-target=check-gotools; };
> +languages = { language=m2;     gcc-check-target=check-m2;
> +                               lib-check-target=check-target-libgm2; };
>  languages = { language=d;      gcc-check-target=check-d;
>                                 lib-check-target=check-target-libphobos; };
>  languages = { language=jit;    gcc-check-target=check-jit; };
> diff -ruw gcc-git-master/Makefile.tpl gcc-git-devel-modula2/Makefile.tpl
> --- gcc-git-master/Makefile.tpl 2022-10-07 20:21:08.989978315 +0100
> +++ gcc-git-devel-modula2/Makefile.tpl  2022-10-07 20:21:18.518095319 +0100
> @@ -166,6 +166,8 @@
>         GOCFLAGS="$(GOCFLAGS_FOR_BUILD)"; export GOCFLAGS; \
>         GDC="$(GDC_FOR_BUILD)"; export GDC; \
>         GDCFLAGS="$(GDCFLAGS_FOR_BUILD)"; export GDCFLAGS; \
> +       GM2="$(GM2_FOR_BUILD)"; export GM2; \
> +       GM2FLAGS="$(GM2FLAGS_FOR_BUILD)"; export GM2FLAGS; \
>         DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \
>         DSYMUTIL="$(DSYMUTIL_FOR_BUILD)"; export DSYMUTIL; \
>         LD="$(LD_FOR_BUILD)"; export LD; \
> @@ -204,6 +206,7 @@
>         GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \
>         GOC="$(GOC)"; export GOC; \
>         GDC="$(GDC)"; export GDC; \
> +       GM2="$(GM2)"; export GM2; \
>         AR="$(AR)"; export AR; \
>         AS="$(AS)"; export AS; \
>         CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
> @@ -307,6 +310,7 @@
>         GFORTRAN="$(GFORTRAN_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GFORTRAN; \
>         GOC="$(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GOC; \
>         GDC="$(GDC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GDC; \
> +       GM2="$(GM2_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GM2; \
>         DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
>         DSYMUTIL="$(DSYMUTIL_FOR_TARGET)"; export DSYMUTIL; \
>         LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \
> @@ -373,6 +377,7 @@
>  GFORTRAN_FOR_BUILD = @GFORTRAN_FOR_BUILD@
>  GOC_FOR_BUILD = @GOC_FOR_BUILD@
>  GDC_FOR_BUILD = @GDC_FOR_BUILD@
> +GM2_FOR_BUILD = @GM2_FOR_BUILD@
>  LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
>  LD_FOR_BUILD = @LD_FOR_BUILD@
>  NM_FOR_BUILD = @NM_FOR_BUILD@
> @@ -443,6 +448,7 @@
>  LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
>  GOCFLAGS = $(CFLAGS)
>  GDCFLAGS = $(CFLAGS)
> +GM2FLAGS = $(CFLAGS)
>
>  # Pass additional PGO and LTO compiler options to the PGO build.
>  BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS)
> @@ -578,6 +584,7 @@
>  GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@
>  GOC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GOC_FOR_TARGET@
>  GDC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GDC_FOR_TARGET@
> +GM2_FOR_TARGET=$(STAGE_CC_WRAPPER) @GM2_FOR_TARGET@
>  DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
>  DSYMUTIL_FOR_TARGET=@DSYMUTIL_FOR_TARGET@
>  LD_FOR_TARGET=@LD_FOR_TARGET@
> @@ -603,6 +610,7 @@
>  LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
>  LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
>  LDFLAGS_FOR_TARGET = @LDFLAGS_FOR_TARGET@
> +GM2FLAGS_FOR_TARGET = -O2 -g
>  GOCFLAGS_FOR_TARGET = -O2 -g
>  GDCFLAGS_FOR_TARGET = -O2 -g
>
> @@ -709,6 +717,7 @@
>         'GFORTRAN=$(GFORTRAN)' \
>         'GOC=$(GOC)' \
>         'GDC=$(GDC)' \
> +       'GM2=$(GM2)' \
>         'LD=$(LD)' \
>         'LIPO=$(LIPO)' \
>         'NM=$(NM)' \
> @@ -735,6 +744,7 @@
>         CC="$${CC}" CC_FOR_BUILD="$${CC_FOR_BUILD}" \
>         CXX="$${CXX}" CXX_FOR_BUILD="$${CXX_FOR_BUILD}" \
>         GDC="$${GDC}" GDC_FOR_BUILD="$${GDC_FOR_BUILD}" \
> +       GM2="$${GM2}" GM2_FOR_BUILD="$${GM2_FOR_BUILD}" \
>         GNATBIND="$${GNATBIND}" \
>         LDFLAGS="$${LDFLAGS}" \
>         HOST_LIBS="$${HOST_LIBS}" \
> @@ -770,6 +780,8 @@
>         'GOCFLAGS=$$(GOCFLAGS_FOR_TARGET)' \
>         'GDC=$$(GDC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
>         'GDCFLAGS=$$(GDCFLAGS_FOR_TARGET)' \
> +       'GM2=$$(GM2_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
> +       'GM2FLAGS=$$(GM2FLAGS_FOR_TARGET)' \
>         'LD=$(COMPILER_LD_FOR_TARGET)' \
>         'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
>         'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
> @@ -796,6 +808,7 @@
>  # cross-building scheme.
>  EXTRA_GCC_FLAGS = \
>         "GCC_FOR_TARGET=$(GCC_FOR_TARGET) $$TFLAGS" \
> +       "GM2_FOR_TARGET=$(GM2_FOR_TARGET) $$TFLAGS" \
>         "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
>         "`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
>
  
Gaius Mulley Nov. 11, 2022, 7:38 p.m. UTC | #2
Richard Biener <richard.guenther@gmail.com> writes:

> On Mon, Oct 10, 2022 at 5:36 PM Gaius Mulley via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>>
>>
>> This patch set contains the non machine generated changes found in /
>> for example the language die and documentation changes.  It also
>> contains the changes to the top level build Makefile infastructure
>> and the install.texi sourcebuild.texi documentation.
>
> I couldn't spot any issue besides the docs now being written in
> Sphinx, so this part
> is OK (with the docs ported)

awesome, many thanks - I'm working on the tool
(gcc/m2/tools-src/def2doc.py) which generates Sphinx from the modula-2
library sources and should post this in a few days time,

regards,
Gaius
  

Patch

diff -ruw gcc-git-master/configure.ac gcc-git-devel-modula2/configure.ac
--- gcc-git-master/configure.ac	2022-10-07 20:21:09.001978462 +0100
+++ gcc-git-devel-modula2/configure.ac	2022-10-07 20:21:18.522095368 +0100
@@ -140,7 +140,7 @@ 
 # binutils, gas and ld appear in that order because it makes sense to run
 # "make check" in that particular order.
 # If --enable-gold is used, "gold" may replace "ld".
-host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools c++tools"
+host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gm2tools gotools c++tools"
 
 # these libraries are built for the target environment, and are built after
 # the host libraries and the host tools (which may be a cross compiler)
@@ -162,6 +162,7 @@ 
 		target-libffi \
 		target-libobjc \
 		target-libada \
+		target-libgm2 \
 		target-libgo \
 		target-libphobos \
 		target-zlib"
@@ -459,6 +460,14 @@ 
   noconfigdirs="$noconfigdirs gnattools"
 fi
 
+AC_ARG_ENABLE(libgm2,
+[AS_HELP_STRING([--enable-libgm2], [build libgm2 directory])],
+ENABLE_LIBGM2=$enableval,
+ENABLE_LIBGM2=no)
+if test "${ENABLE_LIBGM2}" != "yes" ; then
+  noconfigdirs="$noconfigdirs gm2tools"
+fi
+
 AC_ARG_ENABLE(libssp,
 [AS_HELP_STRING([--enable-libssp], [build libssp directory])],
 ENABLE_LIBSSP=$enableval,
@@ -3616,6 +3625,7 @@ 
 NCN_STRICT_CHECK_TARGET_TOOLS(GFORTRAN_FOR_TARGET, gfortran)
 NCN_STRICT_CHECK_TARGET_TOOLS(GOC_FOR_TARGET, gccgo)
 NCN_STRICT_CHECK_TARGET_TOOLS(GDC_FOR_TARGET, gdc)
+NCN_STRICT_CHECK_TARGET_TOOLS(GM2_FOR_TARGET, gm2)
 
 ACX_CHECK_INSTALLED_TARGET_TOOL(AR_FOR_TARGET, ar)
 ACX_CHECK_INSTALLED_TARGET_TOOL(AS_FOR_TARGET, as)
@@ -3654,6 +3664,8 @@ 
 		[gcc/gccgo -B$$r/$(HOST_SUBDIR)/gcc/], go)
 GCC_TARGET_TOOL(gdc, GDC_FOR_TARGET, GDC,
 		[gcc/gdc -B$$r/$(HOST_SUBDIR)/gcc/], d)
+GCC_TARGET_TOOL(gm2, GM2_FOR_TARGET, GM2,
+		[gcc/gm2 -B$$r/$(HOST_SUBDIR)/gcc/], m2)
 GCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD, [ld/ld-new])
 GCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO)
 GCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM, [binutils/nm-new])
@@ -3780,6 +3792,9 @@ 
 # Specify what files to not compare during bootstrap.
 
 compare_exclusions="gcc/cc*-checksum\$(objext) | gcc/ada/*tools/*"
+compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/M2Version*"
+compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/SYSTEM*"
+compare_exclusions="$compare_exclusions | gcc/m2/gm2version*"
 case "$target" in
   hppa*64*-*-hpux*) ;;
   powerpc*-ibm-aix*) compare_exclusions="$compare_exclusions | *libgomp*\$(objext)" ;;
diff -ruw gcc-git-master/gcc/doc/sourcebuild.texi gcc-git-devel-modula2/gcc/doc/sourcebuild.texi
--- gcc-git-master/gcc/doc/sourcebuild.texi	2022-10-07 20:21:09.761987791 +0100
+++ gcc-git-devel-modula2/gcc/doc/sourcebuild.texi	2022-10-07 20:21:18.606096399 +0100
@@ -97,6 +97,9 @@ 
 @item libgfortran
 The Fortran runtime library.
 
+@item libgm2
+The Modula-2 runtime library.
+
 @item libgo
 The Go runtime library.  The bulk of this library is mirrored from the
 @uref{https://github.com/@/golang/go, master Go repository}.
@@ -187,13 +190,12 @@ 
 @item @var{language}
 Subdirectories for various languages.  Directories containing a file
 @file{config-lang.in} are language subdirectories.  The contents of
-the subdirectories @file{c} (for C), @file{cp} (for C++),
-@file{objc} (for Objective-C), @file{objcp} (for Objective-C++),
-and @file{lto} (for LTO) are documented in this
-manual (@pxref{Passes, , Passes and Files of the Compiler});
-those for other languages are not.  @xref{Front End, ,
-Anatomy of a Language Front End}, for details of the files in these
-directories.
+the subdirectories @file{c} (for C), @file{cp} (for C++), @file{m2}
+(for Modula-2), @file{objc} (for Objective-C), @file{objcp} (for
+Objective-C++), and @file{lto} (for LTO) are documented in this manual
+(@pxref{Passes, , Passes and Files of the Compiler}); those for other
+languages are not.  @xref{Front End, , Anatomy of a Language Front
+End}, for details of the files in these directories.
 
 @item common
 Source files shared between the compiler drivers (such as
diff -ruw gcc-git-master/gcc/doc/install.texi gcc-git-devel-modula2/gcc/doc/install.texi
--- gcc-git-master/gcc/doc/install.texi	2022-10-07 20:21:09.749987645 +0100
+++ gcc-git-devel-modula2/gcc/doc/install.texi	2022-10-07 20:21:18.602096351 +0100
@@ -1832,18 +1832,19 @@ 
 @smallexample
 grep ^language= */config-lang.in
 @end smallexample
-Currently, you can use any of the following:
-@code{all}, @code{default}, @code{ada}, @code{c}, @code{c++}, @code{d},
-@code{fortran}, @code{go}, @code{jit}, @code{lto}, @code{objc}, @code{obj-c++}.
-Building the Ada compiler has special requirements, see below.
-If you do not pass this flag, or specify the option @code{default}, then the
-default languages available in the @file{gcc} sub-tree will be configured.
-Ada, D, Go, Jit, and Objective-C++ are not default languages.  LTO is not a
-default language, but is built by default because @option{--enable-lto} is
-enabled by default.  The other languages are default languages.  If
-@code{all} is specified, then all available languages are built.  An
-exception is @code{jit} language, which requires
-@option{--enable-host-shared} to be included with @code{all}.
+Currently, you can use any of the following: @code{all},
+@code{default}, @code{ada}, @code{c}, @code{c++}, @code{d},
+@code{fortran}, @code{go}, @code{jit}, @code{lto}, @code{m2},
+@code{objc}, @code{obj-c++}.  Building the Ada compiler has special
+requirements, see below.  If you do not pass this flag, or specify the
+option @code{default}, then the default languages available in the
+@file{gcc} sub-tree will be configured.  Ada, D, Go, Jit,
+Objective-C++ and Modula-2 are not default languages.  LTO is not a
+default language, but is built by default because
+@option{--enable-lto} is enabled by default.  The other languages are
+default languages.  If @code{all} is specified, then all available
+languages are built.  An exception is @code{jit} language, which
+requires @option{--enable-host-shared} to be included with @code{all}.
 
 @item --enable-stage1-languages=@var{lang1},@var{lang2},@dots{}
 Specify that a particular subset of compilers and their runtime
@@ -1866,6 +1867,10 @@ 
 previous Ada build procedures, when it was required to explicitly
 do a @samp{make -C gcc gnatlib_and_tools}.
 
+@item --disable-libgm2
+Specify that the run-time libraries and tools used by Modula-2 should not
+be built.  This can be useful for debugging.
+
 @item --disable-libsanitizer
 Specify that the run-time libraries for the various sanitizers should
 not be built.
@@ -3126,10 +3131,10 @@ 
 In order to run sets of tests selectively, there are targets
 @samp{make check-gcc} and language specific @samp{make check-c},
 @samp{make check-c++}, @samp{make check-d} @samp{make check-fortran},
-@samp{make check-ada}, @samp{make check-objc}, @samp{make check-obj-c++},
-@samp{make check-lto}
-in the @file{gcc} subdirectory of the object directory.  You can also
-just run @samp{make check} in a subdirectory of the object directory.
+@samp{make check-ada}, @samp{make check-m2}, @samp{make check-objc},
+@samp{make check-obj-c++}, @samp{make check-lto} in the @file{gcc}
+subdirectory of the object directory.  You can also just run
+@samp{make check} in a subdirectory of the object directory.
 
 
 A more selective way to just run all @command{gcc} execute tests in the
diff -ruw gcc-git-master/gcc/dwarf2out.cc gcc-git-devel-modula2/gcc/dwarf2out.cc
--- gcc-git-master/gcc/dwarf2out.cc	2022-10-07 20:21:09.769987890 +0100
+++ gcc-git-devel-modula2/gcc/dwarf2out.cc	2022-10-07 20:21:18.614096498 +0100
@@ -25206,6 +25206,8 @@ 
     }
   else if (strcmp (language_string, "GNU F77") == 0)
     language = DW_LANG_Fortran77;
+  else if (strcmp (language_string, "GNU Modula-2") == 0)
+    language = DW_LANG_Modula2;
   else if (dwarf_version >= 3 || !dwarf_strict)
     {
       if (strcmp (language_string, "GNU Ada") == 0)
diff -ruw gcc-git-master/Makefile.def gcc-git-devel-modula2/Makefile.def
--- gcc-git-master/Makefile.def	2022-10-07 20:21:08.985978266 +0100
+++ gcc-git-devel-modula2/Makefile.def	2022-10-07 20:21:18.510095220 +0100
@@ -186,6 +186,7 @@ 
 target_modules = { module= zlib; bootstrap=true; };
 target_modules = { module= rda; };
 target_modules = { module= libada; };
+target_modules = { module= libgm2; lib_path=.libs; };
 target_modules = { module= libgomp; bootstrap= true; lib_path=.libs; };
 target_modules = { module= libitm; lib_path=.libs; };
 target_modules = { module= libatomic; bootstrap=true; lib_path=.libs; };
@@ -308,6 +309,8 @@ 
 flags_to_pass = { flag= GOCFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= GDC_FOR_TARGET ; };
 flags_to_pass = { flag= GDCFLAGS_FOR_TARGET ; };
+flags_to_pass = { flag= GM2_FOR_TARGET ; };
+flags_to_pass = { flag= GM2FLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= LD_FOR_TARGET ; };
 flags_to_pass = { flag= LIPO_FOR_TARGET ; };
 flags_to_pass = { flag= LDFLAGS_FOR_TARGET ; };
@@ -619,6 +622,8 @@ 
 dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
 dependencies = { module=all-target-libgo; on=all-target-libffi; };
 dependencies = { module=all-target-libgo; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgm2; on=all-target-libstdc++-v3; };
+dependencies = { module=all-target-libgm2; on=all-target-libatomic; };
 dependencies = { module=configure-target-libphobos; on=configure-target-libbacktrace; };
 dependencies = { module=configure-target-libphobos; on=configure-target-zlib; };
 dependencies = { module=all-target-libphobos; on=all-target-libbacktrace; };
@@ -678,6 +683,8 @@ 
 languages = { language=go;	gcc-check-target=check-go;
 				lib-check-target=check-target-libgo;
 				lib-check-target=check-gotools; };
+languages = { language=m2;	gcc-check-target=check-m2;
+				lib-check-target=check-target-libgm2; };
 languages = { language=d;	gcc-check-target=check-d;
 				lib-check-target=check-target-libphobos; };
 languages = { language=jit;	gcc-check-target=check-jit; };
diff -ruw gcc-git-master/Makefile.tpl gcc-git-devel-modula2/Makefile.tpl
--- gcc-git-master/Makefile.tpl	2022-10-07 20:21:08.989978315 +0100
+++ gcc-git-devel-modula2/Makefile.tpl	2022-10-07 20:21:18.518095319 +0100
@@ -166,6 +166,8 @@ 
 	GOCFLAGS="$(GOCFLAGS_FOR_BUILD)"; export GOCFLAGS; \
 	GDC="$(GDC_FOR_BUILD)"; export GDC; \
 	GDCFLAGS="$(GDCFLAGS_FOR_BUILD)"; export GDCFLAGS; \
+	GM2="$(GM2_FOR_BUILD)"; export GM2; \
+	GM2FLAGS="$(GM2FLAGS_FOR_BUILD)"; export GM2FLAGS; \
 	DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \
 	DSYMUTIL="$(DSYMUTIL_FOR_BUILD)"; export DSYMUTIL; \
 	LD="$(LD_FOR_BUILD)"; export LD; \
@@ -204,6 +206,7 @@ 
 	GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \
 	GOC="$(GOC)"; export GOC; \
 	GDC="$(GDC)"; export GDC; \
+	GM2="$(GM2)"; export GM2; \
 	AR="$(AR)"; export AR; \
 	AS="$(AS)"; export AS; \
 	CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
@@ -307,6 +310,7 @@ 
 	GFORTRAN="$(GFORTRAN_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GFORTRAN; \
 	GOC="$(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GOC; \
 	GDC="$(GDC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GDC; \
+	GM2="$(GM2_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GM2; \
 	DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
 	DSYMUTIL="$(DSYMUTIL_FOR_TARGET)"; export DSYMUTIL; \
 	LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \
@@ -373,6 +377,7 @@ 
 GFORTRAN_FOR_BUILD = @GFORTRAN_FOR_BUILD@
 GOC_FOR_BUILD = @GOC_FOR_BUILD@
 GDC_FOR_BUILD = @GDC_FOR_BUILD@
+GM2_FOR_BUILD = @GM2_FOR_BUILD@
 LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
 LD_FOR_BUILD = @LD_FOR_BUILD@
 NM_FOR_BUILD = @NM_FOR_BUILD@
@@ -443,6 +448,7 @@ 
 LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 GOCFLAGS = $(CFLAGS)
 GDCFLAGS = $(CFLAGS)
+GM2FLAGS = $(CFLAGS)
 
 # Pass additional PGO and LTO compiler options to the PGO build.
 BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS)
@@ -578,6 +584,7 @@ 
 GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@
 GOC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GOC_FOR_TARGET@
 GDC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GDC_FOR_TARGET@
+GM2_FOR_TARGET=$(STAGE_CC_WRAPPER) @GM2_FOR_TARGET@
 DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
 DSYMUTIL_FOR_TARGET=@DSYMUTIL_FOR_TARGET@
 LD_FOR_TARGET=@LD_FOR_TARGET@
@@ -603,6 +610,7 @@ 
 LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
 LDFLAGS_FOR_TARGET = @LDFLAGS_FOR_TARGET@
+GM2FLAGS_FOR_TARGET = -O2 -g
 GOCFLAGS_FOR_TARGET = -O2 -g
 GDCFLAGS_FOR_TARGET = -O2 -g
 
@@ -709,6 +717,7 @@ 
 	'GFORTRAN=$(GFORTRAN)' \
 	'GOC=$(GOC)' \
 	'GDC=$(GDC)' \
+	'GM2=$(GM2)' \
 	'LD=$(LD)' \
 	'LIPO=$(LIPO)' \
 	'NM=$(NM)' \
@@ -735,6 +744,7 @@ 
 	CC="$${CC}" CC_FOR_BUILD="$${CC_FOR_BUILD}" \
 	CXX="$${CXX}" CXX_FOR_BUILD="$${CXX_FOR_BUILD}" \
 	GDC="$${GDC}" GDC_FOR_BUILD="$${GDC_FOR_BUILD}" \
+	GM2="$${GM2}" GM2_FOR_BUILD="$${GM2_FOR_BUILD}" \
 	GNATBIND="$${GNATBIND}" \
 	LDFLAGS="$${LDFLAGS}" \
 	HOST_LIBS="$${HOST_LIBS}" \
@@ -770,6 +780,8 @@ 
 	'GOCFLAGS=$$(GOCFLAGS_FOR_TARGET)' \
 	'GDC=$$(GDC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
 	'GDCFLAGS=$$(GDCFLAGS_FOR_TARGET)' \
+	'GM2=$$(GM2_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'GM2FLAGS=$$(GM2FLAGS_FOR_TARGET)' \
 	'LD=$(COMPILER_LD_FOR_TARGET)' \
 	'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
 	'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
@@ -796,6 +808,7 @@ 
 # cross-building scheme.
 EXTRA_GCC_FLAGS = \
 	"GCC_FOR_TARGET=$(GCC_FOR_TARGET) $$TFLAGS" \
+	"GM2_FOR_TARGET=$(GM2_FOR_TARGET) $$TFLAGS" \
 	"`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
 	"`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"