Re: [PATCH 06/52] m2: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE

2024-06-03 Thread Gaius Mulley
Kewen Lin  writes:

> Joseph pointed out "floating types should have their mode,
> not a poorly defined precision value" in the discussion[1],
> as he and Richi suggested, the existing macros
> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a
> hook mode_for_floating_type.  To be prepared for that, this
> patch is to replace use of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> in m2 with TYPE_PRECISION of {float,{,long_}double}_type_node.
>
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>
> gcc/m2/ChangeLog:
>
>   * gm2-gcc/m2type.cc (build_m2_short_real_node): Use TYPE_PRECISION of
>   float_type_node to replace FLOAT_TYPE_SIZE.
>   (build_m2_real_node): Use TYPE_PRECISION of double_type_node to
>   replace DOUBLE_TYPE_SIZE.
>   (build_m2_long_real_node): Use TYPE_PRECISION of
>   long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.

> ---
>  gcc/m2/gm2-gcc/m2type.cc | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
> index 571923c08ef..d52cbdf0b99 100644
> --- a/gcc/m2/gm2-gcc/m2type.cc
> +++ b/gcc/m2/gm2-gcc/m2type.cc
> @@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
>/* Define `REAL'.  */
>  
>c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>layout_type (c);
>return c;
>  }
> @@ -1433,7 +1433,7 @@ build_m2_real_node (void)
>/* Define `REAL'.  */
>  
>c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>layout_type (c);
>return c;
>  }
> @@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
>if (M2Options_GetIBMLongDouble ())
>  {
>longreal = make_node (REAL_TYPE);
> -  TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
> +  TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
>  }
>else if (M2Options_GetIEEELongDouble ())
>  longreal = float128_type_node;

all look good to me thanks,

regards,
Gaius


Re: [PATCH] modula2: Fully respect DESTDIR in texi rule

2024-05-20 Thread Gaius Mulley
Sam James  writes:

> This was originally reported in Gentoo at https://bugs.gentoo.org/930014.
>
> 2024-05-20  Sam James 
> gcc/m2/
> * Make-lang.in (m2.install-info): Pass --destdir for dir index.
> ---
>  gcc/m2/Make-lang.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index 0abd8ce14555..da4226123dff 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -425,7 +425,7 @@ m2.install-info: installdirs
>   else true; fi
>   -if [ -f gm2$(exeext) ] && [ -f $(DESTDIR)$(infodir)/m2.info ]; then \
> if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
> - install-info --dir-file=$(infodir)/dir 
> $(DESTDIR)$(infodir)/m2.info; \
> + install-info --dir-file=$(DESTDIR)$(infodir)/dir 
> $(DESTDIR)$(infodir)/m2.info; \
> else true; fi; \
>   else true; fi

thanks for the patch and url above - looks good to me,

regards,
Gaius


Re: [PATCH] libgm2: re-generate with autoreconf

2024-05-02 Thread Gaius Mulley
Simon Marchi  writes:

>
> I don't have access to the gcc repo, so could you please push the patch
> on my behalf?

all done - many thanks for the patch!

regards,
Gaius


Re: [PATCH] testsuite: gm2: Remove timeout overrides [PR114886]

2024-04-30 Thread Gaius Mulley
Rainer Orth  writes:

> Hi Gaius,
>
>> yes this looks good to me please apply.  Thanks for the rationale
>
> done for trunk.  I guess it's ok to apply to the gcc-14 branch after the
> release and some soak time?

many thanks - and yes certainly also to gcc-14 (after an appropriate
amount of delay),

regards,
Gaius


[pushed] wwwdocs: modula2 update for changes.html, index.html, readings.html and frontends.html

2024-04-30 Thread Gaius Mulley


Pushed the commit c74a573fa888f3970b6b38d57020f0160e49e58a

   frontends.html: Mention modula-2 was merged during gcc-13.
   gcc-14/changes.html: New section heading for modula-2 and populate.
   index.html: Add modula-2 to the list of languages supported by GCC.
   readings.html (Modula 2 information): New section containing PIM2, PIM4
   and ISO standard links.

regards,
Gaius



diff --git a/htdocs/frontends.html b/htdocs/frontends.html
index d47b56b6..2dec80c9 100644
--- a/htdocs/frontends.html
+++ b/htdocs/frontends.html
@@ -43,8 +43,8 @@ has a back end that generates assembler directly, using the 
GCC back end.
 http://www.nongnu.org/gm2/;>GNU Modula-2 implements
 the ISO/IEC 10514-1, PIM2, PIM3 and PIM4 dialects of the language.
 The compiler is operational with GCC 10, GCC 11, and GCC 12 (on
-GNU/Linux x86 systems).  The front end is now in the GCC development
-trunk (GCC 13).  It is mostly written in Modula-2 and includes a
+GNU/Linux x86 systems).  The front end was merged into the GCC tree
+during GCC 13.  It is mostly written in Modula-2 and includes a
 bootstrap tool which translates Modula-2 into C/C++.
 
 Modula-3 (for links see 
 
 
 
+Modula-2
+
+  The automatic dependency generation options: -M,
+-MD, -MF,
+-MMD, -MP, -MQ and
+-MT have been implemented in the compiler.
+  
+  The -Wcase-enum
+and -Wuninit-variable-checking= options have
+been implemented to provide compile time warnings against
+missing case clauses and uninitialized variables respectively.
+  
+
+
 
 libgccjit
 
diff --git a/htdocs/index.html b/htdocs/index.html
index 7eac5eab..d80ef5d7 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -19,7 +19,7 @@
 C,
 C++,
 Objective-C, Fortran,
-Ada, Go, and D, as well as libraries for these languages (libstdc++,...).
+Ada, Go, D and Modula-2 as well as libraries for these languages 
(libstdc++,...).
 GCC was originally written as the compiler for the http://www.gnu.org/gnu/thegnuproject.html;>GNU operating system.
 The GNU system was developed to be 100% free software, free in the sense
diff --git a/htdocs/readings.html b/htdocs/readings.html
index ee77d969..0f6032c2 100644
--- a/htdocs/readings.html
+++ b/htdocs/readings.html
@@ -559,6 +559,18 @@ names.
 
 
 
+Modula 2 information
+
+
+  https://www.research-collection.ethz.ch/handle/20.500.11850/68683;>Programming
+  in Modula-2 (Edition 2)
+  https://freepages.modula2.org/report4/modula-2.html;>Programming
+  in Modula-2 (Edition 4)
+  http://sc22wg13.twi.tudelft.nl;>ISO Modula-2 standards
+  (base language, OO and generic language extensions)
+
+
+
 Modula 3 information
 
 


Re: [PATCH] libgm2: re-generate with autoreconf

2024-04-30 Thread Gaius Mulley
Christophe Lyon  writes:

> On Tue, 30 Apr 2024 at 04:01, Simon Marchi  wrote:
>>
>> I get a diff when running "autoreconf" in this directory.  I think that
>> the current state is erroneous: it appears to have been generated using
>>
>> aclocal -I ../config -I ..
>>
>> even though configure.ac and Makefile.am list the include flag in the
>> reverse order:
>>
>>aclocal -I .. -I ../config
>>
>> Running "autoreconf" uses the latter order, so I think that's the
>> "right" output.
>>
>> No functional difference expected.
>
> Thanks, this matches what I noticed.
> I'm not a maintainer, so I cannot approve, but a minor remark: in GCC
> we still need a ChangeLog entry in the commit message.
>
> Christophe

many thanks for spotting this bug, lgtm,

regards,
Gaius


Re: [PATCH] testsuite: gm2: Remove timeout overrides [PR114886]

2024-04-30 Thread Gaius Mulley
Rainer Orth  writes:

> A large number of gm2 tests are timing out even on current Solaris/SPARC
> systems.  As detailed in the PR, the problem is that the gm2 testsuite
> artificially lowers many timeouts way below the DejaGnu default of 300
> seconds, often as short as 10 seconds.  The problem lies both in the
> values (they may be appropriate for some targets, but too low for
> others, especially under high load) and the fact that it uses absolute
> values, overriding e.g. settings from a build-wide site.exp.
>
> Therefore this patch removes all those overrides, restoring the
> defaults.
>
> Tested on sparc-sun-solaris2.11 (where all the previous timeouts are
> gone) and i386-pc-solaris2.11.
>
> Ok for trunk and the gcc-14 branch once GCC 14.1.0 has been released?

yes this looks good to me please apply.  Thanks for the rationale
described in the PR.  As suggested, locally changing site.exp is more
appropriate should the need arise.  The dg-timeout code was added to
speed up testing/development of (a deadlocking) RTco.cc (which has
since been fixed)

regards,
Gaius


Re: [committed] Further spelling fixes in translatable strings

2024-04-24 Thread Gaius Mulley
Jakub Jelinek  writes:

> On Tue, Apr 23, 2024 at 11:32:08AM +0100, Jonathan Wakely wrote:
>> On Mon, 22 Apr 2024 at 22:30, Jakub Jelinek  wrote:
>> Yup:
>> https://gcc.gnu.org/codingconventions.html#Spelling
>> 
>> That spelling is explicitly mentioned at the link above, so they
>> should be "ize" really.
>
> Ok.  I've committed that patch plus the following as obvious too.
>
> I see various similar cases in m2 and rust FEs where they don't make it into
> gcc/po/gcc.pot, guess those would be nice to get fixed too, end best even 
> find out
> how to make those messages translatable.
> Talking about e.g.
> m2/gm2-compiler/M2Quads.mod:'%a unrecognised builtin 
> constant', Id) |
> m2/gm2-compiler/M2Quads.mod:  InternalError ('unrecognised value')

many thanks for spotting these errors - I'll look into getting the
messages translatable,

regards,
Gaius


[pushed] modula2: add modula-2 language section to languages supported by GCC

2024-04-11 Thread Gaius Mulley


Pushed to trunk as r14-9915-g0dc39dee836761f1bc993d760f4ed5f3d127897a

This patch introduces a small modula-2 language section to the
Language Standards Supported by GCC node.

gcc/ChangeLog:

* doc/standards.texi (Language Standards Supported by GCC):
Add Modula-2 language section.

(my last email omitted the patch, now included here)


diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi
index 06444ee15f7..68bd750a063 100644
--- a/gcc/doc/standards.texi
+++ b/gcc/doc/standards.texi
@@ -332,6 +332,17 @@ GCC supports the D 2.0 programming language.  The D 
language itself is
 currently defined by its reference implementation and supporting language
 specification, described at @uref{https://dlang.org/spec/spec.html}.
 
+@section Modula-2 language
+
+GCC supports the Modula-2 language and is compliant with the PIM2,
+PIM3, PIM4 and ISO dialects.  Also implemented are a complete set of
+free ISO libraries.  It also contains a collection of PIM libraries
+and some Logitech compatible libraries.
+
+For more information on Modula-2 see
+@uref{https://gcc.gnu.org/readings.html}.  The online manual is
+available at @uref{https://gcc.gnu.org/onlinedocs/gm2/index.html}.
+
 @section References for Other Languages
 
 @xref{Top, GNAT Reference Manual, About This Guide, gnat_rm,


[pushed] modula2: add modula-2 language section to languages supported by GCC

2024-04-11 Thread Gaius Mulley


Pushed to trunk as r14-9915-g0dc39dee836761f1bc993d760f4ed5f3d127897a

This patch introduces a small modula-2 language section to the
Language Standards Supported by GCC node.

gcc/ChangeLog:

* doc/standards.texi (Language Standards Supported by GCC):
Add Modula-2 language section.


[PATCH][wwwdocs] modula2 update for changes.html, index.html, readings.html and frontends.html

2024-04-11 Thread Gaius Mulley


Hello,

Here are a proposed set of patches to highlight the changes in the
modula-2 frontend for GCC 14.1.

The patches also contain updates for:

  * readings.html: Add Modula-2 language standards.
  * index.html: Modula-2 listed in the languages supported by GCC.
  * frontends.html: Update now Modula-2 is in the tree.
  * changes.html: Highlight user facing changes.

feel free to adjust or rewrite in anyway,

regards,
Gaius



diff --git a/htdocs/frontends.html b/htdocs/frontends.html
index d47b56b6..2dec80c9 100644
--- a/htdocs/frontends.html
+++ b/htdocs/frontends.html
@@ -43,8 +43,8 @@ has a back end that generates assembler directly, using the 
GCC back end.
 http://www.nongnu.org/gm2/;>GNU Modula-2 implements
 the ISO/IEC 10514-1, PIM2, PIM3 and PIM4 dialects of the language.
 The compiler is operational with GCC 10, GCC 11, and GCC 12 (on
-GNU/Linux x86 systems).  The front end is now in the GCC development
-trunk (GCC 13).  It is mostly written in Modula-2 and includes a
+GNU/Linux x86 systems).  The front end was merged into the GCC tree
+during GCC 13.  It is mostly written in Modula-2 and includes a
 bootstrap tool which translates Modula-2 into C/C++.
 
 Modula-3 (for links see 
 
 
 
+Modula-2
+
+  The automatic dependency generation options: -M,
+-MD, -MF,
+-MMD, -MP, -MQ and
+-MT have been implemented in the compiler.
+  
+  The -Wcase-enum
+and -Wuninit-variable-checking= options have
+been implemented to provide compile time warnings against
+missing case clauses and uninitialized variables respectively.
+  
+
+
 
 libgccjit
 
diff --git a/htdocs/index.html b/htdocs/index.html
index 909cae75..125fc4ce 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -19,7 +19,7 @@
 C,
 C++,
 Objective-C, Fortran,
-Ada, Go, and D, as well as libraries for these languages (libstdc++,...).
+Ada, Go, D and Modula-2 as well as libraries for these languages 
(libstdc++,...).
 GCC was originally written as the compiler for the http://www.gnu.org/gnu/thegnuproject.html;>GNU operating system.
 The GNU system was developed to be 100% free software, free in the sense
diff --git a/htdocs/readings.html b/htdocs/readings.html
index ee77d969..e78c4769 100644
--- a/htdocs/readings.html
+++ b/htdocs/readings.html
@@ -559,6 +559,18 @@ names.
 
 
 
+Modula 2 information
+
+
+  https://www.research-collection.ethz.ch/handle/20.500.11850/68683;>Programming
+  in Modula-2 (Edition 2)
+  https://freepages.modula2.org/report4/modula-2.html;>Programming
+  in Modula-2 (Edition 4)
+  http://sc22wg13.twi.tudelft.nl;>ISO Modula-2 standards
+  (base language, OO and generic language extensions)
+
+
+
 Modula 3 information
 
 



Re: [PATCH] modula2: Add m2.install-dvi in gcc/m2/Make-lang.in

2024-04-05 Thread Gaius Mulley
Christophe Lyon  writes:

> m2 has a m2.dvi build rule, but lacks the m2.install-dvi one.
>
> 2024-04-04  Christophe Lyon  
>
>   gcc/m2/
>   * Make-lang.in (m2.install-dvi): New rule.
> ---
>  gcc/m2/Make-lang.in | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index e56240b4c44..0abd8ce1455 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -162,6 +162,18 @@ m2.dvi: doc/m2.dvi
>  doc/m2.dvi: $(TEXISRC) $(objdir)/m2/images/gnu.eps
>   $(TEXI2DVI) -c -I $(objdir)/m2 -I $(srcdir)/doc/include -o $@ 
> $(srcdir)/doc/gm2.texi
>  
> +M2_DVIFILES = doc/m2.dvi
> +
> +m2.install-dvi: $(M2_DVIFILES)
> + @$(NORMAL_INSTALL)
> + test -z "$(dvidir)/gcc" || $(mkinstalldirs) "$(DESTDIR)$(dvidir)/gcc"
> + @list='$(M2_DVIFILES)'; for p in $$list; do \
> +   if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
> +   f=$(dvi__strip_dir) \
> +   echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(dvidir)/gcc/$$f'"; \
> +   $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(dvidir)/gcc/$$f"; \
> + done
> +
>  doc/m2.ps: doc/m2.dvi
>   dvips -o $@ $<

many thanks - lgtm,

regards,
Gaius


Re: [PATCH 2/2] modula2: Fix m2.install-info in gcc/m2/Make-lang.in

2024-03-30 Thread Gaius Mulley
Christophe Lyon  writes:

> Fix a few typos: the generated filename is m2.info (not gm2.info, and
> gm2$(exeext) is a file not a directory (so test -d would always fail).
>
> 2024-03-29  Christophe Lyon  
>
>   gcc/m2/
>   * Make-lang.in (m2.install-info): Fix rule.
> ---
>  gcc/m2/Make-lang.in | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index 2d8a47a1b1f..e56240b4c44 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -400,20 +400,20 @@ m2.install-common: installdirs
>   done
>  
>  m2.install-info: installdirs
> - if [ -d gm2$(exeext) ] ; then \
> -   if [ -f $(objdir)/doc/gm2.info ]; then \
> - rm -f $(DESTDIR)$(infodir)/gm2.info*; \
> - for f in $(objdir)/doc/gm2.info*; do \
> + if [ -f gm2$(exeext) ] ; then \
> +   if [ -f $(objdir)/doc/m2.info ]; then \
> + rm -f $(DESTDIR)$(infodir)/m2.info*; \
> + for f in $(objdir)/doc/m2.info*; do \
> realfile=`echo $$f | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
>rm -f $(DESTDIR)$(infodir)/`basename $$realfile`; \
> $(INSTALL_DATA) $$f $(DESTDIR)$(infodir)/`basename $$realfile`; \
>   done; \
> - chmod a-x $(DESTDIR)$(infodir)/gm2.info*; \
> + chmod a-x $(DESTDIR)$(infodir)/m2.info*; \
> else true; fi; \
>   else true; fi
> - -if [ -f gm2$(exeext) ] && [ -f $(DESTDIR)$(infodir)/gm2.info ]; then \
> + -if [ -f gm2$(exeext) ] && [ -f $(DESTDIR)$(infodir)/m2.info ]; then \
> if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
> - install-info --dir-file=$(infodir)/dir 
> $(DESTDIR)$(infodir)/gm2.info; \
> + install-info --dir-file=$(infodir)/dir 
> $(DESTDIR)$(infodir)/m2.info; \
> else true; fi; \
>   else true; fi

lgtm, many thanks for spotting these bugs,

regards,
Gaius


Re: [PATCH 1/2] modula2: Add m2.install-html rule to gcc/m2/Make-lang.in

2024-03-30 Thread Gaius Mulley
Christophe Lyon  writes:

> This rule was missing, and 'make install-html' was failing.
> It is copied from the corresponding one in fortran.
>
> 2024-03-29  Christophe Lyon  
>
>   gcc/m2/
>   * Make-lang.in (install-html): New rule.
> ---
>  gcc/m2/Make-lang.in | 19 +++
>  1 file changed, 19 insertions(+)
>
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index ef6990ce617..2d8a47a1b1f 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -206,6 +206,25 @@ $(build_htmldir)/m2/index.html: $(TEXISRC) 
> $(objdir)/m2/images/gnu.eps
>   rm -f $(@D)/*
>   $(TEXI2HTML) -I $(objdir)/m2 -I $(srcdir)/m2 -I $(gcc_docdir)/include 
> -o $(@D) $<
>  
> +M2_HTMLFILES = $(build_htmldir)/m2
> +
> +m2.install-html: $(M2_HTMLFILES)
> + @$(NORMAL_INSTALL)
> + test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
> + @list='$(M2_HTMLFILES)'; for p in $$list; do \
> +   if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; 
> fi; \
> +   f=$(html__strip_dir) \
> +   if test -d "$$d$$p"; then \
> + echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \
> + $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
> + echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
> + $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
> +   else \
> + echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
> + $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
> +   fi; \
> + done
> +
>  # gm2-libs.texi
>  
>  m2/gm2-libs.texi: gm2-libs.texi-check; @true

lgtm, many thanks for the fix,

regards,
Gaius


Re: [PATCH RFA] build: drop target libs from LD_LIBRARY_PATH [PR105688]

2024-02-24 Thread Gaius Mulley
Iain Sandoe  writes:

> Hi Gaius,
>
>> On 22 Feb 2024, at 18:06, Gaius Mulley  wrote:
>> 
>> Iain Sandoe  writes:
>> 
>>> Right now, AFAIK the only target runtimes used by host tools are
>>> libstdc++, libgcc and libgnat.  I agree that might change with rust -
>>> since the rust folks are talking about using one of the runtimes in
>>> the FE, I am not aware of other language FEs requiring their targte
>>> runtimes to be available to the host tools (adding Gaius in case I
>>> missed something with m2 - which is quite complex inthe
>>> bootstrapping).
>
>> the m2 infrastructure translates and builds gcc/m2/gm2-libs along with
>> gcc/m2/gm2-compiler and uses these objects for cc1gm2, pge, mc etc -
>> rather than the library archives generated from /libgm2
>
> If I understand this (and my builds of the m2 stuff) correctly, this is done
> locally to the builds of the host-side components; in particular not 
> controlled
> by the top level Makefile.{tpl,def}?

Hi Iain,

yes indeed,

> (so that we do not see builds of libgm2 in stage1/2- but only in the
> stage3-target builds?
>
> in which case, this should be outside the scope of the patch here.

regards,
Gaius


Re: [PATCH RFA] build: drop target libs from LD_LIBRARY_PATH [PR105688]

2024-02-22 Thread Gaius Mulley
Iain Sandoe  writes:

> Right now, AFAIK the only target runtimes used by host tools are
> libstdc++, libgcc and libgnat.  I agree that might change with rust -
> since the rust folks are talking about using one of the runtimes in
> the FE, I am not aware of other language FEs requiring their targte
> runtimes to be available to the host tools (adding Gaius in case I
> missed something with m2 - which is quite complex inthe
> bootstrapping).

Hi Iain,

the m2 infrastructure translates and builds gcc/m2/gm2-libs along with
gcc/m2/gm2-compiler and uses these objects for cc1gm2, pge, mc etc -
rather than the library archives generated from /libgm2

regards,
Gaius


Re: [PATCH] libgm2: Fix libm2iso/wraptime.cc compilation on Solaris

2024-02-13 Thread Gaius Mulley
Rainer Orth  writes:

> As it turned out, my patch to complete the libgm2 autoconf macros works
> on both Linux/sparc64 and Linux/x86_64, but breaks Solaris bootstrap:
>
> /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc: In function 'int 
> m2iso_wraptime_gettimeofday(void*, timezone*)':
> /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc:148:24: error: 
> invalid conversion from 'void*' to 'timeval*' [-fpermissive]
>   148 |   return gettimeofday (tv, tz);
>   |^~
>   ||
>   |void*
> In file included from /usr/include/sys/select.h:27,
>  from /usr/include/sys/types.h:665,
>  from 
> /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc:35:
> /usr/include/sys/time.h:444:18: note:   initializing argument 1 of 'int 
> gettimeofday(timeval*, void*)'
>   444 | int gettimeofday(struct timeval *_RESTRICT_KYWD, void 
> *_RESTRICT_KYWD);
>   |  ^
> /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc: In function 'int 
> m2iso_wraptime_settimeofday(void*, timezone*)':
> /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc:165:24: error: 
> invalid conversion from 'void*' to 'timeval*' [-fpermissive]
>   165 |   return settimeofday (tv, tz);
>   |^~
>   ||
>   |void*
> /usr/include/sys/time.h:431:18: note:   initializing argument 1 of 'int 
> settimeofday(timeval*, void*)'
>   431 | int settimeofday(struct timeval *, void *);
>   |  ^~~~
>
> This happens because on Linux only HAVE_[GS]ETTIMEOFDAY is defined,
> while Solaris has both that and HAVE_STRUCT_TIMEZONE, selecting
> different implementations.
>
> Fixed by casting tv to struct timeval *.
>
> I thought about changing the signatures instead to take a struct timeval
> * instead, but that seemed risky given that there's a
> HAVE_STRUCT_TIMEVAL, so would probably break other targets.
>
> Bootstrapped without regressions on i386-pc-solaris2.11,
> sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.
>
> Ok for trunk?

yes sure, lgtm - many thanks,

regards,
Gaius


Re: [PATCH] libgm2: Define missing configure macros [PR113888]

2024-02-12 Thread Gaius Mulley
Rainer Orth  writes:

> As detailed in PR modula2/113888, the 32-bit libm2pim/target.c doesn't
> assemble in a Linux/sparc64 multilib build.  However, the root cause is
> that the HAVE_EXP10* macros are never defined.  While I was at it, I
> checked for other cases where the code uses HAVE_* macros that are
> missing from config.h.in.
>
> This patch adds the missing checks, changes the configure checks where
> the names don't match what's used in the code, or corrects the code to
> use the right names.
>
> So far tested on sparc64-unknown-linux-gnu by building libgm2 (32 and
> 64-bit) and running the gm2 tests.
>
> Ok for trunk?

yes lgtm and thanks for the patch,

regards,
Gaius


[PATCH] PR modula2/113836 gm2 does not dump gimple or quadruples to a file

2024-02-12 Thread Gaius Mulley
rrorT2, MetaErrorT3,
 MetaError1, MetaError2, MetaErrorStringT1 ;
 
-FROM M2Options IMPORT DisplayQuadruples, UnboundedByReference, PedanticCast,
+FROM M2Options IMPORT UnboundedByReference, PedanticCast,
   VerboseUnbounded, Iso, Pim, DebugBuiltins, WholeProgram,
   StrictTypeChecking, AutoInit, cflag, ScaffoldMain,
   ScaffoldDynamic, ScaffoldStatic,
@@ -256,8 +256,7 @@ FROM m2except IMPORT BuildThrow, BuildTryBegin, BuildTryEnd,
 FROM M2Quads IMPORT QuadOperator, GetQuad, IsReferenced, GetNextQuad,
 SubQuad, PutQuad, MustCheckOverflow, GetQuadOtok,
 QuadToTokenNo, DisplayQuad, GetQuadtok,
-GetM2OperatorDesc, GetQuadOp,
-DisplayQuadList ;
+GetM2OperatorDesc, GetQuadOp ;
 
 FROM M2Check IMPORT ParameterTypeCompatible, AssignmentTypeCompatible,  
ExpressionTypeCompatible ;
 FROM M2SSA IMPORT EnableSSA ;
@@ -640,11 +639,6 @@ BEGIN
  Changed := TRUE
   END
UNTIL NoChange ;
-   IF Debugging AND DisplayQuadruples AND FALSE
-   THEN
-  printf0('after resolving expressions with gcc\n') ;
-  DisplayQuadList
-   END ;
RETURN Changed
 END ResolveConstantExpressions ;
 
diff --git a/gcc/m2/gm2-compiler/M2LangDump.def 
b/gcc/m2/gm2-compiler/M2LangDump.def
new file mode 100644
index 000..8298da2a54d
--- /dev/null
+++ b/gcc/m2/gm2-compiler/M2LangDump.def
@@ -0,0 +1,65 @@
+(* M2LangDump.def provides support routines for the -flang-dump.
+
+Copyright (C) 2024 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  *)
+
+DEFINITION MODULE M2LangDump ;
+
+FROM m2tree IMPORT Tree ;
+FROM DynamicStrings IMPORT String ;
+
+
+(*
+   IsDumpRequiredTree - return TRUE if the gcc tree should be dumped.
+*)
+
+PROCEDURE IsDumpRequiredTree (tree: Tree) : BOOLEAN ;
+
+
+(*
+   IsDumpRequired - return TRUE if symbol sym should be dumped
+according to the rules of the filter.
+No filter specified will always return TRUE.
+The filter is a comma separated list of either:
+
+DECL names for example: m2pim_NumberIO_HexToStr
+filename:m2symbolname for example: NumberIO.mod:HexToStr
+fully qualified m2name for example: NumberIO.HexToStr
+*)
+
+PROCEDURE IsDumpRequired (sym: CARDINAL) : BOOLEAN ;
+
+
+(*
+   MakeQuadTemplate - return a template for the quad dump file.
+*)
+
+PROCEDURE MakeQuadTemplate () : String ;
+
+
+(*
+   MakeGimpleTemplate - return a template for the gimple dump file and assign
+len to the max number of characters required to 
complete
+a template.
+*)
+
+PROCEDURE MakeGimpleTemplate (VAR len: CARDINAL) : String ;
+
+
+END M2LangDump.
diff --git a/gcc/m2/gm2-compiler/M2LangDump.mod 
b/gcc/m2/gm2-compiler/M2LangDump.mod
new file mode 100644
index 000..ad822a75fc4
--- /dev/null
+++ b/gcc/m2/gm2-compiler/M2LangDump.mod
@@ -0,0 +1,457 @@
+(* M2LangDump.mod provides support routines for the -flang-dump.
+
+Copyright (C) 2024 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  *)
+
+IMPLEMENTATION MODULE M2LangDump ;
+
+FROM SYSTEM IMPORT ADDRESS ;
+
+FROM DynamicStrings IMPORT String, Length, InitString, Mark, Slice, EqualArray,
+   InitStringCharStar, ConCatChar, ConCat, KillString,
+   Dup, string, char, Index, ReverseIndex, RIndex, 
Equal,
+   PushAllocation, PopAllocationExemption ;
+

Re: [PATCH] m2: Use time_t in time and don't redefine alloca

2024-01-23 Thread Gaius Mulley
"H.J. Lu"  writes:

> Fix the m2 build warning and error:
>
> [...]
> ../../src/gcc/m2/mc/mc.flex:32:9: warning: "alloca" redefined
>32 | #define alloca __builtin_alloca
>   | ^~
> In file included from /usr/include/stdlib.h:587,
>  from :22:
> /usr/include/alloca.h:35:10: note: this is the location of the previous 
> definition
>35 | # define alloca(size)   __builtin_alloca (size)
>   |  ^~
> ../../src/gcc/m2/mc/mc.flex: In function 'handleDate':
> ../../src/gcc/m2/mc/mc.flex:333:25: error: passing argument 1 of 'time' from 
> incompatible point
> er type [-Wincompatible-pointer-types]
>   333 |   time_t  clock = time ((long *)0);
>   | ^
>   | |
>   | long int *
> In file included from ../../src/gcc/m2/mc/mc.flex:28:
> /usr/include/time.h:76:29: note: expected 'time_t *' {aka 'long long int *'} 
> but argument is of
>  type 'long int *'
>76 | extern time_t time (time_t *__timer) __THROW;
>
>   PR bootstrap/113554
>   * mc/mc.flex (alloca): Don't redefine.
>   (handleDate): Replace (long *)0 with (time_t *)0 when calling
>   time.
> ---
>  gcc/m2/mc/mc.flex | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/m2/mc/mc.flex b/gcc/m2/mc/mc.flex
> index bd37d5ad100..7c841bf8d63 100644
> --- a/gcc/m2/mc/mc.flex
> +++ b/gcc/m2/mc/mc.flex
> @@ -28,9 +28,11 @@ along with GNU Modula-2; see the file COPYING3.  If not see
>  #include 
>  #include 
>  
> +#ifndef alloca
>  #ifdef __GNUC__
>  #define alloca __builtin_alloca
>  #endif
> +#endif
>  
>  #if !defined(TRUE)
>  #  define TRUE (1==1)
> @@ -330,7 +332,7 @@ handleColumn (void)
>  static void
>  handleDate (void)
>  {
> -  time_t  clock = time ((long *)0);
> +  time_t  clock = time ((time_t *)0);
>char   *sdate = ctime ();
>char   *s = (char *)alloca (strlen (sdate)+2+1);
>char   *p = strchr(sdate, '\n');

many thanks - and lgtm,

regards.,
Gaius


Re: [PATCH] modula2: Many powerpc platforms do _not_ have support for IEEE754 long double [PR111956]

2024-01-19 Thread Gaius Mulley
Richard Biener  writes:

> On Thu, Jan 18, 2024 at 1:58 AM Gaius Mulley  wrote:
>>
>>
>> ok for master ?
>>
>> Bootstrapped on power8 (cfarm135), power9 (cfarm120) and
>> x86_64-linux-gnu.
>
> OK.

many thanks!

> I wonder what this does to the libm2 ABI?

ah yes - I'll open a PR reflecting lack of libm2 ABI compatibility on
powerpc platforms.


[PATCH] modula2: Many powerpc platforms do _not_ have support for IEEE754 long double [PR111956]

2024-01-17 Thread Gaius Mulley


ok for master ?

Bootstrapped on power8 (cfarm135), power9 (cfarm120) and
x86_64-linux-gnu.

---

This patch corrects commit
r14-4149-g81d5ca0b9b8431f1bd7a5ec8a2c94f04bb0cf032 which assummed
all powerpc platforms would have IEEE754 long double.  The patch
ensures that cc1gm2 obtains the default IEEE754 long double availability
from the configure generated tm_defines.  The user command
line switches -mabi=ibmlongdouble and -mabi=ieeelongdouble are implemented
to override the configuration defaults.

gcc/m2/ChangeLog:

PR modula2/111956
* Make-lang.in (host_mc_longreal): Remove.
* configure: Regenerate.
* configure.ac (M2C_LONGREAL_FLOAT128): Remove.
(M2C_LONGREAL_PPC64LE): Remove.
* gm2-compiler/M2Options.def (SetIBMLongDouble): New procedure.
(GetIBMLongDouble): New procedure function.
(SetIEEELongDouble): New procedure.
(GetIEEELongDouble): New procedure function.
* gm2-compiler/M2Options.mod (SetIBMLongDouble): New procedure.
(GetIBMLongDouble): New procedure function.
(SetIEEELongDouble): New procedure.
(GetIEEELongDouble): New procedure function.
(InitializeLongDoubleFlags): New procedure called during
module block initialization.
* gm2-gcc/m2configure.cc: Remove duplicate includes.
(m2configure_M2CLongRealFloat128): Remove.
(m2configure_M2CLongRealIBM128): Remove.
(m2configure_M2CLongRealLongDouble): Remove.
(m2configure_M2CLongRealLongDoublePPC64LE): Remove.
(m2configure_TargetIEEEQuadDefault): New function.
* gm2-gcc/m2configure.def (M2CLongRealFloat128): Remove.
(M2CLongRealIBM128): Remove.
(M2CLongRealLongDouble): Remove.
(M2CLongRealLongDoublePPC64LE): Remove.
(TargetIEEEQuadDefault): New function.
* gm2-gcc/m2configure.h (m2configure_M2CLongRealFloat128): Remove.
(m2configure_M2CLongRealIBM128): Remove.
(m2configure_M2CLongRealLongDouble): Remove.
(m2configure_M2CLongRealLongDoublePPC64LE): Remove.
(m2configure_TargetIEEEQuadDefault): New function.
* gm2-gcc/m2options.h (M2Options_SetIBMLongDouble): New prototype.
(M2Options_GetIBMLongDouble): New prototype.
(M2Options_SetIEEELongDouble): New prototype.
(M2Options_GetIEEELongDouble): New prototype.
* gm2-gcc/m2type.cc (build_m2_long_real_node): Re-implement using
results of M2Options_GetIBMLongDouble and M2Options_GetIEEELongDouble.
* gm2-lang.cc (gm2_langhook_handle_option): Add case
OPT_mabi_ibmlongdouble and call M2Options_SetIBMLongDouble.
Add case OPT_mabi_ieeelongdouble and call M2Options_SetIEEELongDouble.
* gm2config.aci.in: Regenerate.
* gm2spec.cc (lang_specific_driver): Remove block defined by
M2C_LONGREAL_PPC64LE.
Remove case OPT_mabi_ibmlongdouble.
Remove case OPT_mabi_ieeelongdouble.

libgm2/ChangeLog:

PR modula2/111956
* Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* Makefile.in: Regenerate.
* libm2cor/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2log/Makefile.in: Regenerate.
* libm2min/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2min/Makefile.in: Regenerate.
* libm2pim/Makefile.am (TARGET_LONGDOUBLE_ABI): Remove.
* libm2pim/Makefile.in: Regenerate.

---

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index d7bc7362bbf..45bfa933dca 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -98,9 +98,6 @@ GM2_PROG_DEP=gm2$(exeext) xgcc$(exeext) cc1gm2$(exeext)
 
 include m2/config-make
 
-# Determine if float128 should represent the Modula-2 type LONGREAL.
-host_mc_longreal := $(if $(strip $(filter 
powerpc64le%,$(host))),--longreal=__float128)
-
 LIBSTDCXX=../$(TARGET_SUBDIR)/libstdc++-v3/src/.libs/libstdc++.a
 
 PGE=m2/pge$(exeext)
@@ -474,8 +471,7 @@ MC_ARGS= --olang=c++ \
  -I$(srcdir)/m2/gm2-gcc \
  --quiet \
  $(MC_COPYRIGHT) \
- --gcc-config-system \
- $(host_mc_longreal)
+ --gcc-config-system
 
 MCDEPS=m2/boot-bin/mc$(exeext)
 
diff --git a/gcc/m2/configure b/gcc/m2/configure
index f62f3d8729c..46530970785 100755
--- a/gcc/m2/configure
+++ b/gcc/m2/configure
@@ -3646,24 +3646,6 @@ $as_echo "#define HAVE_OPENDIR 1" >>confdefs.h
 fi
 
 
-case $target in #(
-  powerpc64le*) :
-
-$as_echo "#define M2C_LONGREAL_FLOAT128 1" >>confdefs.h
- ;; #(
-  *) :
- ;;
-esac
-
-case $target in #(
-  powerpc64le*) :
-
-$as_echo "#define M2C_LONGREAL_PPC64LE 1" >>confdefs.h
- ;; #(
-  *) :
- ;;
-esac
-
 ac_config_headers="$ac_config_headers gm2config.aci"
 
 cat >confcache <<\_ACEOF
diff --git a/gcc/m2/configure.ac b/gcc/m2/configure.ac
index efcca628068..15be50936f7 

Re: Modula-2: Support '-isysroot [...]'

2023-12-05 Thread Gaius Mulley
Thomas Schwinge  writes:

> Hi!
>
> OK to push the attached "Modula-2: Support '-isysroot [...]'"?
>
> This greatly improves test results for the cross configurations I've
> tested, but I don't know if any real handling needs to be implemented, or
> this should be done differently altogether?
>
>
> Grüße
>  Thomas
>
>
> -
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße
> 201, 80634 München; Gesellschaft mit beschränkter Haftung;
> Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft:
> München; Registergericht München, HRB 106955
>
>>From 0bd30fd25138497df5320e5f63fd04e1b5756cc5 Mon Sep 17 00:00:00 2001
> From: Thomas Schwinge 
> Date: Tue, 5 Dec 2023 09:54:54 +0100
> Subject: [PATCH] Modula-2: Support '-isysroot [...]'
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> In GCC cross configurations (tested '--target=amdgcn-amdhsa' and
> '--target=nvptx-none') with a sysroot configured, the 'gm2' driver invocations
> are passed '--sysroot=[...]', which is translated into '-isysroot [...]' for
> the 'cc1gm2' compiler invocation.  The latter, however gets complained about:
>
> cc1gm2: warning: command-line option ‘-isysroot [...]’ is valid for 
> C/C++/D/Fortran/ObjC/ObjC++ but not for Modula-2
>
> ..., and therefore a ton of FAILs.
>
> Reproducer (also for non-cross, native configurations):
>
> $ build-gcc/gcc/gm2 -Bbuild-gcc/gcc -v --sysroot=/tmp -x modula-2 
> /dev/null
> [...]
>  build-gcc/gcc/cc1gm2 [...] -isysroot [...]/tmp [...]
> cc1gm2: warning: command-line option ‘-isysroot /tmp’ is valid for 
> C/C++/D/Fortran/ObjC/ObjC++ but not for Modula-2
> [...]
>
>   gcc/m2/
>   * lang.opt (-isysroot): New.
> ---
>  gcc/m2/lang.opt | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt
> index 24f3c6594b9..a60c03e69d4 100644
> --- a/gcc/m2/lang.opt
> +++ b/gcc/m2/lang.opt
> @@ -405,6 +405,10 @@ iquote
>  Modula-2
>  ; Documented in c.opt
>  
> +isysroot
> +Modula-2
> +; Documented in c.opt
> +
>  isystem
>  Modula-2
>  ; Documented in c.opt

Hi Thomas,

yes indeed and many thanks for the fix!  gm2-lang.cc anticipates
OPT_isysroot (albeit it does nothing with it yet)

regards,
Gaius


Re: [PATCH] gm2: Fix mc/mc.flex compilation on Solaris

2023-12-04 Thread Gaius Mulley
Rainer Orth  writes:

> The recent warning changes broke gm2 bootstrap on Solaris:
>
> /vol/gcc/src/hg/master/local/gcc/m2/mc/mc.flex: In function 'handleFile':
> /vol/gcc/src/hg/master/local/gcc/m2/mc/mc.flex:297:21: error: implicit 
> declaration of function 'alloca' [-Wimplicit-function-declaration]
>   297 |   char *s = (char *)alloca (strlen (filename) + 2 + 1);
>   | ^~
>
> alloca needs  on Solaris, which isn't universally available.
> Since mc.flex doesn't include any config header, I chose to switch to
> __builtin_alloca instead.
>
> /vol/gcc/src/hg/master/local/gcc/m2/mc/mc.flex:332:19: error: implicit 
> declaration of function 'index' [-Wimplicit-function-declaration]
>   332 |   char   *p = index(sdate, '\n');
>   |   ^
>
> index is declared in  on Solaris, again not a standard
> header.  I simply switched to using strchr to avoid that issue.
>
> Bootstrapped without regressions on i386-pc-solaris2.11,
> sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and
> x86_64-apple-darwin23.1.0.
>
> Ok for trunk?
>
>   Rainer

yes, lgtm, - thanks for fixing index as well,

regards,
Gaius




Re: [PATCH] m2, build: Use LDLFAGS for mklink

2023-07-13 Thread Gaius Mulley via Gcc-patches
Rainer Orth  writes:

> When trying to bootstrap current trunk on macOS 14.0 beta 3 with Xcode
> 15 beta 4, the build failed running mklink in stage 2:
>
> unset CC ; m2/boot-bin/mklink -s --langc++ --exit --name m2/mc-boot/main.cc 
> /vol/gcc/src/hg/master/darwin/gcc/m2/init/mcinit
> dyld[55825]: Library not loaded: /vol/gcc/lib/libstdc++.6.dylib
>
> While it's unclear to me why this only happens on macOS 14, the problem
> is clear: unlike other C++ executables, mklink isn't linked with
> -static-libstdc++ which is passed in from toplevel in LDFLAGS.
>
> This patch fixes that and allows the build to continue.
>
> Bootstrapped on x86_64-apple-darwin23.0.0, i386-pc-solaris2.11, and
> sparc-sun-solaris2.11.
>
> Ok for trunk?
>
>   Rainer

sure yes - and thanks for the fix,

regards,
Gaius


Re: [PATCH] modula-2: Amend the handling of failed select() calls in RTint [PR108835].

2023-06-28 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on various affected Darwin versions and on x86_64-linux-gnu
> OK for trunk?
> OK for 13.2?
> thanks
> Iain

lgtm - many thanks,

regards,
Gaius


Re: [PATCH] modula2: Fix bootstrap

2023-06-06 Thread Gaius Mulley via Gcc-patches
Jakub Jelinek  writes:

> Hi!
>
> internal-fn.h since yesterday includes insn-opinit.h, which is a generated
> header.
> One of my bootstraps today failed because some m2 sources started compiling
> before insn-opinit.h has been generated.
>
> Normally, gcc/Makefile.in has
> # In order for parallel make to really start compiling the expensive
> # objects from $(OBJS) as early as possible, build all their
> # prerequisites strictly before all objects.
> $(ALL_HOST_OBJS) : | $(generated_files)
>
> rule which ensures that all the generated files are generated before
> any $(ALL_HOST_OBJS) objects start, but use order-only dependency for
> this because we don't want to rebuild most of the objects whenever one
> generated header is regenerated.  After the initial build in an empty
> directory we'll have .deps/ files contain the detailed dependencies.
>
> $(ALL_HOST_OBJS) includes even some FE files, I think in the m2 case
> would be m2_OBJS, but m2/Make-lang.in doesn't define those.
>
> The following patch just adds a similar rule to m2/Make-lang.in.
> Another option would be to set m2_OBJS variable in m2/Make-lang.in to
> something, but not really sure to which exactly and why it isn't
> done.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?


> 2023-06-06  Jakub Jelinek  
>
>   * Make-lang.in: Build $(generated_files) before building
>   all $(GM2_C_OBJS).
>
> --- gcc/m2/Make-lang.in.jj2023-05-04 09:31:27.289948109 +0200
> +++ gcc/m2/Make-lang.in   2023-06-06 21:38:26.655336041 +0200
> @@ -511,6 +511,8 @@ GM2_LIBS_BOOT = m2/gm2-compiler-boot
>  m2/gm2-libs-boot/libgm2.a \
>  $(GM2-BOOT-O)
>  
> +$(GM2_C_OBJS) : | $(generated_files)
> +
>  cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
>   cp -p $< $@
>  
>
>
>   Jakub

Hi Jakub,

sure looks good to me - thanks for the patch,

regards,
Gaius


Re: [PATCH 05/14] m2: use _P() defines from tree.h

2023-05-13 Thread Gaius Mulley via Gcc-patches
Bernhard Reutner-Fischer via Gcc-patches 
writes:

> From: Bernhard Reutner-Fischer 
>
> gcc/m2/ChangeLog:
>
>   * gm2-gcc/m2builtins.cc (doradix): Use _P defines from tree.h.
>   (doplaces): Ditto.
>   (doexponentmin): Ditto.
>   (doexponentmax): Ditto.
>   (dolarge): Ditto.
>   (dosmall): Ditto.
>   (dogUnderflow): Ditto.
>   * gm2-gcc/m2convert.cc (unsafe_conversion_p): Ditto.
>   * gm2-gcc/m2expr.cc (m2expr_build_unary_op_check): Ditto.
>   (m2expr_build_binary_op_check): Ditto.
>   * gm2-gcc/m2tree.cc (m2tree_is_var): Ditto.
>   * gm2-gcc/m2treelib.cc (build_modify_expr): Ditto.
>   * gm2-gcc/m2type.cc (gm2_finish_decl): Ditto.
>   * m2pp.cc (hextree): Ditto.
>   (m2pp_call_expr): Ditto.
> ---
>  gcc/m2/gm2-gcc/m2builtins.cc | 14 +++---
>  gcc/m2/gm2-gcc/m2convert.cc  |  8 
>  gcc/m2/gm2-gcc/m2expr.cc |  4 ++--
>  gcc/m2/gm2-gcc/m2tree.cc |  2 +-
>  gcc/m2/gm2-gcc/m2treelib.cc  |  2 +-
>  gcc/m2/gm2-gcc/m2type.cc |  4 ++--
>  gcc/m2/m2pp.cc   |  4 ++--
>  7 files changed, 19 insertions(+), 19 deletions(-)

Hi Bernhard,

from the m2 perspective - lgtm - thanks for the patch!

regards,
Gaius


Re: [PATCH 05/14] m2: use _P() defines from tree.h

2023-05-13 Thread Gaius Mulley via Gcc-patches
Bernhard Reutner-Fischer via Gcc-patches 
writes:

> From: Bernhard Reutner-Fischer 
>
> gcc/m2/ChangeLog:
>
>   * gm2-gcc/m2builtins.cc (doradix): Use _P defines from tree.h.
>   (doplaces): Ditto.
>   (doexponentmin): Ditto.
>   (doexponentmax): Ditto.
>   (dolarge): Ditto.
>   (dosmall): Ditto.
>   (dogUnderflow): Ditto.
>   * gm2-gcc/m2convert.cc (unsafe_conversion_p): Ditto.
>   * gm2-gcc/m2expr.cc (m2expr_build_unary_op_check): Ditto.
>   (m2expr_build_binary_op_check): Ditto.
>   * gm2-gcc/m2tree.cc (m2tree_is_var): Ditto.
>   * gm2-gcc/m2treelib.cc (build_modify_expr): Ditto.
>   * gm2-gcc/m2type.cc (gm2_finish_decl): Ditto.
>   * m2pp.cc (hextree): Ditto.
>   (m2pp_call_expr): Ditto.

Hi Bernhard,

from the m2 perspective - all looks good to me - thanks for the patch,

regards,
Gaius


Re: libgm2: Remove 'autogen.sh'

2023-05-11 Thread Gaius Mulley via Gcc-patches
Thomas Schwinge  writes:

> Hi!
>
> On 2023-04-14T13:49:20+0100, Gaius Mulley via Gcc-patches 
>  wrote:
>> Thomas Schwinge  writes:
>>> Separately, given that plain 'autoreconf' works, why have 'autogen.sh' at
>>> all?
>>
>> If autoreconf does the same as autogen.sh then yes this can be removed
>
> Pushed to master branch commit bd6dbdb196da5aa5c7354e0fc7b0a146237bcf8a
> "libgm2: Remove 'autogen.sh'".
>
>
>> (or its contents replaced with a call to autoreconf perhaps?),
>
> I didn't see any advantage in that.
>
>
> Grüße
>  Thomas

thank you!

regards,
Gaius


Re: [PATCH] gcc/m2: Drop references to $(P)

2023-04-21 Thread Gaius Mulley via Gcc-patches
Arsen Arsenović  writes:

> $(P) seems to have been a workaround for some old, proprietary make
> implementations that we no longer support.  It was removed in
> r0-31149-gb8dad04b688e9c.
>
> gcc/m2/ChangeLog:
>
>   * Make-lang.in: Remove references to $(P).
>   * Make-maintainer.in: Ditto.
> ---
> Hi,
>
> We spotted that the m2 makefile includes some long-gone compatibility
> variable $(P), presumably left over from when m2 was not in the tree
> yet.  This induced a build failure on our end:
> https://bugs.gentoo.org/904714
>
> Build-tested on x86_64-pc-linux-gnu.  I haven't finished running the
> testsuite.  I believe this only ever expands to an empty string (if not
> set by the env) in the current build system, so in theory, it should be
> safe.
>
> OK for gcc-13 and trunk (with a priority on the former)?
>
>  gcc/m2/Make-lang.in   | 4 ++--
>  gcc/m2/Make-maintainer.in | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index b34db0d9156..d0fa692e5b8 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -514,7 +514,7 @@ GM2_LIBS_BOOT = m2/gm2-compiler-boot/gm2.a \
>  cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
>   cp -p $< $@
>  
> -m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) 
> m2/gm2-compiler/m2flex.o $(P) \
> +m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) 
> m2/gm2-compiler/m2flex.o \
>  $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
>  m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext)
>   -test -d $(@D) || $(mkinstalldirs) $(@D)
> @@ -527,7 +527,7 @@ m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) 
> m2/gm2-compiler/m2flex.o $(
>   @$(call LINK_PROGRESS,$(INDEX.m2),end)
>  
>  m2/stage1/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
> -$(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
> +$(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
>  $(GM2_LIBS_BOOT) $(MC_LIBS) \
>  m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) \
>  $(m2.prev)
> diff --git a/gcc/m2/Make-maintainer.in b/gcc/m2/Make-maintainer.in
> index 17bd9a2d37e..a70682673cd 100644
> --- a/gcc/m2/Make-maintainer.in
> +++ b/gcc/m2/Make-maintainer.in
> @@ -753,7 +753,7 @@ GM2_LIBS_PARANOID = m2/gm2-compiler-paranoid/gm2.a \
>  gm2.paranoid: m2/m2obj3/cc1gm2$(exeext) gm2.verifyparanoid
>  
>  m2/m2obj3/cc1gm2$(exeext): m2/m2obj2/cc1gm2$(exeext) 
> m2/gm2-compiler-paranoid/m2flex.o \
> -$(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) 
> $(GM2_LIBS_PARANOID) \
> +$(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) 
> $(GM2_LIBS_PARANOID) \
>  m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so 
> m2/gm2-libs-boot/M2LINK.o
>   -test -d m2/m2obj3 || $(mkinstalldirs) m2/m2obj3
>   @$(call LINK_PROGRESS,$(INDEX.m2),start)

Hi,

yes certainly this is fine.  lgtm.  Thanks for spotting and the patch

regards,
Gaius


Re: libgm2: Adjust 'autogen.sh' to 'ACLOCAL_AMFLAGS', and simplify

2023-04-14 Thread Gaius Mulley via Gcc-patches
Thomas Schwinge  writes:

> Hi!
>
> On 2022-12-06T14:47:26+0000, Gaius Mulley via Gcc-patches 
>  wrote:
>> This patch set consists of the libgm2 makefile, autoconf sources
>> necessary to build the libm2pim, libm2iso, libm2min, libm2cor
>> and libm2log.
>
> Notice:
>
>> --- /dev/null 2022-08-24 16:22:16.88870 +0100
>> +++ gcc-git-devel-modula2/libgm2/Makefile.am  2022-12-06 02:56:51.428775868 
>> +
>
>> +ACLOCAL_AMFLAGS = -I . -I .. -I ../config
>
> ... this vs.:
>
>> --- /dev/null 2022-08-24 16:22:16.88870 +0100
>> +++ gcc-git-devel-modula2/libgm2/autogen.sh   2022-12-06 02:56:51.432775922 
>> +
>
>> +aclocal -I . -I ../config
>> +autoreconf -I . -I ../config
>
> ... this: for the latter, no explicit '-I ..' before '-I ../config'.
> This means that 'autogen.sh' vs. plain 'autoreconf' don't produce
> identical results: different order of files found via search paths.
> OK to align (and simplify) that as per the attached
> "libgm2: Adjust 'autogen.sh' to 'ACLOCAL_AMFLAGS', and simplify"?

Hi Thomas,

thanks for detecting the bug and the patch - yes looks good to me - feel
free to apply.

> Separately, given that plain 'autoreconf' works, why have 'autogen.sh' at
> all?

If autoreconf does the same as autogen.sh then yes this can be removed
(or its contents replaced with a call to autoreconf perhaps?),

regards,
Gaius

>
>
> Grüße
>  Thomas
>
>
> -
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße
> 201, 80634 München; Gesellschaft mit beschränkter Haftung;
> Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft:
> München; Registergericht München, HRB 106955
>
>>From 8fd7ff138c83200ab83df7f08f773e33961550b4 Mon Sep 17 00:00:00 2001
> From: Thomas Schwinge 
> Date: Tue, 11 Apr 2023 21:40:14 +0200
> Subject: [PATCH] libgm2: Adjust 'autogen.sh' to 'ACLOCAL_AMFLAGS', and
>  simplify
>
> Specifying explicit '-I ..' before '-I ../config' is what (most) other GCC
> components do.  Specifying '-I .' is not necessary.
>
> With the order of '-I's aligned, 'autogen.sh' and plain 'autoreconf' then
> produce identical results.
>
>   libgm2/
>   * autogen.sh: For 'aclocal', 'autoreconf', remove '-I .',
>   add '-I ..'.
>   * Makefile.am (ACLOCAL_AMFLAGS): Remove '-I .'.
>   * libm2cor/Makefile.am (ACLOCAL_AMFLAGS): Likewise.
>   * libm2iso/Makefile.am (ACLOCAL_AMFLAGS): Likewise.
>   * libm2log/Makefile.am (ACLOCAL_AMFLAGS): Likewise.
>   * libm2min/Makefile.am (ACLOCAL_AMFLAGS): Likewise.
>   * libm2pim/Makefile.am (ACLOCAL_AMFLAGS): Likewise.
>   * aclocal.m4: Regenerate.
>   * Makefile.in: Likewise.
>   * libm2cor/Makefile.in: Likewise.
>   * libm2iso/Makefile.in: Likewise.
>   * libm2log/Makefile.in: Likewise.
>   * libm2min/Makefile.in: Likewise.
>   * libm2pim/Makefile.in: Likewise.
> ---
>  libgm2/Makefile.am  |  2 +-
>  libgm2/Makefile.in  | 12 ++--
>  libgm2/aclocal.m4   | 10 +-
>  libgm2/autogen.sh   |  5 ++---
>  libgm2/libm2cor/Makefile.am |  2 +-
>  libgm2/libm2cor/Makefile.in | 12 ++--
>  libgm2/libm2iso/Makefile.am |  2 +-
>  libgm2/libm2iso/Makefile.in | 12 ++--
>  libgm2/libm2log/Makefile.am |  2 +-
>  libgm2/libm2log/Makefile.in | 12 ++--
>  libgm2/libm2min/Makefile.am |  2 +-
>  libgm2/libm2min/Makefile.in | 12 ++--
>  libgm2/libm2pim/Makefile.am |  2 +-
>  libgm2/libm2pim/Makefile.in | 12 ++--
>  14 files changed, 49 insertions(+), 50 deletions(-)
>
> diff --git a/libgm2/Makefile.am b/libgm2/Makefile.am
> index 0b593f6ff216..95df3ed7a301 100644
> --- a/libgm2/Makefile.am
> +++ b/libgm2/Makefile.am
> @@ -25,7 +25,7 @@ AUTOMAKE_OPTIONS = 1.8 foreign
>  
>  SUFFIXES = .c .mod .def .o .obj .lo .a
>  
> -ACLOCAL_AMFLAGS = -I . -I .. -I ../config
> +ACLOCAL_AMFLAGS = -I .. -I ../config
>  
>  # Multilib support.
>  MAKEOVERRIDES=
> diff --git a/libgm2/Makefile.in b/libgm2/Makefile.in
> index da2ec7c2a098..d9950065de19 100644
> --- a/libgm2/Makefile.in
> +++ b/libgm2/Makefile.in
> @@ -90,15 +90,15 @@ host_triplet = @host@
>  target_triplet = @target@
>  subdir = .
>  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
> -am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
> - $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
> - $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
> - $(top_srcdir)/../config/acx.m4 \
> +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
>   $(top_srcdir)/../config/depstand.m4 \
>   $(top_srcdir)/../config/lead-dot.m4 \
>   $(t

Re: [PATCH] Modula-2: fix documentation layout

2023-03-27 Thread Gaius Mulley via Gcc-patches
Eric Botcazou  writes:

> Hi Gaius,
>
>> yes indeed and thanks for the patch!
>
> You're welcome.  The documentation was slightly broken again in the meantime, 
> but nothing really serious this time.
>
> Again tested with a modern and an old version of Makeinfo.  OK for mainline?
>
>
> 2023-03-27  Eric Botcazou  
>
>   * doc/gm2.texi: Add missing Next, Previous and Top fields to most
>   top-level sections.

Hi Eric,

yes certainly - thanks again!

regards,
Gaius


Re: [wwwdocs] document modula-2 in gcc-13/changes.html (and index.html)

2023-03-15 Thread Gaius Mulley via Gcc-patches
Gerald Pfeifer  writes:

> The patch is now in, alas all the GNU M2 manual links now point to 
> non-existant locations.
>
> Does maintainer-scripts/update_web_docs_git require an update to cover 
> Modula-2 and actually build the manual we are now linking to (or rather
> trying to)?
>
> Gerald

Apologies I was going to ask about these links.  I've updated the m2
subtree with target documentation independent sections.  Attached is a
proposed patch for maintainer-scripts/update_web_docs_git feel free to
apply or adapt in any way.

regards,
Gaius


--->o--->o--->o--->o--->o--->o--->o--->o--->o--->o--->o--->o--->o--->o

Add modula-2 documentation to be built

Update the online documentation build script to include modula-2.

maintainer-scripts/ChangeLog:

* update_web_docs_git (MANUALS): Add gm2.
Add include path for m2 target independent sections.


diff --git a/maintainer-scripts/update_web_docs_git 
b/maintainer-scripts/update_web_docs_git
index 1c6a993cafd..c678fc29155 100755
--- a/maintainer-scripts/update_web_docs_git
+++ b/maintainer-scripts/update_web_docs_git
@@ -24,6 +24,7 @@ MANUALS="cpp
   gdc
   gfortran
   gfc-internals
+  gm2
   gnat_ugn
   gnat-style
   gnat_rm
@@ -169,6 +170,9 @@ for file in $MANUALS; do
 includes="-I ${includedir} -I `dirname ${filename}`"
 if [ "$file" = "gnat_ugn" ]; then
   includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn"
+elif [ "$file" = "gm2" ]; then
+  includes="$includes -I gcc/gcc/m2/target-independent"
+  includes="$includes -I gcc/gcc/m2/target-independent/m2"
 fi
 makeinfo --html --css-ref $CSS $includes -o ${file} ${filename}
 tar cf ${file}-html.tar ${file}/*.html


Re: [pushed] wwwdocs: gcc-13: Escape < and > as and

2023-03-12 Thread Gaius Mulley via Gcc-patches
Gerald Pfeifer  writes:

> Note that in HTML < and > have a special meaning, so we cannot simply 
> write "<* noreturn *>", but need to escape it as "* noreturn *".
>
> Pushed.
>
> Gerald

apologies and thanks for correcting this bug

regards,
Gaius


Re: [wwwdocs] document modula-2 in gcc-13/changes.html (and index.html)

2023-03-06 Thread Gaius Mulley via Gcc-patches
Gerald Pfeifer  writes:

> Hi Gaius,
>
> apologies, I thought you had pushed the updated patch and only now 
> realized it's not in yet.
>
> Please look into the few bits below and then go ahead and push.
>
> On Mon, 6 Feb 2023, Gaius Mulley wrote:
>>  * htdocs/frontends.html: An update to say the front end is now in
>>  the development trunk.
>
> Here we'd usually simply say
>
>   * frontends: The Modula-2 front end is now on the 
>   development trunk.
>
> skiping "An update to say", or at least "An update to" and the "htdocs/" 
> port (and adding which front end).
>
>>  * htdocs/gcc-13/changes.html: A description of which dialects are
>>  supported and the user level front end changes so far.
>
>   * gcc-13: Note which Modula-2 dialects are...
>
>>  * htdocs/index.html: Proposed news entry.
>
>   * index: Announce Modula-2 inclusion 
>
> (or something like that).
>
>>  * htdocs/onlinedocs/index.html: PDF, PS and HTML documentation
>>  links.
>   * onlinedocs: Add links to Modula-2 documentation
>
>
>> +The compiler is operational with GCC 10, GCC 11 GCC 12 (on
>
> ...GCC 11, and GCC 12...
>
>> +GNU/Linux x86 systems).  The front end is now in the GCC development
>> +trunk (GCC 13).  The front end is mostly written in Modula-2 and it
>>  includes a bootstrap tool which translates Modula-2 into C/C++.
>
> How about "It is mostly written in Modula-2 and includes..." to avoid
> repetition of "the front end"?
>
>
> Thank you,
> Gerald

Hi Gerald,

no problem at all and many thanks for the advice.  I'll push the changes
shortly,

regards,
Gaius


[PATCH] Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261]

2023-02-20 Thread Gaius Mulley via Gcc-patches


Hello,

bootstrapped on gcc master x86_64 and no extra failures generated on all
front ends.

Would this be ok for trunc?

regards,
Gaius


Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261]

This patch allows front ends to register spec functions.  It is motivated
by PR108261 which needs to retain the order of search path related
options in the modula-2 front end.

gcc/ChangeLog:

* gcc.cc (add_spec_function):
* gcc.h (add_spec_function):

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index becc56051a8..93e4e38389d 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -46,6 +46,7 @@ compilation is specified by a string called a "spec".  */
 #include "spellcheck.h"
 #include "opts-jobserver.h"
 #include "common/common-target.h"
+#include 
 
 
 
@@ -1774,6 +1775,8 @@ static const struct spec_function static_spec_functions[] 
=
   { 0, 0 }
 };
 
+static std::vectorlang_spec_functions;
+
 static int processing_spec_function;
 
 /* Add appropriate libgcc specs to OBSTACK, taking into account
@@ -6825,9 +6828,25 @@ lookup_spec_function (const char *name)
 if (strcmp (sf->name, name) == 0)
   return sf;
 
+  for (auto *sf : lang_spec_functions)
+if (strcmp (sf->name, name) == 0)
+  return sf;
+
   return NULL;
 }
 
+/* Add a new spec function.  */
+
+void
+add_spec_function (const char *name,
+  const char *(*func) (int, const char **))
+{
+  struct spec_function *sf = XNEW (struct spec_function);
+  sf->name = name;
+  sf->func = func;
+  lang_spec_functions.push_back (sf);
+}
+
 /* Evaluate a spec function.  */
 
 static const char *
diff --git a/gcc/gcc.h b/gcc/gcc.h
index 19a61b373ee..f40de0f5520 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -73,6 +73,8 @@ struct spec_function
 extern int do_spec (const char *);
 extern void record_temp_file (const char *, int, int);
 extern void set_input (const char *);
+extern void add_spec_function (const char *name,
+  const char *(*func) (int, const char **));
 
 /* Spec files linked with gcc.cc must provide definitions for these.  */
 


[PATCH] Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261]

2023-02-20 Thread Gaius Mulley via Gcc-patches


Hello,

bootstrapped on gcc master x86_64 and no extra failures generated on all
front ends.

Would this be ok for trunc?

regards,
Gaius


Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261]

This patch allows front ends to register spec functions.  It is motivated
by PR108261 which needs to retain the order of search path related
options in the modula-2 front end.

gcc/ChangeLog:

* gcc.cc (add_spec_function):
* gcc.h (add_spec_function):

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index becc56051a8..93e4e38389d 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -46,6 +46,7 @@ compilation is specified by a string called a "spec".  */
 #include "spellcheck.h"
 #include "opts-jobserver.h"
 #include "common/common-target.h"
+#include 
 
 
 
@@ -1774,6 +1775,8 @@ static const struct spec_function static_spec_functions[] 
=
   { 0, 0 }
 };
 
+static std::vectorlang_spec_functions;
+
 static int processing_spec_function;
 
 /* Add appropriate libgcc specs to OBSTACK, taking into account
@@ -6825,9 +6828,25 @@ lookup_spec_function (const char *name)
 if (strcmp (sf->name, name) == 0)
   return sf;
 
+  for (auto *sf : lang_spec_functions)
+if (strcmp (sf->name, name) == 0)
+  return sf;
+
   return NULL;
 }
 
+/* Add a new spec function.  */
+
+void
+add_spec_function (const char *name,
+  const char *(*func) (int, const char **))
+{
+  struct spec_function *sf = XNEW (struct spec_function);
+  sf->name = name;
+  sf->func = func;
+  lang_spec_functions.push_back (sf);
+}
+
 /* Evaluate a spec function.  */
 
 static const char *
diff --git a/gcc/gcc.h b/gcc/gcc.h
index 19a61b373ee..f40de0f5520 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -73,6 +73,8 @@ struct spec_function
 extern int do_spec (const char *);
 extern void record_temp_file (const char *, int, int);
 extern void set_input (const char *);
+extern void add_spec_function (const char *name,
+  const char *(*func) (int, const char **));
 
 /* Spec files linked with gcc.cc must provide definitions for these.  */
 


Re: [wwwdocs] document modula-2 in gcc-13/changes.html (and index.html)

2023-02-06 Thread Gaius Mulley via Gcc-patches
Gerald Pfeifer  writes:

> On Fri, 3 Feb 2023, Gaius Mulley wrote:
>> The following patch provides a summary of the modula-2 front end
>> and also contains links to the online modula-2 documentation in
>> index.html.
>
>> +Modula-2
>> +
>> +  Support for the language Modula-2 has been added.  The dialects
>> +  supported are PIM2, PIM3, PIM4 and ISO/IEC 10514-1.  Also included
>> +  are a complete set of ISO/IEC 10514-1 libraries and PIM
>> +libraries.
>
> I wonder whether we can this a bit more active. 
>
> Maybe something like "This includes support for the ... dialects, a 
> complete set of ...and ..."?
>
>> +  https://gcc.gnu.org/onlinedocs/m2/Compiler-options.html;>
>> +  Compiler options.
>
> Maybe put this in parenthesis since it's not an update as such and more 
> relatives to the previous item?
>
>> +  Linking has been redesigned.
>
> What are we saying here? I.e., what is the change we are announcing? As a 
> user, what might I notice? Why do I care?
>

Thanks for spotting this - agreed.

> The above are questions to possibly improve this for our users. Please 
> adjust as you see fit, or push as is, if you prefer.
>
>
> On a somewhat related note: This is definitely big enough to warrant an 
> entry in the News section on our main page. :-)  Do you want to propose
> something?
>
> Gerald

Ah yes thank you for the advice - here is an improved proposed patch
containing:

* htdocs/frontends.html: An update to say the front end is now in
the development trunk.
* htdocs/gcc-13/changes.html: A description of which dialects are
supported and the user level front end changes so far.
* htdocs/index.html: Proposed news entry.
* htdocs/onlinedocs/index.html: PDF, PS and HTML documentation
links.

regards,
Gaius


diff --git a/htdocs/frontends.html b/htdocs/frontends.html
index 12af359b..75be4658 100644
--- a/htdocs/frontends.html
+++ b/htdocs/frontends.html
@@ -41,10 +41,10 @@ has a back end that generates assembler directly, using the 
GCC back end.
 (at an early stage of development).
 
 http://www.nongnu.org/gm2/;>GNU Modula-2 implements
-the PIM2, PIM3, PIM4 and ISO dialects of the language.  The compiler
-is fully operational with GCC 10 and GCC 11 (on
-GNU/Linux x86 systems).  Work is in progress to move the front end to
-the GCC trunk.  The front end is mostly written in Modula-2 and it
+the ISO/IEC 10514-1, PIM2, PIM3 and PIM4 dialects of the language.
+The compiler is operational with GCC 10, GCC 11 GCC 12 (on
+GNU/Linux x86 systems).  The front end is now in the GCC development
+trunk (GCC 13).  The front end is mostly written in Modula-2 and it
 includes a bootstrap tool which translates Modula-2 into C/C++.
 
 Modula-3 (for links see 
 
 
 
+Modula-2
+
+  Support for the language Modula-2 has been added.  This includes
+support for the ISO/IEC 10514-1, PIM2, PIM3, PIM4 dialects
+together with a complete set of ISO/IEC 10514-1 and PIM
+libraries.
+  The <* noreturn *> attribute is supported
+with the -Wreturn-type
+https://gcc.gnu.org/onlinedocs/m2/Compiler-options.html;>
+  option.
+
+
 
 
 
diff --git a/htdocs/index.html b/htdocs/index.html
index 80730c06..3d03ef46 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -61,6 +61,11 @@ mission statement.
   has been contributed to Compiler Explorer (aka godbolt.org) by Marc
   Poulhiès
 
+Modula-2 front end 
added
+  [2022-12-14]
+The Modula-2 programming language front end has been added to GCC.
+  This front end was contributed by Gaius Mulley.
+
 https://gcc.gnu.org/wiki/cauldron2022;>GNU Tools Cauldron 
2022
 [2022-09-02]
 Prague, Czech Republic and online, September 16-18 2022
diff --git a/htdocs/onlinedocs/index.html b/htdocs/onlinedocs/index.html
index 343ff9f5..27a8a505 100644
--- a/htdocs/onlinedocs/index.html
+++ b/htdocs/onlinedocs/index.html
@@ -1647,6 +1647,12 @@ existing release.
href="https://gcc.gnu.org/onlinedocs/gdc.ps.gz;>PostScript or https://gcc.gnu.org/onlinedocs/gdc-html.tar.gz;>an
HTML tarball)
+https://gcc.gnu.org/onlinedocs/m2/;>GNU M2 Manual (https://gcc.gnu.org/onlinedocs/m2.pdf;>also in
+   PDF or https://gcc.gnu.org/onlinedocs/m2.ps.gz;>PostScript or https://gcc.gnu.org/onlinedocs/m2-html.tar.gz;>an
+   HTML tarball)
 https://gcc.gnu.org/onlinedocs/libgomp/;>GNU Offloading and
Multi Processing Runtime Library Manual (https://gcc.gnu.org/onlinedocs/libgomp.pdf;>also in


[wwwdocs] document modula-2 in gcc-13/changes.html (and index.html)

2023-02-03 Thread Gaius Mulley via Gcc-patches


Hello,

The following patch provides a summary of the modula-2 front end
and also contains links to the online modula-2 documentation in
index.html.

[I'm just about to git push fixes so that modula-2 builds html, info and
 pdf documentation into the standard directories.]

regards,
Gaius




diff --git a/htdocs/gcc-13/changes.html b/htdocs/gcc-13/changes.html
index 9ecd115c..fa13369f 100644
--- a/htdocs/gcc-13/changes.html
+++ b/htdocs/gcc-13/changes.html
@@ -283,6 +283,18 @@ a work-in-progress.
 
 
 
+Modula-2
+
+  Support for the language Modula-2 has been added.  The dialects
+  supported are PIM2, PIM3, PIM4 and ISO/IEC 10514-1.  Also included
+  are a complete set of ISO/IEC 10514-1 libraries and PIM
+libraries.
+  https://gcc.gnu.org/onlinedocs/m2/Compiler-options.html;>
+  Compiler options.
+  The <* noreturn *> attribute is supported.
+  Linking has been redesigned.
+
+
 
 
 
diff --git a/htdocs/onlinedocs/index.html b/htdocs/onlinedocs/index.html
index 343ff9f5..27a8a505 100644
--- a/htdocs/onlinedocs/index.html
+++ b/htdocs/onlinedocs/index.html
@@ -1647,6 +1647,12 @@ existing release.
href="https://gcc.gnu.org/onlinedocs/gdc.ps.gz;>PostScript or https://gcc.gnu.org/onlinedocs/gdc-html.tar.gz;>an
HTML tarball)
+https://gcc.gnu.org/onlinedocs/m2/;>GNU M2 Manual (https://gcc.gnu.org/onlinedocs/m2.pdf;>also in
+   PDF or https://gcc.gnu.org/onlinedocs/m2.ps.gz;>PostScript or https://gcc.gnu.org/onlinedocs/m2-html.tar.gz;>an
+   HTML tarball)
 https://gcc.gnu.org/onlinedocs/libgomp/;>GNU Offloading and
Multi Processing Runtime Library Manual (https://gcc.gnu.org/onlinedocs/libgomp.pdf;>also in


Re: For Modula-2 build-tree testing, also set up paths to compiler libraries

2023-01-31 Thread Gaius Mulley via Gcc-patches
Thomas Schwinge  writes:

> Hi!
>
> On 2022-10-10T16:31:26+0100, Gaius Mulley via Gcc-patches 
>  wrote:
>> Here are the dejagnu expect library scripts for the gm2
>> testsuite.
>
> This (or some variant thereof; haven't checked), became part of
> commit r13-4704-g1eee94d351774cdc2efc8ee508b82d065184c6ee
> "Merge modula-2 front end onto gcc".
>
>
> For build-tree testing ('$gccpath != ""'; such as standard 'make check'),
> 'gm2_link_flags' takes care to set up paths to a number of libraries that
> may be necessary:
>
>> --- /dev/null 2022-08-24 16:22:16.88870 +0100
>> +++ gcc-git-devel-modula2/gcc/testsuite/lib/gm2.exp   2022-10-07 
>> 20:21:18.718097775 +0100
>
>> +set gm2_link_libraries "m2pim m2iso";
>
>> +#  gm2_link_flags - detects the whereabouts of libraries (-lstdc++).
>> +#
>> +
>> +proc gm2_link_flags { paths } {
>> +global srcdir;
>> +global ld_library_path;
>> +global gccpath;
>> +global gm2_link_libraries;
>> +
>> +set gccpath ${paths}
>> +set libio_dir ""
>> +set flags ""
>> +set ld_library_path "."
>> +
>> +set shlib_ext [get_shlib_extension]
>> +verbose "shared lib extension: $shlib_ext"
>> +
>> +if { $gccpath == "" } {
>> +  global tool_root_dir
>> +
>> +  set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
>> +  if { $libstdcpp != "" } {
>> +  append flags "-L${libstdcpp} "
>> +  append ld_library_path ":${libstdcpp}"
>> +  }
>> +} else {
>> + if [file exists "${gccpath}/lib/libstdc++.a"] {
>> + append ld_library_path ":${gccpath}/lib"
>> + }
>> + if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
>> + append flags "-L${gccpath}/libstdc++ "
>> + append ld_library_path ":${gccpath}/libstdc++"
>> + }
>> + if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
>> + append flags " -L${gccpath}/libstdc++-v3/src/.libs "
>> + append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
>> + }
>> + # Look for libstdc++.${shlib_ext}.
>> + if [file exists 
>> "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
>> + append flags " -L${gccpath}/libstdc++-v3/src/.libs "
>> + append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
>> + }
>> +
>> + # puts stderr "${gm2_link_libraries}  before foreach"
>> + foreach d [list {*}${gm2_link_libraries}] {
>> + # puts stderr "${d}  "
>> + send_log "ld_library_path was ${ld_library_path}\n"
>> + send_log "looking for ${gccpath}/lib${d}/.libs/lib${d}.a\n"
>> + if [file exists "${gccpath}/libgm2/lib${d}/.libs/lib${d}.a"] {
>> + send_log "good found 
>> ${gccpath}/libgm2/lib${d}/.libs/lib${d}.a\n"
>> + # append flags " -L${gccpath}/libgm2/lib${d}/.libs -l${d}"
>> + append flags " ${gccpath}/libgm2/lib${d}/.libs/lib${d}.a"
>> + append ld_library_path ":${gccpath}/libgm2/lib${d}/.libs"
>> + }
>> + send_log "ld_library_path is ${ld_library_path}\n"
>> + }
>> +}
>> +
>> +set_ld_library_path_env_vars
>> +return "$flags"
>> +}
>
> However, this misses compiler libraries (such as libgcc, which libstdc++
> may depend on).  For example, I see my x86_64-pc-linux-gnu '-m32' testing
> not pick up the build-tree libgcc, but instead some random system one,
> which (expectedly) doesn't satisfy requirements of other build-tree
> libraries:
>
> [...]/build-gcc/gcc/testsuite/gm225/m.x0: 
> /lib/i386-linux-gnu/libgcc_s.so.1: version `GCC_7.0.0' not found (required by 
> [...]/build-gcc/x86_64-pc-linux-gnu/32/libstdc++-v3/src/.libs/libstdc++.so.6)
>
> ..., and thus a lot of execution FAILs.
>
> To cure that, OK to push the attached
> "For Modula-2 build-tree testing, also set up paths to compiler libraries"?
>
>
> Grüße
>  Thomas
>
>
> -
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
> München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
> Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
&g

Re: [PATCH] modula2/108462 - duplicate install of static modula2 target libs

2023-01-31 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

> On Mon, 23 Jan 2023, Richard Biener wrote:
>
>> The following addresses the fact that libgm2 installs static libraries
>> into two places, one performed by
>> 
>> toolexeclib_LTLIBRARIES = libm2cor.la
>> 
>> and one performed as part of the install-data-local rule to a
>> m2/m2cor subdirectory alongside Modula-2 .def and .mod files.
>> 
>> This patch opts to keep the copy installed by libtool and removes
>> the extra installs in the install-data-local rules.
>> 
>> I've built and installed both with and without
>> --enable-version-specific-runtime-libs and compiled and linked
>> a Modula-2 testcase with the installed compiler with the two
>> multilibs and with and without static successfully.
>> 
>> OK for trunk?
>
> Ping.

yes sure, LGTM

A heads up that I've just renamed the gcc/m2/gm2-libs-pim directory to
gcc/m2/gm2-libs-log for consistency.  I've just tried the patch (post
rename changes) and the patch builds and installs fine (non bootstrap
test build though),

regards,
Gaius


Re: [COMMITTED] testsuite: Restore TORTURE_OPTIONS in gm2/warnings/returntype/fail/warnings-returntype-fail.exp

2023-01-30 Thread Gaius Mulley via Gcc-patches
Rainer Orth  writes:

> Between 20230126 and 20230127, 1100+ gm2 tests started to FAIL for the
> non-default multilib, e.g.
>
> FAIL: gm2/calling-c/datatypes/unbounded/run/pass/m.mod compilation, 
> {additional_flags= -O0 -g -Werror=return-type } timeout=10
> UNRESOLVED: gm2/calling-c/datatypes/unbounded/run/pass/m.mod execution, 
> {additional_flags= -O0 -g -Werror=return-type } timeout=10
> FAIL: gm2/case/pass/testcase1.mod,  -O0 -g -Werror=return-type  
> [...]
> cc1gm2: warning: '-Werror=' argument '-Werror=return-type' is not valid for 
> Modula-2
>
> I'm seeing this on all of Solaris/x86, Solaris/SPARC, and Linux/x86_64.
>
> I could trace this to
> gm2/warnings/returntype/fail/warnings-returntype-fail.exp not properly
> restoring TORTURE_OPTIONS.
>
> Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11.  Installed on
> trunk.
>
>   Rainer

apologies and many thanks for detecting and fixing this bug

regards,
Gaius


Re: [PATCH] modula-2: Fixes for preprocessing [PR102343, PR108182]

2023-01-25 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86_64, powerpc64 - linux-gnu (with 32b multilibs),
> i686, powerpc darwin (with 64b multilibs) x86_64 darwin (with and without
> 32b multilib).
> OK for trunk?
> thanks
> Iain
>
> --- 8< ---
>
> Modula-2 uses the C preprocessor to implement handling for conditional
> code and macros.  However, this is not done directly, because the process
> is applied recursively to imported definitions and modules.
>
> The cc1gm2 executable records the parameters as a template command line
> needed to create a composite 'cc1 -E' for each file to be preprocessed
> starting with the main file from the original command line.
>
> This patch fixes the capture of the C preprocessor template to include
> the target information needed for correct multilib operation.
>
> In order to match the existing semantics of '-E, -M and -MM' these have
> to be handled as a 'pre-processor only' job (i.e. the recursion is omitted
> and only the main file is processed).
>
> Whereas C-family front ends always pre-process, Modula-2 only does so
> when specifically requested (via the -fcpp option).
>
> '-MD, -MMD and -MQ' also require special handling, since (in principle)
> these options can be applied to any command line (with -fcpp) providing
> dependency information as a by-product.
>
> TODO: the preprocessor is not able to determine def and mod dependencies
> for Modula-2 and so the output of this only shows the object to module
> dep.  We should be able to append the .def and .mod dependencies.
>
> The patch amends save-temps handling to cater for the preprocessor
> recursion and to avoid writing saved files into the source directories.
>
> The patch changes the extension for Modula-2 preprocessed source to .m2i
> to avoid clashes with .i.
>
> The main driver code is amended to add default handlers for .mod and .m2i
> so that a useful error message will be emitted if the Modula-2 compiler
> is not built-in.
>
> The compiler will now also handle code generation from a .m2i preprocessed
> source.
>
> TODO: We should not need to pass the '-c' option to the compiler to alter
> the processing of init code.
>
> Signed-off-by: Iain Sandoe 
>
>   PR modula2/102343
>   PR modula2/108182
>
> gcc/ChangeLog:
>
>   * gcc.cc: Provide default specs for Modula-2 so that when the
>   language is not built-in better diagnostics are emitted for
>   attempts to use .mod or .m2i file extensions.
>
> gcc/m2/ChangeLog:
>
>   * gm2-compiler/M2Comp.mod: Early exit for pre-processor-only jobs.
>   * gm2-compiler/M2Options.def (SetPPOnly, GetPPOnly, SetMD, GetMD,
>   SetMMD, GetMMD, SetMQ, GetMQ, SetObj, GetObj, SetDumpDir,
>   GetDumpDir):New.
>   * gm2-compiler/M2Options.mod:(SetPPOnly, GetPPOnly, SetMD, GetMD,
>   SetMMD, GetMMD, SetMQ, GetMQ, SetObj, GetObj, SetDumpDir,
>   GetDumpDir):New.
>   * gm2-compiler/M2Preprocess.def (PreprocessModule): Add flag to
>   indicate the main file.
>   * gm2-compiler/M2Preprocess.mod: Handle Preprocess-only jobs,
>   handle MD, MMD and MQ options.
>   * gm2-gcc/m2options.h (M2Options_SetPPOnly, M2Options_GetPPOnly,
>   M2Options_SetDumpDir, M2Options_SetMD, M2Options_GetMD,
>   M2Options_SetMMD, M2Options_GetMMD, M2Options_SetMQ, M2Options_GetMQ,
>   M2Options_SetObj, M2Options_GetObj): New.
>   * gm2-gcc/m2type.cc (m2type_InitBaseTypes): Early exit for pre-
>   processor-only jobs.
>   * gm2-lang.cc (gm2_langhook_init): Handle preprocess-only commands.
>   (gm2_langhook_option_lang_mask): Claim C and Driver options so that
>   we can intercept them for building pre-processor commands.
>   (gm2_langhook_init_options): Collect the preprocessor line here.
>   Save options that have different actions for preprocessor and compile
>   commands.
>   (gm2_langhook_handle_option): Only handle the modula-2 options here.
>   (gm2_langhook_post_options): Do not create a back-end for pre-
>   processor-only jobs.
>   * gm2spec.cc (lang_specific_driver): Ignore PCH options, append a
>   scaffold-main for cases where we are building a main module with
>   -c.
>   * lang-specs.h: Revise to handle preprocessor-only jobs and to
>   consume pre-processed files.
>   * lang.opt: Remove Driver and C options copies (we claim these
>   separately).


Hi Iain,

yes LGTM - thanks for the fixes and it is great to have the ability for
gm2 to handle preprocessed source

regards,
Gaius


Re: [PATCH] modula-2: Fix stack size request in initPreemptive [PR108405]

2023-01-23 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Given that, currently, this value is not configurable per target the
> short-term solution is to avoid a bad request.
>
> Tested on x86_64-darwin21, OK for trunk?
> thanks
> Iain

Hi Iain,

yes this is fine.  LGTM - thanks

regards,
Gaius


Re: [PATCH] modula-2, driver, Front end: Revise handling of I and L paths [PR108182].

2023-01-23 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86_64-linux-gnu (with a 32b multilib), powerpc, i686 and
> x86_64-darwin.  OK for trunk?
> thanks,
> Iain
>
> --- 8< ---
>
> The adds the includes in the FE as done in other GCC languages.
> It also revises the library handling to avoid additional -L options
> from hiding LIBDIR.
>
> For the include/import paths as presented to the front end initialisation,
> we capture them and then arrange to emit the 'standard library' paths in
> the same order as specified for C.
>
> The specs are tidied up.

yes LGTM - apologies for the delay

thank you!
Gaius


Re: [PATCH] Modula-2, testsuite: Remove use of concatenated paths.

2023-01-22 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> tested on x86_64-darwin21 with an updated compiler that does not support
> the path concatentation and on an unpatched trunk.
> OK for trunk?
> thanks
> Iain
>
> --- 8< ---
>
> The original implementation for Modula-2 search paths allows things like
> '-I/path/a:/path/b'.  Such paths are not compatible with the rest of the
> compiler (in particular, the preprocessor, which Modula-2 uses).  In
> preparation for removing that idiom, this patch rewrites the cases in the
> testsuite and removes string processing where possible from lists of paths.
>
> TODO: There are some apparent discrepancies and/or extraneous insertions
> of partial include paths (especially in gm2_init_log, gm2_init_iso and
> gm2_init_pim) - to be handled in some future patch.
>
> Signed-off-by: Iain Sandoe 
>
> gcc/testsuite/ChangeLog:
>
>   * gm2/case/pass/case-pass.exp: Update for removal of concatenated
>   paths.
>   * gm2/complex/pass/complex-pass.exp: Likewise.
>   * gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp: Likewise.
>   * gm2/iso/analysis/fail/iso-analysis-fail.xp: Likewise.
>   * gm2/iso/check/fail/iso-check-fail.exp: Likewise.
>   * gm2/iso/fail/iso-fail.exp: Likewise.
>   * gm2/iso/pass/iso-pass.exp: Likewise.
>   * gm2/isolib/run/pass/isolib-run-pass.exp: Likewise.
>   * gm2/pim/fail/pim-fail.exp: Likewise.
>   * gm2/pim/pass/pim-pass.exp: Likewise.
>   * gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp: Likewise.
>   * gm2/pimlib/pass/pimlib-pass.exp: Likewise.
>   * gm2/pimlib/run/pass/pimlib-run-pass.exp: Likewise.
>   * gm2/projects/iso/run/pass/halma/projects-iso-run-pass-halma.exp: 
> Likewise.
>   * gm2/projects/iso/run/pass/hello/projects-iso-run-pass-hello.exp: 
> Likewise.
>   * gm2/projects/log/run/pass/hello/projects-log-run-pass-hello.exp: 
> Likewise.
>   * gm2/projects/pim/run/pass/hello/projects-pim-run-pass-hello.exp: 
> Likewise.
>   * gm2/recover/pass/recover-pass.exp: Likewise.
>   * gm2/switches/makeall/fail/switches-makeall-fail.exp: Likewise.
>   * gm2/switches/makeall/pass/switches-makeall-pass.exp: Likewise.
>   * gm2/switches/none/run/pass/gm2-none.exp: Likewise.
>   * gm2/switches/pim2/run/pass/switches-pim2-run-pass.exp: Likewise.
>   * gm2/ulmlib/pass/ulmlib-pass.exp: Likewise.
>   * gm2/ulmlib/std/pass/ulmlib-std-pass.exp: Likewise.
>   * gm2/ulmlib/sys/pass/ulmlib-sys-pass.exp: Likewise.
>   * lib/gm2.exp: Make the paths list a mandatory entry for each 
> gm2_init_xxx
>   function. Remove the use of concatenated include and library paths.
>   Remove string processing where possible.

LGTM - many thanks,

regards,
Gaius


Re: [PATCH] modula2/108144 - Fix multilib install of libgm2

2023-01-20 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

> The following adjusts libgm2 to properly use the multilib build
> infrastructure, thereby fixing the install with
> --enable-version-specific-runtime-libs
>
> In particular config-ml.pl needs to be applied to generated Makefiles
> as documented in the manual and we have to avoid clobbering the
> variables via make arguments.  The explicit install rules used different
> ways to construct the multilib dir which isn't necessary and breaks
> when MUTLIDIR is now finally set correctly.  Instead use
> $(toolexeclibdir).
>
> This results in some dead variables in the Makefile.am (and there were
> some before), I refrained from doing even more changes here.
>
> Verified with an install with and without 
> --enable-version-specific-runtime-libs
> and checking the result.
>
> OK?
>
> Thanks,
> Richard.

Many thanks for this fix - and the deep magic AC_FOREACH config-ml.in
recursion rhunes.  LGTM

regards,
Gaius


Re: [PATCH] modula-2, testsuite: Make libs and interfaces consistent.

2023-01-19 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86_64-linux-gnu (with a 32b multilib), powerpc, i686 and
> x86_64-darwin.  OK for trunk?
> thanks,
> Iain

LGTM, thank you

regards,
Gaius


Re: [PATCH] modula2/108144 - fix --enable-version-specific-runtime-libs

2023-01-19 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

> The following fixes --enable-version-specific-runtime-libs for
> the modula2 target libraries.  The issue is that the install
> happens via for example
>
> toolexeclib_LTLIBRARIES = libm2cor.la
>
> and toolexeclibdir is set to $(toolexecdir)/$(gcc_version)$(MULTISUBDIR)
> but the Makefile.am do not define $(gcc_version) but instead
> $(version) which is used locally to define libsubdir.  The fix
> is to consistently define and use $(gcc_version), also properly
> supporting --with-gcc-major-version-only
>
> Built and installed on x86_64-unknown-linux-gnu with
> --enable-version-specific-runtime-libs and --with-gcc-major-version-only.
>
> OK?
>
> Thanks,
> Richard. 

yes LGTM and thanks for the fix!

regards,
Gaius


Re: [PATCH] contrib: Partial fix for failed update-copyright --this year [PR108413]

2023-01-17 Thread Gaius Mulley via Gcc-patches
Jakub Jelinek  writes:

> Hi!
>
> As mentioned on IRC or in PR108413, the last update-copyright.py --this year
> failed and that is why we are in a strange state where some copyrights have
> been updated and others have not.
> The full list of errors I got was I think:
> gcc/m2/mc-boot/GmcOptions.c: unrecognised copyright: comment (f, (const char 
> *) "Copyright (C) ''2021'' Free Software Foundation, Inc.", 53);
> gcc/m2/mc-boot/GmcOptions.c: unrecognised copyright: comment (f, (const char 
> *) "Copyright (C) ''2021'' Free Software Foundation, Inc.", 53);
> gcc/testsuite/gm2/switches/pedantic-params/pass/Strings.mod: unrecognised 
> copyright holder: Faculty of Information Technology,
> gcc/testsuite/gm2/switches/pedantic-params/pass/Strings2.mod: unrecognised 
> copyright holder: Faculty of Information Technology,
> libphobos/libdruntime/__builtins.di: unrecognised copyright: * Copyright: 
> Copyright Digital Mars 2022
> libstdc++-v3/src/c++17/fast_float/fast_float.h: unrecognised copyright 
> holder: The fast_float authors
> libstdc++-v3/include/c_compatibility/stdatomic.h: unrecognised copyright 
> holder: The GCC developers
>
> The following patch deals with the gcc/testsuite/gm2 ones and
> with the fast_float.h one, ok for trunk?
>
> Not really sure what we should do in the GmcOptions.c case
> (perhaps obfuscate it in the source somehow by splitting
> the string literals into different substrings
> Perhaps "Copy" "right (" "C) ''..." would do it?  Or do we want
> to bump there each year (manually or by the script)?
> E.g. in gcc.cc we have
>   printf ("Copyright %s 2023 Free Software Foundation, Inc.\n",
>   _("(C)"));
> which also prints (C) nicer in Unicode if possible and is updated
> by hand each year.
>

Hi,

I've git pushed some fixes for gcc/m2/mc/mcOptions.mod to obfuscate the
copyright text.  The change to mcOptions.mod also includes the removal
of the 'YEAR' constant and it queries the system for the year.  A
summary of the ChangeLog:

gcc/m2/ChangeLog:

* mc-boot/GmcOptions.c: Rebuilt.
* mc/mcOptions.mod (displayVersion):
Split first printf into three components
* mc/mcOptions.mod (YEAR): Remove.
(getYear): New procedure function.
(displayVersion): Use result from getYear instead of YEAR.
Emit boilerplate for GPL v3.
(gplBody): Use result from getYear instead of YEAR.
(glplBody): Use result from getYear instead of YEAR.

regards,
Gaius


Re: [PATCH] modula-2: Handle pass '-v' option to the compiler.

2023-01-12 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86-64-darwin21.
> OK for trunk?
> Iain

yes LGTM,

thanks,
Gaius

> --- 8< ---
>
> Somehow this setting had been missed, and we really need the verbose
> flag to enable useful debug output.
>
> Signed-off-by: Iain Sandoe 
>
> gcc/m2/ChangeLog:
>
>   * gm2-gcc/m2options.h (M2Options_SetVerbose): Export the
>   function.
>   * gm2-lang.cc: Handle OPT_v, passing it to the compiler.
>   * lang-specs.h: Pass -v to cc1gm2.
> ---
>  gcc/m2/gm2-gcc/m2options.h | 1 +
>  gcc/m2/gm2-lang.cc | 3 +++
>  gcc/m2/lang-specs.h| 2 +-
>  3 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/m2/gm2-gcc/m2options.h b/gcc/m2/gm2-gcc/m2options.h
> index 4b32c911b09..beaa460ffa9 100644
> --- a/gcc/m2/gm2-gcc/m2options.h
> +++ b/gcc/m2/gm2-gcc/m2options.h
> @@ -106,6 +106,7 @@ EXTERN int M2Options_GetCpp (void);
>  EXTERN int M2Options_GetM2g (void);
>  EXTERN void M2Options_SetM2g (int value);
>  EXTERN void M2Options_SetLowerCaseKeywords (int value);
> +EXTERN void M2Options_SetVerbose (int value);
>  EXTERN void M2Options_SetUnusedVariableChecking (int value);
>  EXTERN void M2Options_SetUnusedParameterChecking (int value);
>  EXTERN void M2Options_SetStrictTypeChecking (int value);
> diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
> index 49f93901d3c..073d1dd55db 100644
> --- a/gcc/m2/gm2-lang.cc
> +++ b/gcc/m2/gm2-lang.cc
> @@ -451,6 +451,9 @@ gm2_langhook_handle_option (
>  case OPT_save_temps_:
>M2Options_SetSaveTempsDir (arg);
>return 1;
> +case OPT_v:
> +  M2Options_SetVerbose (value);
> +  return 1;
>  default:
>if (insideCppArgs)
>   {
> diff --git a/gcc/m2/lang-specs.h b/gcc/m2/lang-specs.h
> index 0a34b0bc6d7..bf882649b21 100644
> --- a/gcc/m2/lang-specs.h
> +++ b/gcc/m2/lang-specs.h
> @@ -34,6 +34,6 @@ along with GCC; see the file COPYING3.  If not see
>{"@modula-2",
>"cc1gm2 " M2CPP
>"  %(cc1_options) %{B*} %{c*} %{+e*} %{I*} "
> -  "  %{i*} %{save-temps*} "
> +  "  %{i*} %{save-temps*} %{v} "
>"  %i %{!fsyntax-only:%(invoke_as)}",
>0, 0, 0},


Re: [PATCH v3 17/19] modula2 front end: dejagnu expect library scripts

2023-01-10 Thread Gaius Mulley via Gcc-patches
Jason Merrill  writes:

> On 12/6/22 09:47, Gaius Mulley via Gcc-patches wrote:
>> Here are the dejagnu expect library scripts for the gm2
>> testsuite.
>
> A couple of weeks ago I noticed on a testrun that the modula tests
> didn't seem to be timing out properly, so I made this change.  It
> looks like they didn't run at all in the bootstrap/test I did just
> now, so I don't know if this change is actually helpful, but here it
> is if you think it makes sense:

awesome, many thanks for the patch - it certainly looks as if the
timeout library was absent from lib/gm2.exp (and also gm2-torture.exp).
I've also applied this fix to gm2-torture.exp and will git commit/git
push your patch

regards,
Gaius


Re: [PATCH, Modula2] PR-108142 Many empty directories created in the build directory

2023-01-10 Thread Gaius Mulley via Gcc-patches
Jakub Jelinek  writes:

> On Tue, Jan 10, 2023 at 11:16:28AM +0100, Richard Biener via Gcc-patches 
> wrote:
>> > @@ -424,7 +388,7 @@ override PLUGINCFLAGS := $(filter-out 
>> > -mdynamic-no-pic,$(PLUGINCFLAGS))
>> >
>> >  plugin/m2rte$(soext): $(srcdir)/m2/plugin/m2rte.cc 
>> > $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
>> >  insn-attr-common.h insn-flags.h $(generated_files)
>> > -   test -d plugin || mkdir plugin
>> > +   -test -d plugin || $(mkinstalldirs) plugin
>> 
>> I wonder if that's possibly racy (that's why you use mkinstalldirs?)?
>
> Using $(mkinstalldirs) in the patch is what I've suggested because
> previously the patch was using mkdir -p which we almost never use
> (I think only some Ada Makefiles).  Above when it is a single directory
> mkdir is fine.
>   -test -d $(TESTSUITEDIR) || mkdir $(TESTSUITEDIR)
> etc. is what is used in gcc/Makefile.in in some spots.
> If 2 shells do that test -d plugin || mkdir plugin at the same time,
> then yes, both might do mkdir, but that is why we have the - at the start,
> the error of doing mkdir twice will be ignored then.

thanks both - will apply the patch and close the PR

regards,
Gaius


Re: Missing dependencies in m2/ ?

2023-01-09 Thread Gaius Mulley via Gcc-patches
Jeff Law  writes:

> I'm still seeing it as of about 2 hours ago:
>
> http://law-sandy.freeddns.org:8080/job/avr-elf/2125/console
>
> A good run (yesterday):
>
> http://law-sandy.freeddns.org:8080/job/avr-elf/2124/console
>
>
Hi Jeff,

many thanks for the urls above - useful I'll attempt to reproduce the
gcc compile.

> However, I did find that my scripts were enabling all languages --
> sorry I stated otherwise and blamed it on the M2 front-end.

No problem at all - it allowed me to find I was using wrong
version of autoconf :-).

> THe only issue we need to resolve is the dependency problems.

Yes indeed, I think I've found some missing dependencies which I'll push
to git when the bootstrap completes.  In the meantime here is the patch:

regards,
Gaius

--- o< --- o< --- o< --- o< --- o< --- o< --- o<
diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index 08d0f3b963f..5c173f22540 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -1360,7 +1360,7 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) 
$(BUILD-MC-INTERFACE-O) \
  $(BUILD-MC-INTERFACE-O) m2/mc-boot/main.o \
  mcflex.o m2/gm2-libs-boot/RTcodummy.o -lm
 
-m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.c
+m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.c 
m2/gm2-libs/gm2-libs-host.h
$(CXX) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot 
-I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
 
 m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c 
m2/gm2-libs/gm2-libs-host.h
@@ -1373,7 +1373,7 @@ m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.c 
$(srcdir)/m2/init/mcinit
$(CXX) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) 
m2/mc-boot/main.c -o $@
 
-mcflex.o: mcflex.c
+mcflex.o: mcflex.c m2/gm2-libs/gm2-libs-host.h
$(CC) -I$(srcdir)/m2/mc -g -c $< -o $@   # remember that mcReserved.h 
is copied into m2/mc
 
 mcflex.c: $(srcdir)/m2/mc/mc.flex


[PATCH, Modula2] PR-108142 Many empty directories created in the build directory

2023-01-09 Thread Gaius Mulley via Gcc-patches


PR-108142 Modula-2 configure generates many subdirectories in the top
build directory.  This patch dynamically creates subdirectories under
gcc/m2 if and when required.

Bootstrapped on x86_64 gnu/linux, ok for master?

regards,
Gaius


gcc/m2/ChangeLog:

* Make-lang.in (GM2_1): Change -B path to m2/stage1.
($(objdir)/m2/images/gnu.eps): Check and create dest dir
if necessary.
(gm2-libs.texi-check): Check and create dir m2/gm2-libs-pim,
m2/gm2-libs-iso and m2/gm2-libs if necessary.
($(objdir)/m2/gm2-compiler-boot): Remove.
($(objdir)/m2/gm2-libs-boot): Remove.
($(objdir)/m2/gm2-libs-libiberty): Remove.
($(objdir)/m2/gm2-libiberty): Remove.
($(objdir)/m2/gm2-gcc): Remove.
($(objdir)/m2/gm2-compiler): Remove.
($(objdir)/m2/gm2-libs): Remove.
($(objdir)/m2/gm2-libs-iso): Remove.
($(objdir)/m2/gm2-libs-min): Remove.
($(objdir)/m2/gm2-compiler-paranoid): Remove.
($(objdir)/m2/gm2-libs-paranoid): Remove.
($(objdir)/m2/gm2-compiler-verify): Remove.
($(objdir)/m2/boot-bin): Remove.
($(objdir)/m2/gm2-libs-pim): Remove.
($(objdir)/m2/gm2-libs-coroutines): Remove.
(stage1/m2): Remove.
(stage2/m2): Remove.
(stage3/m2): Remove.
(m2.stageprofile): New rule.
(m2.stagefeedback): New rule.
(cc1gm2$(exeext)): Change dependent name.
(m2/stage2/cc1gm2$(exeext)): Change dependent name.
Check and create dest dir.
(m2/stage1/cc1gm2$(exeext)): Check and create dest dir
if necessary.
(m2/gm2-gcc/%.o): Ditto.
(m2/gm2-gcc/rtegraph.o): Ditto.
(m2/gm2-gcc/$(SRC_PREFIX)%.h): Ditto.
(m2/gm2-gcc/$(SRC_PREFIX)%.h): Ditto.
(m2/mc-boot): Ditto.
(m2/mc-boot-ch): Ditto.
(m2/gm2-libs-boot): Ditto.
(m2/gm2-compiler-boot): Ditto.
(m2/gm2-compiler): Ditto.
(m2/gm2-libiberty): Ditto.
(m2/gm2-compiler): Ditto.
(m2/gm2-libs-iso): Ditto.
(m2/gm2-libs): Ditto.
(m2/gm2-libs-min): Ditto.
(m2/gm2-libs-coroutines): Ditto.
(m2/boot-bin): Ditto.
(m2/pge-boot): Ditto.
(m2/pge-boot): Ditto.
* Make-maintainer.in (m2/gm2-ppg-boot): Check and create
dest dir if necessary.
(m2): Ditto.
(m2/gm2-ppg-boot): Ditto.
(m2/gm2-pg-boot): Ditto.
(m2/gm2-auto): Ditto.
(m2/gm2-pg-boot): Ditto.
(m2/gm2-pge-boot): Ditto.
($(objdir)/plugin): Ditto.
($(objdir)/m2/mc-boot-ch): Ditto.
($(objdir)/m2/mc-boot-gen): Ditto.
(m2/boot-bin): Ditto.
(m2/mc): Ditto.
(m2/mc-obj): Ditto.
($(objdir)/m2/gm2-ppg-boot): Ditto.
($(objdir)/m2/gm2-pg-boot): Ditto.
($(objdir)/m2/gm2-pge-boot): Ditto.
(m2/mc-boot-gen): Ditto.
(m2/m2obj3): Ditto.
(m2/gm2-libs-paranoid): Ditto.
(m2/gm2-compiler-paranoid): Ditto.
(m2/gm2-libs-paranoid): Ditto.
(m2/gm2-compiler-paranoid): Ditto.
(m2/gm2-libs-paranoid): Ditto.
(m2/gm2-compiler-paranoid): Ditto.
* config-lang.in (m2/gm2-compiler-boot): Remove mkdir.
(m2/gm2-libs-boot): Ditto.
(m2/gm2-ici-boot): Ditto.
(m2/gm2-libiberty): Ditto.
(m2/gm2-gcc): Ditto.
(m2/gm2-compiler): Ditto.
(m2/gm2-libs): Ditto.
(m2/gm2-libs-iso): Ditto.
(m2/gm2-compiler-paranoid): Ditto.
(m2/gm2-libs-paranoid): Ditto.
(m2/gm2-compiler-verify): Ditto.
(m2/boot-bin): Ditto.
(m2/gm2-libs-pim): Ditto.
(m2/gm2-libs-coroutines): Ditto.
(m2/gm2-libs-min): Ditto.
(m2/pge-boot): Ditto.
(plugin): Ditto.
(stage1/m2): Ditto.
(stage2/m2): Ditto.
(stage3/m2): Ditto.
(stage4/m2): Ditto.
(m2/gm2-auto): Ditto.
(m2/gm2-pg-boot): Ditto.
(m2/gm2-pge-boot): Ditto.
(m2/gm2-ppg-boot): Ditto.
(m2/mc-boot): Ditto.
(m2/mc-boot-ch): Ditto.
(m2/mc-boot-gen): Ditto.

-- o< -- o< -- o< -- o< -- o< -- o< -- o<
diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index 08d0f3b963f..a3751109481 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -27,7 +27,7 @@ GM2_CROSS_NAME = `echo gm2|sed 
'$(program_transform_cross_name)'`

 M2_MAINTAINER = no

-GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g
+GM2_1 = ./gm2 -B./m2/stage1 -g -fm2-g

 GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ 
-L$(objdir)/../ld $(TFLAGS)

@@ -71,7 +71,6 @@ m2.srcextra: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi 
m2/gm2-libs.texi m2/gm2-ebnf.
-cp -p m2/SYSTEM-iso.texi $(srcdir)/m2
-cp -p m2/gm2-libs.texi $(srcdir)/m2
-cp -p m2/gm2-ebnf.texi $(srcdir)/m2
-   find . -name '*.texi' -print
 else
 m2.srcextra:
 endif
@@ -167,7 +166,7 @@ doc/m2.info: $(TEXISRC)
else true; fi

 

Re: [PATCH] Modula-2: fix documentation layout

2023-01-09 Thread Gaius Mulley via Gcc-patches
Eric Botcazou  writes:

> Hi,
>
> the Modula-2 documentation is rejected by older versions of Makeinfo because 
> the web of @node markers is fairly broken, apparently some subsections were 
> moved around, most notably between the Overview and Using sections, and the 
> @node markers were not (properly) adjusted.
>
> This patch allows me to build it with these older versions, as well as with 
> modern versions.  OK for mainline?
>
>
> 2023-01-09  Eric Botcazou  
>
>   * doc/gm2.texi (Overview): Fix @node markers.
>   (Using): Likewise.  Remove subsections that were moved to
>   Overview from the menu and move others around.

Hi Eric,

yes indeed and thanks for the patch!

regards,
Gaius


Re: Missing dependencies in m2/ ?

2023-01-08 Thread Gaius Mulley via Gcc-patches
Jeff Law via Gcc-patches  writes:

> I've been getting sporatic errors like this since the introduction of
> the modula-2 front-end:
>
>> In file included from ../../..//gcc/gcc/m2/mc-boot/GSFIO.c:29:
>> ../../..//gcc/gcc/system.h:556:20: error: conflicting declaration of C 
>> function 'const char* strsignal(int)'
>>   556 | extern const char *strsignal (int);
>>   |^
>> In file included from /usr/include/c++/12/cstring:42,
>>  from ../../..//gcc/gcc/system.h:241:
>> /usr/include/string.h:478:14: note: previous declaration 'char* 
>> strsignal(int)'
>>   478 | extern char *strsignal (int __sig) __THROW;
>>   |  ^
>> In file included from ../../..//gcc/gcc/system.h:707:
>> ../../..//gcc/gcc/../include/libiberty.h:112:14: error: ambiguating new 
>> declaration of 'char* basename(const char*)'
>>   112 | extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL 
>> ATTRIBUTE_NONNULL(1);
>>   |  ^~~~
>> /usr/include/string.h:524:26: note: old declaration 'const char* 
>> basename(const char*)'
>>   524 | extern "C++" const char *basename (const char *__filename)
>>   |  ^~~~
>> make[1]: *** [../../..//gcc/gcc/m2/Make-lang.in:1364: m2/mc-boot/GSFIO.o] 
>> Error 1
>
>
> They seem to come and go without rhyme or reason.  For example build
> #1885 on lm32-elf failed, while #1884 passed.
>
> Aside from the fact that I coonfigure with --enable-languages=c,c++
> and yet modula-2 stuff still gets built (can that be fixed?) it seems
> like we're missing dependencies to ensure that the generated config.h
> file is made before building the modula-2 stuff.
>
> In a good build you'll see something like this:
>
> config.status: creating auto-host.h
> [ ... ]
> Build GSFIO.o:
> g++ -g -c -I. -I../../..//gcc/gcc/m2/mc-boot-ch
> -I../../..//gcc/gcc/m2/mc-boot -I../../..//gcc/gcc/../include 
> -I../../..//gcc/gcc -I. -Im2/mc-boot -I../../..//gcc/gcc
>  -I../../..//gcc/gcc/m2/mc-boot -I../../..//gcc/gcc/../include 
> -I../../..//gcc/gcc/../libcpp/include -I../../..//gcc/gcc/../libcody
>  -I../../..//gcc/gcc/../libdecnumber 
> -I../../..//gcc/gcc/../libdecnumber/dpd -I../libdecnumber
>  -I../../..//gcc/gcc/../libbacktrace 
> ../../..//gcc/gcc/m2/mc-boot/GSFIO.c -o m2/mc-boot/GSFIO.o
>
> Which naturally works just fine.
>
> In a bad build, auto-host.h is _not_ created before trying to build GSFIO.o.
>
> Can you please take care of this.  It's rather annoying to have builds
> failing in the continuous testing system like this, particularly when 
> modula-2 isn't even enabled.
>
> Jeff

Hi Jeff,

many apologies for the breakage - I've now added the Makefile
dependencies.  I've also regenerated the m2 configure scripts

regards,
Gaius


[PATCH, modula2] v2 PR-108182 gm2 driver mishandles target and multilib options

2023-01-07 Thread Gaius Mulley via Gcc-patches


Hi,

This is version 2 with the SKIPOPT applied to every option given to
save_switch.

ok for master?  Bootstrapped on x86_64 gnu/linux and darwin.

regards,
Gaius



PR-108182 gm2 driver mishandles target and multilib options

here are some patches which attempt to allow target specific include
paths and library paths in the gm2 driver.  I admit that the patch has
flaws in that it only processes options -f, -m in the lang_specific_driver.
[Called after driver::set_up_specs but before read_specs is called].

I suspect a better implementation might be to use a spec function
to fixup the paths.

gcc/ChangeLog:

* gcc.cc (save_switch): Remove static declaration.
(get_multilib_dir): New function.
(reset_mdswitches): New function.
* gcc/gcc.h (save_switch): Declare extern.
(get_multilib_dir): New extern.
(reset_mdswitches): New extern.

gcc/m2/ChangeLog:

* gm2spec.cc (lang_specific_driver): Detect -m and -f options and
call save_switch and SKIPOPT.  Assign multilib_dir with the result
of get_multilib_dir.  Call reset_mdswitches afterwards.

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index d629ca5e424..362a6a96b63 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -3849,7 +3849,7 @@ alloc_switch (void)
 /* Save an option OPT with N_ARGS arguments in array ARGS, marking it
as validated if VALIDATED and KNOWN if it is an internal switch.  */

-static void
+void
 save_switch (const char *opt, size_t n_args, const char *const *args,
 bool validated, bool known)
 {
@@ -9559,6 +9559,24 @@ default_arg (const char *p, int len)
   return 0;
 }

+/* Return the value of multilib_dir.  */
+
+const char *
+get_multilib_dir (void)
+{
+  set_multilib_dir ();
+  return multilib_dir;
+}
+
+/* Reset the mdswitches array to empty.  */
+
+void
+reset_mdswitches (void)
+{
+  n_mdswitches = 0;
+  mdswitches = NULL;
+}
+
 /* Work out the subdirectory to use based on the options. The format of
multilib_select is a list of elements. Each element is a subdirectory
name followed by a list of options followed by a semicolon. The format
diff --git a/gcc/gcc.h b/gcc/gcc.h
index 19a61b373ee..03646ff2d87 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -73,6 +73,11 @@ struct spec_function
 extern int do_spec (const char *);
 extern void record_temp_file (const char *, int, int);
 extern void set_input (const char *);
+extern const char *get_multilib_dir (void);
+extern void reset_mdswitches (void);
+extern void save_switch (const char *opt, size_t n_args,
+const char *const *args,
+bool validated, bool known);

 /* Spec files linked with gcc.cc must provide definitions for these.  */

diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
index 583723da416..d813de4ab46 100644
--- a/gcc/m2/gm2spec.cc
+++ b/gcc/m2/gm2spec.cc
@@ -797,8 +797,20 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
  if ((decoded_options[i].orig_option_with_args_text != NULL)
  && (strncmp (decoded_options[i].orig_option_with_args_text,
   "-m", 2) == 0))
-   multilib_dir = xstrdup 
(decoded_options[i].orig_option_with_args_text
-   + 2);
+   {
+ save_switch (decoded_options[i].orig_option_with_args_text,
+  0, NULL, true, true);
+ args[i] |= SKIPOPT;
+   }
+ else if ((decoded_options[i].orig_option_with_args_text != NULL)
+  && (strncmp (decoded_options[i].orig_option_with_args_text,
+   "-f", 2) == 0))
+   {
+ save_switch (decoded_options[i].orig_option_with_args_text,
+  0, NULL, true, true);
+ args[i] |= SKIPOPT;
+   }
+ break;
}
 }
   if (language != NULL && (strcmp (language, "modula-2") != 0))
@@ -864,10 +876,13 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
   if ((! (seen_uselist || seen_gen_module_list)) && linking)
 append_option (OPT_fgen_module_list_, "-", 1);

+  multilib_dir = get_multilib_dir ();
+  reset_mdswitches ();
   if (allow_libraries)
 {
   /* If the libraries have not been specified by the user but the
-dialect has been specified then select the appropriate libraries.  */
+dialect has been specified then select the appropriate
+libraries.  */
   if (libraries == NULL)
{
  if (strcmp (dialect, "iso") == 0)


Re: [PATCH] modula-2, libm2min: Declare abort and exit as expected.

2023-01-07 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested with a build on x86_64-darwin21, the build warnings are gone and
> the build completed as normal.
> OK for master?
> thanks
> Iain
>
> --- 8< ---
>
> The build is currently emitting a warning that abort() is declared differently
> from the built-in.  This updates the declaration to match expectations.
>
> Signed-off-by: Iain Sandoe 
>
> gcc/m2/ChangeLog:
>
>   * gm2-libs-min/libc.c (abort): Update declaration to match the
>   expected form, add no-return attribute.
>   (exit): Add no-return attribute.
> ---
>  gcc/m2/gm2-libs-min/libc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/m2/gm2-libs-min/libc.c b/gcc/m2/gm2-libs-min/libc.c
> index b39bfffb65c..8cddb5dd7b4 100644
> --- a/gcc/m2/gm2-libs-min/libc.c
> +++ b/gcc/m2/gm2-libs-min/libc.c
> @@ -24,10 +24,10 @@ a copy of the GCC Runtime Library Exception along with 
> this program;
>  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  .  */
>  
> -void abort (int);
> -void exit (int);
> +extern void abort (void)  __attribute__ ((__noreturn__));
> +extern void exit (int) __attribute__ ((__noreturn__));
>  
> -void abort (int i)
> +void abort (void)
>  {
>while (1)
>  ;

yes LGTM, thanks!

regards,
Gaius


[PATCH, modula2] PR-108182 gm2 driver mishandles target and multilib options

2023-01-06 Thread Gaius Mulley via Gcc-patches



ChangeLog entry follows:

regards,
Gaius



[PATCH, modula2] PR-108182 gm2 driver mishandles target and multilib options

here are some patches which attempt to allow target specific include
paths and library paths in the gm2 driver.  I admit that the patch has
flaws in that it only processes options -f, -m in the lang_specific_driver.
[Called after driver::set_up_specs but before read_specs is called].

I suspect a better implementation might include a language callback
(lang_post_spec) which could fixup target related paths.

gcc/ChangeLog:

* gcc.cc (save_switch): Remove static declaration.
(get_multilib_dir): New function.
(reset_mdswitches): New function.
* gcc/gcc.h (save_switch): Declare extern.
(get_multilib_dir): New extern.
(reset_mdswitches): New extern.

gcc/m2/ChangeLog:

* gm2spec.cc (lang_specific_driver): Detect -m and -f options and
call save_switch.  Assign multilib_dir with the result of
get_multilib_dir.  Call reset_mdswitches afterwards.


[PATCH, modula2] PR-108182 gm2 driver mishandles target and multilib options

2023-01-06 Thread Gaius Mulley via Gcc-patches


Hi,

here are some patches which attempt to allow target specific include
paths and library paths in the gm2 driver.  I admit that the patch has
flaws in that it only processes options -f, -m in the lang_specific_driver.
[Called after driver::set_up_specs but before read_specs is called].

I suspect a better implementation might include a language callback
(lang_post_spec) which could fixup target related paths.

Nevertheless as a stage3 bugfix (workaround) they are presented below:

I wonder if they would be suitable for master?

Tested on Darwin (prior cleanup) and X86_64 Linux

regards,
Gaius

- o< - o< - o< - o< - o< - o< - o< - o<
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index d629ca5e424..362a6a96b63 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -3849,7 +3849,7 @@ alloc_switch (void)
 /* Save an option OPT with N_ARGS arguments in array ARGS, marking it
as validated if VALIDATED and KNOWN if it is an internal switch.  */

-static void
+void
 save_switch (const char *opt, size_t n_args, const char *const *args,
 bool validated, bool known)
 {
@@ -9559,6 +9559,24 @@ default_arg (const char *p, int len)
   return 0;
 }

+/* Return the value of multilib_dir.  */
+
+const char *
+get_multilib_dir (void)
+{
+  set_multilib_dir ();
+  return multilib_dir;
+}
+
+/* Reset the mdswitches array to empty.  */
+
+void
+reset_mdswitches (void)
+{
+  n_mdswitches = 0;
+  mdswitches = NULL;
+}
+
 /* Work out the subdirectory to use based on the options. The format of
multilib_select is a list of elements. Each element is a subdirectory
name followed by a list of options followed by a semicolon. The format
diff --git a/gcc/gcc.h b/gcc/gcc.h
index 19a61b373ee..03646ff2d87 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -73,6 +73,11 @@ struct spec_function
 extern int do_spec (const char *);
 extern void record_temp_file (const char *, int, int);
 extern void set_input (const char *);
+extern const char *get_multilib_dir (void);
+extern void reset_mdswitches (void);
+extern void save_switch (const char *opt, size_t n_args,
+const char *const *args,
+bool validated, bool known);

 /* Spec files linked with gcc.cc must provide definitions for these.  */

diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
index 583723da416..dbfd1ca 100644
--- a/gcc/m2/gm2spec.cc
+++ b/gcc/m2/gm2spec.cc
@@ -797,8 +797,14 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
  if ((decoded_options[i].orig_option_with_args_text != NULL)
  && (strncmp (decoded_options[i].orig_option_with_args_text,
   "-m", 2) == 0))
-   multilib_dir = xstrdup 
(decoded_options[i].orig_option_with_args_text
-   + 2);
+   save_switch (decoded_options[i].orig_option_with_args_text,
+0, NULL, true, true);
+ else if ((decoded_options[i].orig_option_with_args_text != NULL)
+  && (strncmp (decoded_options[i].orig_option_with_args_text,
+   "-f", 2) == 0))
+ save_switch (decoded_options[i].orig_option_with_args_text,
+  0, NULL, true, true);
+ break;
}
 }
   if (language != NULL && (strcmp (language, "modula-2") != 0))
@@ -864,10 +870,13 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
   if ((! (seen_uselist || seen_gen_module_list)) && linking)
 append_option (OPT_fgen_module_list_, "-", 1);

+  multilib_dir = get_multilib_dir ();
+  reset_mdswitches ();
   if (allow_libraries)
 {
   /* If the libraries have not been specified by the user but the
-dialect has been specified then select the appropriate libraries.  */
+dialect has been specified then select the appropriate
+libraries.  */
   if (libraries == NULL)
{
  if (strcmp (dialect, "iso") == 0)



Re: [PATCH] modula-2: Remove uses of scalb*() and significand*() [PR107631]

2023-01-05 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86_64-darwin21 and x86_64-linux-gnu without any m2 regressions.
> OK for trunk?
> thanks
> Iain

yes sure LGTM

thank you!
Gaius


Re: [PATCH] modula-2, driver: Implement handling for -static-libgm2.

2023-01-04 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Hi Gaius,
>
>> On 4 Jan 2023, at 12:11, Gaius Mulley  wrote:
>> 
>> Iain Sandoe  writes:
>> 
>>> tested on x86_64-linux-gnu, x86_64,aarch64-darwin21,
>
>> 
>> yes LGTM - it was unimplemented - thanks!
>
> My apologies, when I came to apply this I realised that I posted the wrong
> version of the patch - omitting the documentation changes.
>
> Here is the version with (albeit basic) documentation.
> Still OK for master?
> Iain

Hi Iain,

yes LGTM

thanks,
Gaius

> [PATCH] modula-2, driver: Implement handling for -static-libgm2.
>
> This was unimplemented so far.
>
> gcc/ChangeLog:
>
>   * common.opt: Add -static-libgm2.
>   * config/darwin.h (LINK_SPEC): Handle static-libgm2.
>   * doc/gm2.texi: Document static-libgm2.
>   * gcc.cc (driver_handle_option): Allow static-libgm2.
>
> gcc/m2/ChangeLog:
>
>   * gm2spec.cc (lang_specific_driver): Handle static-libgm2.
>   * lang.opt: Add static-libgm2.
> ---
>  gcc/common.opt  |  4 
>  gcc/config/darwin.h |  7 ++-
>  gcc/doc/gm2.texi|  4 
>  gcc/gcc.cc  | 12 +++-
>  gcc/m2/gm2spec.cc   | 24 +++-
>  gcc/m2/lang.opt |  4 
>  6 files changed, 48 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 97a78030228..d0371aec8db 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -3622,6 +3622,10 @@ static-libgfortran
>  Driver
>  ; Documented for Fortran, but always accepted by driver.
>  
> +static-libgm2
> +Driver
> +; Documented for Modula-2, but always accepted by driver.
> +
>  static-libphobos
>  Driver
>  ; Documented for D, but always accepted by driver.
> diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
> index efe3187cd96..e6f76e598e6 100644
> --- a/gcc/config/darwin.h
> +++ b/gcc/config/darwin.h
> @@ -447,7 +447,12 @@ extern GTY(()) int darwin_ms_struct;
> %{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos 
> libgphobos.a%s)}\
> 
> %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp
>  libgomp.a%s)}\
> %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ 
> libstdc++.a%s)}\
> -   %{force_cpusubtype_ALL:-arch %(darwin_arch)} \
> +   %{static|static-libgm2:%:replace-outfile(-lm2pim libm2pim.a%s)}\
> +   %{static|static-libgm2:%:replace-outfile(-lm2iso libm2iso.a%s)}\
> +   %{static|static-libgm2:%:replace-outfile(-lm2min libm2min.a%s)}\
> +   %{static|static-libgm2:%:replace-outfile(-lm2log libm2log.a%s)}\
> +   %{static|static-libgm2:%:replace-outfile(-lm2cor libm2cor.a%s)}\
> +  %{force_cpusubtype_ALL:-arch %(darwin_arch)} \
> %{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\
> LINK_SYSROOT_SPEC \
>"%{mmacosx-version-min=*:-macosx_version_min %*} \
> diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
> index 513fdd3ec7f..18cb798c6cd 100644
> --- a/gcc/doc/gm2.texi
> +++ b/gcc/doc/gm2.texi
> @@ -573,6 +573,10 @@ the they provide the base modules which all other 
> dialects utilize.
>  The option @samp{-fno-libs=-} disables the @samp{gm2} driver from
>  modifying the search and library paths.
>  
> +@item -static-libgm2
> +On systems that provide the m2 runtimes as both shared and static libraries,
> +this option forces the use of the static version.
> +
>  @c flocation=
>  @c Modula-2 Joined
>  @c set all location values to a specific value (internal switch)
> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> index 91313a8516d..d629ca5e424 100644
> --- a/gcc/gcc.cc
> +++ b/gcc/gcc.cc
> @@ -4540,12 +4540,14 @@ driver_handle_option (struct gcc_options *opts,
>  case OPT_static_libgfortran:
>  case OPT_static_libquadmath:
>  case OPT_static_libphobos:
> +case OPT_static_libgm2:
>  case OPT_static_libstdc__:
> -  /* These are always valid, since gcc.cc itself understands the
> -  first two, gfortranspec.cc understands -static-libgfortran,
> -  d-spec.cc understands -static-libphobos, g++spec.cc
> -  understands -static-libstdc++ and libgfortran.spec handles
> -  -static-libquadmath.  */
> +  /* These are always valid; gcc.cc itself understands the first two
> +  gfortranspec.cc understands -static-libgfortran,
> +  libgfortran.spec handles -static-libquadmath,
> +  d-spec.cc understands -static-libphobos,
> +  gm2spec.cc understands -static-libgm2,
> +  and g++spec.cc understands -static-libstdc++.  */
>validated = true;
>break;
>  
> diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
> index b9a5c4e79bb..583723da416 100644
> --- a/gcc/m2/gm2spec.cc
> +++

Re: [PATCH 4/n] modula-2, driver: Handle static-libstd++ for targets without static/dynamic

2023-01-04 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Oops pressed ‘send' too soon - this is part of the series for Darwin:
>
> There are several modula-2 issues on Darwin, some blocking bootstrap on
> one or more system versions.
>
> This has been tested on powerpc/i688-darwin9 .. x86_64-darwin10,17,21 and
> the prototype aarch64-darwin branch on darwin21.
>
> OK for trunk?
> thanks
> Iain

sure, LGTM

regards,
Gaius

>> On 30 Dec 2022, at 10:58, Iain Sandoe  wrote:
>> 
>> The follows the pattern used in C++ and D drivers to pass -static-libstdc++
>> onto the target driver to allow spec substitution of static libraries.
>> 
>> NOTE: The general handling of Bstatic/dynamic and the possible use of static
>> libgm2 libraries is unimplemented in this driver so far.  It seems likely
>> that the driver construction could be greatly simplified if the modula-2
>> runtimes were combined into fewer (hopefully, one) libraries.
>> 
>> Signed-off-by: Iain Sandoe 
>> 
>> gcc/m2/ChangeLog:
>> 
>>  * gm2spec.cc (lang_specific_driver): Pass -static-libstdc++ on to
>>  the target driver if the linker does not support Bstatic/dynamic.
>> ---
>> gcc/m2/gm2spec.cc | 5 +
>> 1 file changed, 5 insertions(+)
>> 
>> diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
>> index 680dd3602ef..b9a5c4e79bb 100644
>> --- a/gcc/m2/gm2spec.cc
>> +++ b/gcc/m2/gm2spec.cc
>> @@ -767,7 +767,12 @@ lang_specific_driver (struct cl_decoded_option 
>> **in_decoded_options,
>> 
>>  case OPT_static_libstdc__:
>>library = library >= 0 ? 2 : library;
>> +#ifdef HAVE_LD_STATIC_DYNAMIC
>> +  /* Remove -static-libstdc++ from the command only if target supports
>> + LD_STATIC_DYNAMIC.  When not supported, it is left in so that a
>> + back-end target can use outfile substitution.  */
>>args[i] |= SKIPOPT;
>> +#endif
>>break;
>> 
>>  case OPT_stdlib_:
>> -- 
>> 2.37.1 (Apple Git-137.1)
>> 


[PATCH modula2] Add missing declarations to gcc/m2/gm2-libs-min/M2RTS.def

2023-01-04 Thread Gaius Mulley via Gcc-patches


Bootstrapped on gnu/linux x86_64

Ok for trunk?

thanks
Gaius

- o< - o< - o< - o< - o<


Add missing declarations to gcc/m2/gm2-libs-min/M2RTS.def

This patch adds two missing procedures to gcc/m2/gm2-libs-min/M2RTS.def
required for linking (the procedures are already present in the pim and
iso M2RTS.def).  The patch also includes test code, changes to
gcc/testsuite/lib/gm2.exp and an expect tcl script to test the min
libraries.


gcc/m2/ChangeLog:

* gm2-libs-min/M2RTS.def (ConstructModules): New procedure
declaration.
(DeconstructModules): New procedure declaration.

gcc/testsuite:

* lib/gm2.exp (gm2_init_minx): New procedure.
(gm2_init_min): New procedure calls gm2_init_min with
dialect flags.
* gm2/link/min/pass/tiny.mod: New test case.
* gm2/link/min/pass/link-min-pass.exp: New file.


diff --git a/gcc/m2/gm2-libs-min/M2RTS.def b/gcc/m2/gm2-libs-min/M2RTS.def
index e3e13b7b554..147024ebe78 100644
--- a/gcc/m2/gm2-libs-min/M2RTS.def
+++ b/gcc/m2/gm2-libs-min/M2RTS.def
@@ -38,6 +38,10 @@ TYPE
all these procedures do nothing except satisfy the linker.
 *)

+PROCEDURE ConstructModules (applicationmodule: ADDRESS;
+argc: INTEGER; argv, envp: ADDRESS) ;
+PROCEDURE DeconstructModules (applicationmodule: ADDRESS;
+  argc: INTEGER; argv, envp: ADDRESS) ;
 PROCEDURE RegisterModule (name: ADDRESS;
   init, fini:  ArgCVEnvP;
   dependencies: PROC) ;
diff --git a/gcc/testsuite/lib/gm2.exp b/gcc/testsuite/lib/gm2.exp
index 450cb4c2d35..9eba195291a 100644
--- a/gcc/testsuite/lib/gm2.exp
+++ b/gcc/testsuite/lib/gm2.exp
@@ -496,3 +496,42 @@ proc gm2_init_cor { {path ""} args } {
 gm2_link_lib "m2cor m2pim m2iso"
 gm2_init {*}${theIpath} -fpim {*}${theLpath} {*}${args};
 }
+
+
+#
+#  gm2_init_minx - set the default libraries to choose MIN library and
+#  choose Modula-2, dialect.
+#
+#
+
+proc gm2_init_minx { dialect {path ""} args } {
+global srcdir;
+global gccpath;
+
+set gm2src ${srcdir}/../m2;
+
+send_log "srcdir is $srcdir\n"
+send_log "gccpath is $gccpath\n"
+send_log "gm2src is $gm2src\n"
+
+set minIpath "${gccpath}/libgm2/libm2min";
+set minLpath "${gccpath}/libgm2/libm2min/.libs";
+
+set theIpath "-I${minIpath}";
+set theLpath "-L${minLpath}";
+
+if { $path != "" } then {
+   append theIpath " -I"
+   append theIpath ${path}
+}
+gm2_init {*}${theIpath} {*}${dialect} {*}${theLpath} {*}${args};
+}
+
+#
+#  gm2_init_min - set the default libraries to choose MIN libraries
+# and pim dialect.
+#
+
+proc gm2_init_min { {path ""} args } {
+gm2_init_minx -fpim {*}${path} {*}${args};
+}
diff --git a/gcc/testsuite/gm2/link/min/pass/link-min-pass.exp 
b/gcc/testsuite/gm2/link/min/pass/link-min-pass.exp
new file mode 100644
index 000..88d180ec31e
--- /dev/null
+++ b/gcc/testsuite/gm2/link/min/pass/link-min-pass.exp
@@ -0,0 +1,37 @@
+# Expect driver script for GCC Regression Tests
+# Copyright (C) 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file was written by Gaius Mulley (gaiusm...@gmail.com)
+# for GNU Modula-2.
+
+if $tracelevel then {
+strace $tracelevel
+}
+
+# load support procs
+load_lib gm2-torture.exp
+
+gm2_init_min "${srcdir}/gm2/min/pass"
+
+foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
+# If we're only testing specific files and this isn't one of them, skip it.
+if ![runtest_file_p $runtests $testcase] then {
+   continue
+}
+
+gm2-torture $testcase
+}
diff --git a/gcc/testsuite/gm2/link/min/pass/tiny.mod 
b/gcc/testsuite/gm2/link/min/pass/tiny.mod
new file mode 100644
index 000..e1165edbe4a
--- /dev/null
+++ b/gcc/testsuite/gm2/link/min/pass/tiny.mod
@@ -0,0 +1,7 @@
+MODULE tiny ;
+
+(* Does nothing at all, but it should link if -flibs=min is used.  *)
+
+BEGIN
+
+END tiny.


Re: [PATCH] modula-2, driver: Implement handling for -static-libgm2.

2023-01-04 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> tested on x86_64-linux-gnu, x86_64,aarch64-darwin21,
> OK for trunk?
> thanks,
> Iain
>
> --- 8< ---
>
> This was unimplemented so far.
>
> gcc/ChangeLog:
>
>   * common.opt: Add -static-libgm2.
>   * config/darwin.h (LINK_SPEC): Handle static-libgm2.
>
> gcc/m2/ChangeLog:
>
>   * gm2spec.cc (lang_specific_driver): Handle static-libgm2.
> ---
>  gcc/common.opt  |  4 
>  gcc/config/darwin.h |  7 ++-
>  gcc/m2/gm2spec.cc   | 24 +++-
>  3 files changed, 33 insertions(+), 2 deletions(-)
>

yes LGTM - it was unimplemented - thanks!

regards,
Gaius


Re: [PATCH] modula-2: Module registration constructors need to be visible [PR108259].

2023-01-04 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86_64-linux-gnu, x86_64,aarch64-darwin21.
> There remain issues with shared libraries, but the link fails are fixed
> by this.
>
> OK for master?
> Thanks
> Iain
>
> --- 8< ---
>
> In the current design the main executable links explicitly to the module
> registration construtors that it uses.  This means that they must be
> visible in shared libraries.
>
>   PR modula2/108259
>
> gcc/m2/ChangeLog:
>
>   * gm2-gcc/m2decl.cc (m2decl_DeclareModuleCtor): Make module
>   registration constructors visible.
> ---
>  gcc/m2/gm2-gcc/m2decl.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/m2/gm2-gcc/m2decl.cc b/gcc/m2/gm2-gcc/m2decl.cc
> index 62bfefd2530..d849f8aefc4 100644
> --- a/gcc/m2/gm2-gcc/m2decl.cc
> +++ b/gcc/m2/gm2-gcc/m2decl.cc
> @@ -276,7 +276,7 @@ m2decl_DeclareModuleCtor (tree decl)
>/* Declare module_ctor ().  */
>TREE_PUBLIC (decl) = 1;
>DECL_ARTIFICIAL (decl) = 1;
> -  DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
> +  DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
>DECL_VISIBILITY_SPECIFIED (decl) = 1;
>DECL_STATIC_CONSTRUCTOR (decl) = 1;
>return decl;

LGTM thanks,

Gaius


Re: [PATCH] modula-2: Fix registration of modules via constructors [PR108183].

2023-01-04 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

>  When I first made this patch I had a question as to what should be
>  done for registration CTORs generated by the compiler for .mod files.
>  I've now answered that question (the code that makes the GCC decl
>  has also be updated in a separately posted patch).
>  
> tested on x86_64-linux-gnu, x86_64, aarch64-darwin21,
> OK for master?
> Thanks,
> Iain
>  
>  --- 8< ---
>
> This reworks the mechanism used for module registration to use init-
> time constructors.  The order of registration is not important, the
> actual initialization dependency tree will be computed early in the
> execution (all that matters is that we have registered before that).
>
> This fixes a potential issue in which the external name known to the
> m2 system is of the form _M2_XX_ctor() but the C++ code was
> producing a static variable instance with the same name.
>
> Signed-off-by: Iain Sandoe 
>
>   PR modula2/108183
>
> gcc/m2/ChangeLog:
>
>   * gm2-libs-ch/UnixArgs.cc (_M2_UnixArgs_ctor): Rework to use
>   an extern "C" function with 'constructor' attribute.
>   * gm2-libs-ch/dtoa.cc (_M2_dtoa_ctor): Likewise.
>   * gm2-libs-ch/ldtoa.cc (_M2_ldtoa_ctor): Likewise.
>
> libgm2/ChangeLog:
>
>   * libm2cor/KeyBoardLEDs.cc (_M2_KeyBoardLEDs_ctor): Rework to use
>   an extern "C" function with 'constructor' attribute.
>   * libm2iso/ErrnoCategory.cc (_M2_ErrnoCategory_ctor): Likewise.
>   * libm2iso/RTco.cc (_M2_RTco_ctor): Likewise.
>   * libm2pim/Selective.cc (_M2_Selective_ctor): Likewise.
>   * libm2pim/SysExceptions.cc (_M2_SysExceptions_ctor): Likewise.
>   * libm2pim/UnixArgs.cc (_M2_UnixArgs_ctor): Likewise.
>   * libm2pim/cgetopt.cc (_M2_cgetopt_ctor): Likewise.
>   * libm2pim/dtoa.cc (_M2_dtoa_ctor): Likewise.
>   * libm2pim/errno.cc (_M2_errno_ctor): Likewise.
>   * libm2pim/ldtoa.cc (_M2_ldtoa_ctor): Likewise.
>   * libm2pim/sckt.cc (_M2_sckt_ctor): Likewise.
>   * libm2pim/termios.cc (_M2_termios_ctor): Likewise.
>   * libm2pim/wrapc.c: Add a new line to the file end.

all LGTM  (together with the other GCC decl patch),

thanks,
Gaius


Re: [PATCH] modula-2, doc: Build dvi, ps and pdf doc in the gcc/doc directory.

2023-01-04 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on darwin21 with "make m2.pdf" and "make m2.dvi".
> OK for trunk?
> thanks.
> Iain
>
> --- 8< ---
>
> This also uses the configured $(TEXI2DVI) and $(TEXI2PDF) to deal with those
> targets (since we cannot assume to know what the user might have installed).
>
> gcc/m2/ChangeLog:
>
>   * Make-lang.in (dvi, ps, pdf): Build in the gcc/doc directory, also
>   use the configured tools for texi -> dvi and texi -> pdf.
> ---
>  gcc/m2/Make-lang.in | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index a134d3aca92..6c2b095bb7d 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -140,18 +140,22 @@ $(DESTDIR)$(man1dir)/$(GM2_INSTALL_NAME)$(man1ext): 
> doc/m2.1 installdirs
>   -$(INSTALL_DATA) $< $@
>   -chmod a-x $@
>  
> -m2.dvi: $(TEXISRC)
> +m2.dvi: doc/m2.dvi
> +
> +doc/m2.dvi: $(TEXISRC)
>   $(TEXI2DVI) -I $(objdir)/m2 -I $(srcdir)/doc/include 
> $(srcdir)/doc/gm2.texi -o $@
>  
> -m2.ps: m2.dvi
> +doc/m2.ps: doc/m2.dvi
>   dvips -o $@ $<
>  
> -m2.pdf: m2.ps
> - gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ $<
> +m2.pdf: doc/m2.pdf
> +
> +doc/m2.pdf: $(TEXISRC)
> + $(TEXI2PDF) -I $(objdir)/m2 -I $(srcdir)/doc/include 
> $(srcdir)/doc/gm2.texi -o $@
>  
>  .INTERMEDIATE: m2.pod
>  
> -m2.pod: doc/gm2.texi $(TEXISRC)
> +m2.pod: $(TEXISRC)
>   -$(TEXI2POD) -I $(objdir)/m2 -D m2 < $< > $@
>  
>  doc/m2.info: $(TEXISRC)

thanks LGTM -

regards,
Gaius


Re: [PATCH] Modula-2, testsuite: No 96 bit floating type on Darwin.

2023-01-04 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Tested on x86_64  and aarch64 Darwin,
> OK for master?
> thanks
> Iain
>
> --- 8< ---
>
> The realbitscast.mod is currently failing on x86_64 and aarch64
> Darwin since they do not have a 96b floating type.  Disable the
> type for all Darwin arches.
>
> gcc/testsuite/ChangeLog:
>
>   * gm2/iso/pass/realbitscast.mod: Disable REAL96 on Darwin.
> ---
>  gcc/testsuite/gm2/iso/pass/realbitscast.mod | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/testsuite/gm2/iso/pass/realbitscast.mod 
> b/gcc/testsuite/gm2/iso/pass/realbitscast.mod
> index 4da5cee..c6b70eb032c 100644
> --- a/gcc/testsuite/gm2/iso/pass/realbitscast.mod
> +++ b/gcc/testsuite/gm2/iso/pass/realbitscast.mod
> @@ -28,11 +28,10 @@ FROM SYSTEM IMPORT CAST, WORD ;
>  #elif defined(__ppc__)
>  #   undef HAVE_REAL96
>  #elif defined(__ia64)
> -#   undef HAVE_REAL69
> -#elif defined(__APPLE__) && defined(__i386__)
>  #   undef HAVE_REAL96
>  #elif defined(__APPLE__)
> -#   define HAVE_REAL96
> +(* No 96 bit floating type on Apple platforms *)
> +#   undef HAVE_REAL96
>  #endif

Hi Iain,

sure yes LGTM,

regards,
Gaius


Re: [PATCH 3/n] modula2: Ensure that module registration constructors are 'extern' [PR108183].

2022-12-31 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> There are several modula-2 issues on Darwin, some blocking bootstrap on
> one or more system versions.
>
> This has been tested on powerpc/i688-darwin9 .. x86_64-darwin10,17,21 and
> the prototype aarch64-darwin branch on darwin21.
>
> OK for trunk?
> thanks
> Iain
>
> NOTE: As discussed in the PR, there are likely to be other changes to the
> _definitions_ of the module registration constructors.  This patch only
> relates to the _references_ to those CTORs.
>
> --- 8< ---
>
> The symbols for module registration constructors need to be external
> or we get wrong code generated for targets that allow direct access to
> local symbol definitions.
>
> Signed-off-by: Iain Sandoe 
>
>   PR modula2/108183
>
> gcc/m2/ChangeLog:
>
>   * gm2-compiler/M2GCCDeclare.mod: Module registration constructors are
>   externs to the builder of m2_link.
> ---
>  gcc/m2/gm2-compiler/M2GCCDeclare.mod | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/gcc/m2/gm2-compiler/M2GCCDeclare.mod 
> b/gcc/m2/gm2-compiler/M2GCCDeclare.mod
> index 7e814b631ee..4c177c47398 100644
> --- a/gcc/m2/gm2-compiler/M2GCCDeclare.mod
> +++ b/gcc/m2/gm2-compiler/M2GCCDeclare.mod
> @@ -2294,6 +2294,11 @@ PROCEDURE IsExternal (sym: CARDINAL) : BOOLEAN ;
>  VAR
> mod: CARDINAL ;
>  BEGIN
> +   IF IsProcedure (sym) AND IsExtern (sym)
> +   THEN
> + Assert (NOT IsDefImp (sym));
> + RETURN TRUE
> +   END ;
> mod := GetScope(sym) ;
> REPEAT
>IF mod=NulSym

a very minor change suggested:

VAR
   mod: CARDINAL ;
BEGIN
   Assert (NOT IsDefImp (sym)) ;
   IF IsProcedure (sym) AND IsExtern (sym)
   THEN
  RETURN TRUE
   END ;
   mod := GetScope(sym) ;
   REPEAT
  IF mod=NulSym


as it doesn't make sense to call GetScope from a DefImp symbol.
There is no entry in the double booking tree for DefImp symbols
(definition / implmentation modules) - so it really shouldn't occur.

Other than this obvious change, the patches 1, 2, 3 LGTM - I've also
boot strapped and built these patches (with the above Assert change) on
amd64 gnu/linux for what it is worth,

regards,
Gaius


Re: [PATCH modula2] PR-108142 Remove empty directories created in the build directory

2022-12-29 Thread Gaius Mulley via Gcc-patches
Iain Sandoe  writes:

> Hi Gaius,
>
> I’m finding it hard to figure out how the configuration is supposed to work 
> for cross compilers (and more so for Canadian/native crosses).
>
> Apologies if this is already answered in other review (but maybe some notes 
> would help in that case).
>
> questions in-line, thanks
> Iain

Hi Iain,

many thanks for the comments.  The patch only addresses the empty
directories issue.  I take your point about Canadian cross compiler
problems.  I think there is confusion in my use of stage1, stage2,
stage3 directory names which perhaps should be renamed cxxobj1, m2obj2,
m2obj3.  All objects in cxxobj1 are created by 'mc' and 'g++' and this
would occur if the compiler is built native or in any cross
configuration.

The m2obj2 objects would be built from modula-2 sources using cxxobj1
and would be a developer/maintainer enabled option principally used for
debugging.  Finally m2obj3 is also used by developers to allow the
compiler generations output to be compared (cxxobj1 vs m2obj2 vs
m2obj3).  

This could coexist with the standard stage1, stage2, stage3 of gcc.  The
gcc stage check would only check cxxobj1 having been rebuilt by the
relevant g++/gcc.

I propose to rework the patch (renaming the directories) and ensure that
Canadian cross works (currently it doesn't) - although it was tested for
classic cross (build == host != target).

regards,
Gaius


>> On 26 Dec 2022, at 14:46, Gaius Mulley via Gcc-patches 
>>  wrote:
>>
>>
>> Hello,
>>
>> Bootstrapped on amd64 GNU/Linux.  Ok for trunk?
>>
>> regards,
>> Gaius
>>
>> --- 8< ---
>>
>> PR-108142 Remove empty directories created in the build directory.
>>
>> This patch removes empty directories created in the build directory.
>> Directories are only created if required and all modula-2 build output
>> is created under m2.  Add m2.stageprofile and m2.stagefeedback rules.
>>
>> gcc/m2/ChangeLog:
>>
>>* PR m2/108142
>>  * Make-lang.in: Change build directory to m2.
>>Change all rules to dynamically create subdirectories
>>when required.
>>  (m2.stageprofile): New.
>>  (m2.stagefeedback): New.
>>  * Make-maintainer.in: Change build directory to m2.
>>Change all rules to dynamically create subdirectories when
>>required.
>>  * config-lang.in: Remove static creation of build directories.
>>
>> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
>> index a8bd7fe4d19..828eaad6285 100644
>> --- a/gcc/m2/Make-lang.in
>> +++ b/gcc/m2/Make-lang.in
>> @@ -27,7 +27,7 @@ GM2_CROSS_NAME = `echo gm2|sed 
>> '$(program_transform_cross_name)'`
>>
>> M2_MAINTAINER = no
>>
>> -GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g
>> +GM2_1 = ./gm2 -B./m2/stage1 -g -fm2-g
>
> What does “stage1” mean in the case of a cross-compiler or a
> —disable-bootstrap configure?

stage1 (or the proposed newly named cxxobj1) is created when the first
generation modula-2 compiler is built (using mc/g++).

>> GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ 
>> -L$(objdir)/../ld $(TFLAGS)
>>
>> @@ -61,7 +61,6 @@ m2.srcextra: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi 
>> m2/gm2-libs.texi m2/gm2-ebnf.
>>  -cp -p m2/SYSTEM-iso.texi $(srcdir)/m2
>>  -cp -p m2/gm2-libs.texi $(srcdir)/m2
>>  -cp -p m2/gm2-ebnf.texi $(srcdir)/m2
>> -find . -name '*.texi' -print
>> else
>> m2.srcextra:
>> endif



>> @@ -565,6 +518,7 @@ m2/gm2-gcc/m2configure.o: 
>> $(srcdir)/m2/gm2-gcc/m2configure.cc \
>>$(SYSTEM_H) $(GCC_H) $(CONFIG_H) \
>>m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \
>>$(generated_files) $(C_TREE_H) insn-attr-common.h
>> +-test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
>>  $(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
>>  $(DRIVER_DEFINES) \
>>  -DLIBSUBDIR=\"$(libsubdir)\" \
>> @@ -585,6 +539,7 @@ m2/m2pp.o : $(srcdir)/m2/m2pp.cc 
>> $(GCC_HEADER_DEPENDENCIES_FOR_M2)
>>
>> m2/gm2-gcc/rtegraph.o: $(srcdir)/m2/gm2-gcc/rtegraph.cc 
>> $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
>>gt-m2-rtegraph.h
>> +-test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
>>  $(COMPILER) -c -g -I$(GM2GCC) $(ALL_COMPILERFLAGS) \
>
> GM2GCC = -I$(srcdir)/m2 -Im2 -I$(srcdir)/m2/gm2-gcc -Im2/gm2-gcc ?

allows g++ to pick up the mc translated definition modules in the build
directory gcc/m2/gm2-gcc/G*.h.  Maybe I've misunderstood the question?
There is some redundancy when this macro is used within some rules (I'll
reduce the paths), thanks for spotting it!

> (and in two other places).
>
>> $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
>>
>> @@ -593,6 +548,7 @@ c-family/m2pp.o : $(srcdir)/m2/m2pp.cc 
>> $(GCC_HEADER_DEPENDENCIES_FOR_M2)
>> $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
>>




[PATCH modula2] PR-108142 Remove empty directories created in the build directory

2022-12-26 Thread Gaius Mulley via Gcc-patches


Hello,

Bootstrapped on amd64 GNU/Linux.  Ok for trunk?

regards,
Gaius

--- 8< ---

PR-108142 Remove empty directories created in the build directory.

This patch removes empty directories created in the build directory.
Directories are only created if required and all modula-2 build output
is created under m2.  Add m2.stageprofile and m2.stagefeedback rules.

gcc/m2/ChangeLog:

* PR m2/108142
* Make-lang.in: Change build directory to m2.
Change all rules to dynamically create subdirectories
when required.
(m2.stageprofile): New.
(m2.stagefeedback): New.
* Make-maintainer.in: Change build directory to m2.
Change all rules to dynamically create subdirectories when
required.
* config-lang.in: Remove static creation of build directories.

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index a8bd7fe4d19..828eaad6285 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -27,7 +27,7 @@ GM2_CROSS_NAME = `echo gm2|sed 
'$(program_transform_cross_name)'`
 
 M2_MAINTAINER = no
 
-GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g
+GM2_1 = ./gm2 -B./m2/stage1 -g -fm2-g
 
 GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ 
-L$(objdir)/../ld $(TFLAGS)
 
@@ -61,7 +61,6 @@ m2.srcextra: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi 
m2/gm2-libs.texi m2/gm2-ebnf.
-cp -p m2/SYSTEM-iso.texi $(srcdir)/m2
-cp -p m2/gm2-libs.texi $(srcdir)/m2
-cp -p m2/gm2-ebnf.texi $(srcdir)/m2
-   find . -name '*.texi' -print
 else
 m2.srcextra:
 endif
@@ -153,7 +152,7 @@ doc/m2.info: $(TEXISRC)
else true; fi
 
 $(objdir)/m2/images/gnu.eps: $(srcdir)/m2/images/gnupng
-   test -d m2/images || mkdir -p m2/images
+   -test -d m2/images || $(mkinstalldirs) m2/images
cp $(srcdir)/m2/images/gnu.eps $@
 
 # gm2-libs.texi
@@ -163,6 +162,9 @@ m2/gm2-libs.texi: gm2-libs.texi-check; @true
 ifeq ($(HAVE_PYTHON),yes)
 gm2-libs.texi-check: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/Builtins.texi \
  $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def
+   test -d m2/gm2-libs-pim || $(mkinstalldirs) m2/gm2-libs-pim
+   test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
+   test -d m2/gm2-libs || $(mkinstalldirs) m2/gm2-libs
$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -uLibraries 
-s$(srcdir)/m2 -b$(objdir)/m2 -o $(objdir)/m2/gm2-libs.texi
 else
 gm2-libs.texi-check:
@@ -279,59 +281,21 @@ Builtins.rst-check:  m2/gm2-libs/Builtins.def
 endif
$(STAMP) Builtins.rst-check
 
-$(objdir)/m2/gm2-compiler-boot:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-boot:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libiberty:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-gcc:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-compiler:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-iso:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-min:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-compiler-paranoid:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-paranoid:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-compiler-verify:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/boot-bin:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-pim:
-   test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-coroutines:
-   test -d $@ || mkdir $@
-
-stage1/m2:
-   -test -d $@ || mkdir -p stage1/m2
-
-stage2/m2:
-   -test -d $@ || mkdir -p stage2/m2
-
-stage3/m2:
-   -test -d $@ || mkdir -p stage3/m2
+# Stage hooks:
+# The toplevel makefile has already created stage?/m2 at this point.
 
-stage4/m2:
-   -test -d $@ || mkdir -p stage4/m2
+m2.stage1: stage1-start
+   -mv m2/*$(objext) stage1/m2
+m2.stage2: stage2-start
+   -mv m2/*$(objext) stage2/m2
+m2.stage3: stage3-start
+   -mv m2/*$(objext) stage3/m2
+m2.stage4: stage4-start
+   -mv m2/*$(objext) stage4/m2
+m2.stageprofile: stageprofile-start
+   -mv m2/*$(objext) stageprofile/m2
+m2.stagefeedback: stageprofile-start
+   -mv m2/*$(objext) stagefeedback/m2
 
 # No gm2-specific selftests
 selftest-m2:
@@ -408,7 +372,7 @@ m2.install-plugin: installdirs
 
 plugin/m2rte$(exeext).so: $(srcdir)/m2/plugin/m2rte.cc 
$(GCC_HEADER_DEPENDENCIES_FOR_M2) \
 insn-attr-common.h insn-flags.h $(generated_files)
-   test -d plugin || mkdir plugin
+   -test -d plugin || $(mkinstalldirs) plugin
$(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) -I$(srcdir)/m2 
-I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include 
-Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o 
$(srcdir)/m2/plugin/m2rte.cc
$(PLUGINCC) $(PLUGINCFLAGS) $(PLUGINLIBS) -fno-rtti plugin/m2rte.o 
-shared -o $@
 
@@ -428,20 +392,6 @@ m2.clean:
 m2.extraclean:
 m2.realclean:
 
-# Stage hooks:
-
-m2.stage1: stage1-start
-   -mv m2/*$(objext) stage1/m2
-
-m2.stage2: 

Re: [PATCH] modula2: PR-108119 Disable m2 plugin m2rte

2022-12-21 Thread Gaius Mulley via Gcc-patches
Rainer Orth  writes:

> Hi Gaius,
>
> Btw., you've got a couple of formatting errors in your ChangeLog entires:
>
 ChangeLog:

 * Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
 * Makefile.in : Rebuilt.
>  ^ no blank here.  Besides, the entires are
>usually in present tense ("Rebuild").
>
 * configure.ac (host_tools): Remove unused gm2tools.
 (m2plugin) New AC_ARG_ENABLE.
>   ^ missing :
>
> and several times more.  Just nits, but best keep the entires consistent
> with the GNU Coding Standards.
>
> Thanks.
> Rainer

Hi Rainer,

thanks for spotting these - yes I'll double check ChangeLogs in the
future and adjust to present tense,

regards,
Gaius




Re: [PATCH] modula2: PR-108119 Disable m2 plugin m2rte

2022-12-21 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

>>
>> ChangeLog:
>>
>> * Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
>> * Makefile.in : Rebuilt.
>> * configure : Rebuilt.
>> * configure.ac (host_tools): Remove unused gm2tools.
>> (m2plugin) New AC_ARG_ENABLE.
>> (enable_m2plugin) New AC_SUBST added.
>
> Why's this at the toplevel?

ah sorry - my misunderstanding on how configure and friends work.  I'll
rework the patch local to gcc/m2.  Thanks for spotting this error,

regards,
Gaius


Re: [committed] modula2: Fix lto profiledbootstrap on powerpc64le-linux and s390x-linux [PR108153]

2022-12-21 Thread Gaius Mulley via Gcc-patches
Jakub Jelinek  writes:

> Hi!
>
> Lto profiledbootstrap was failing for me on {powerpc64le,s390x}-linux with
> modula 2 enabled, with:
> cc1gm2: internal compiler error: the location value is corrupt
> 0x11a3d2d m2assert_AssertLocation(unsigned int)
> ../../gcc/m2/gm2-gcc/m2assert.cc:40
> 0x11a3d2d m2statement_BuildAssignmentTree
> ../../gcc/m2/gm2-gcc/m2statement.cc:177
> ICE.  The problem was that caller (m2assert_AssertLocation used
> location_t M2Options_OverrideLocation (location_t);
> prototype with the libcpp/line-map.h
> typedef unsigned int location_t;
> typedef, but the callee defined in Modula 2 was using:
> TYPE
>location_t = INTEGER ;
> and
> PROCEDURE OverrideLocation (location: location_t) : location_t ;
> Now, on powerpc64le-linux unsigned int is returned and passed zero extended
> into 64-bits, while signed int is returned and passed sign-extended into 
> 64-bits
> and Modula 2 INTEGER is signed 32-bit type, so when the caller then compared
> M2Options_OverrideLocation (location) != location
> and powerpc64le-linux performed the comparison as 64-bit compare, there
> was a mismatch for location_t of 0x807 or others with the MSB set.
>
> Fixed by making Modula 2 location_t a CARDINAL, which is 32-bit unsigned type.
>
> Bootstrapped/regtested normally on x86_64-linux and i686-linux, with
> bootstrap-lto profiledbootstrap on powerpc64le-linux and aarch64-linux so
> far (and in regtesting on x86_64-linux, i686-linux and s390x-linux),
> approved in the PR by Gaius, committed to trunk.
>
> 2022-12-21  Jakub Jelinek  
>
>   PR modula2/108153
>   * gm2-gcc/m2linemap.def (location_t): Use CARDINAL instead of INTEGER.
>
> --- gcc/m2/gm2-gcc/m2linemap.def.jj   2022-12-19 14:59:50.169762747 +0100
> +++ gcc/m2/gm2-gcc/m2linemap.def  2022-12-20 16:36:18.321555969 +0100
> @@ -30,7 +30,7 @@ EXPORT QUALIFIED StartFile, EndFile, Sta
>   WarningAtf, NoteAtf, internal_error, location_t ;
>  
>  TYPE
> -   location_t = INTEGER ;
> +   location_t = CARDINAL ;
>  
>  
>  PROCEDURE StartFile (filename: ADDRESS; linebegin: CARDINAL) ;
>
>   Jakub

Hi Jakub,

thanks for finding the bug and the fix!

regards,
Gaius





[PATCH] modula2: PR-108119 Disable m2 plugin m2rte

2022-12-21 Thread Gaius Mulley via Gcc-patches


Hello,

PR-108119 Disable m2 plugin m2rte (provide --enable-m2plugin configure option).

The m2 plugin m2rte attempts to find reachable calls to the m2 exception
handler, but it identifies the m2 exception calls by procedure name.
As this won't work with other languages it should be disabled by default.

This patch disables the plugin from being built.  It provides a new
configure switch --enable-m2plugin to override the default and it will
check the HAVE_PLUGIN of the host and warn if there is a conflict.

Tested on x86_64 GNU/Linux bootstrapped for all languages no extra
failures (m2 tests missing as the plugin is disabled and TCL expect
now disables m2 plugin tests)

ok for trunk?

regards,
Gaius


ChangeLog:

* Makefile.def (extra_configure_flags): Add @enable_m2plugin@.
* Makefile.in : Rebuilt.
* configure : Rebuilt.
* configure.ac (host_tools): Remove unused gm2tools.
(m2plugin) New AC_ARG_ENABLE.
(enable_m2plugin) New AC_SUBST added.

gcc/ChangeLog:

* Makefile.in (enable_m2plugin): Added.
(site.exp): New variable ENABLE_M2PLUGIN.
* config.in: Rebuilt.
* configure : Rebuilt.
* gcc/configure.ac (m2plugin): New AC_ARG_ENABLE.
(enable_m2plugin) New AC_SUBST added.
* doc/install.texi (--enable-m2plugin): Documented.

gcc/m2/ChangeLog:

* gm2spec.cc (ENABLE_PLUGIN): Replaced by ENABLE_M2PLUGIN.  Ensure
that OPT_fplugin option is only created if ENABLE_M2PLUGIN is
defined.
(lang_specific_driver) Change warning to mention
--enable-m2plugin.
* Make-lang.in (enable_m2plugin): Set to no if enable_plugin is
no.
(M2RTE_PLUGIN_SO) New definition.
(m2.all.cross) Use M2RTE_PLUGIN_SO.
(m2.start.encap) Use M2RTE_PLUGIN_SO.
(m2.install-plugin) Use M2RTE_PLUGIN_SO.
(m2.install-plugin) Add dummy rule when enable_m2plugin is no.
(plugin/m2rte$(exeext).so) Add dummy rule when enable_m2plugin is
no.
(stage1/m2/cc1gm2$(exeext) Use M2RTE_PLUGIN_SO.
(stage2/m2/cc1gm2$(exeext) Use M2RTE_PLUGIN_SO.

gcc/testsuite/ChangeLog:

* gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
(ENABLE_M2PLUGIN): Checked to see whether the test should be ignored.
* gm2/iso/check/fail/iso-check-fail.exp (ENABLE_M2PLUGIN): Ditto.
* gm2/switches/auto-init/fail/switches-auto-init-fail.exp
(ENABLE_M2PLUGIN): Ditto.
* gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
(ENABLE_M2PLUGIN): Ditto.
* 
gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
(ENABLE_M2PLUGIN): Ditto.
* 
gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
(ENABLE_M2PLUGIN): Ditto.

diff --git a/Makefile.def b/Makefile.def
index 5f44190154e..d33e4528b63 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -103,7 +103,7 @@ host_modules= { module= libiberty; bootstrap=true;
 // @extra_linker_plugin_flags@ and @extra_linker_plugin_configure_flags@.
 host_modules= { module= libiberty-linker-plugin; bootstrap=true;
module_srcdir=libiberty;
-   extra_configure_flags='@extra_host_libiberty_configure_flags@ 
--disable-install-libiberty @extra_linker_plugin_flags@ 
@extra_linker_plugin_configure_flags@';
+   extra_configure_flags='@extra_host_libiberty_configure_flags@ 
--disable-install-libiberty @extra_linker_plugin_flags@ 
@extra_linker_plugin_configure_flags@ @enable_m2plugin@';
extra_make_flags='@extra_linker_plugin_flags@'; };
 // We abuse missing to avoid installing anything for libiconv.
 host_modules= { module= libiconv;
diff --git a/configure.ac b/configure.ac
index c5191ce24ae..b771f61ef33 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,7 +140,7 @@ host_libs="intl libiberty opcodes bfd readline tcl tk itcl 
libgui zlib libbacktr
 # 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 
gm2tools 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 
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)
@@ -465,13 +465,22 @@ if test "${ENABLE_LIBADA}" != "yes" ; then
   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"
+
+

Re: [PATCH] modula2: Don't treat % in Modula 2 messages specially

2022-12-19 Thread Gaius Mulley via Gcc-patches
Jakub Jelinek  writes:

> Hi!
>
> On top of the just posted patch, this patch makes sure that
> any % chars in message strings aren't treated as format chars.
> None of these functions take variable number of arguments, so for
> most of format specifiers there is nowhere to take arguments from,
> it is true that a couple of format specifiers don't take any
> arguments - %%, %m, %<, %>, %' - so it is actually possible
> to use them, but one needs to verify that no other are emitted and
> that what should be printed as % is really emitted as %%.
> If the FE does that, then please ignore this patch, otherwise I think
> it is safer to do this.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux.

yes it might be possible for % to slip though.  Thus much safer to avoid
the situation by using the patch.

LGTM

regards,
Gaius


Re: [PATCH] modula2: Fix up bootstrap on powerpc64le-linux [PR108147]

2022-12-19 Thread Gaius Mulley via Gcc-patches
Jakub Jelinek  writes:

> Hi!
>
> As mentioned in the PR, bootstrap with m2 enabled currently fails
> on powerpc64le-linux, we get weird ICE after printing some diagnostics.
> The problem is that mc creates from *.def prototypes like
> extern void m2linemap_WarningAtf (m2linemap_location_t location, void * 
> message);
> but the actual function definitions use
> void m2linemap_WarningAtf (m2linemap_location_t location, void * message,
> ...) { code }
> and on powerpc64le-linux such lying about the prototype results in
> wrong-code, on the caller side we assume the function isn't varargs
> and so don't reserve 64 bytes in the frame for it, while the callee
> relies on the area being reserved and stores into it.
>
> Fixed by adding non-stdarg wrappers around stdarg functions (because
> we want va_list and pass it to diagnostics functions).
>
> Bootstrapped/regtested on {x86_64,i686,powerpc64le,s390x,aarch64}-linux,
> ok for trunk?
>
> 2022-12-19  Jakub Jelinek  
>
>   PR modula2/108147
>   * m2/gm2-gcc/m2linemap.def (ErrorAtf, WarningAtf, NoteAtf):
>   Comment out prototypes with varargs.
>   * m2/gm2-gcc/m2linemap.h (m2linemap_ErrorAtf, m2linemap_WarningAtf,
>   m2linemap_NoteAtf): No longer varargs.
>   * m2/gm2-gcc/m2linemap.cc (m2linemap_ErrorAtf): Turned into a
>   non-varargs wrapper around ...
>   (m2linemap_ErrorAtf_1): ... this.  New static function.
>   (m2linemap_WarningAtf): Turned into a non-varargs wrapper around ...
>   (m2linemap_WarningAtf_1): ... this.  New static function.
>   (m2linemap_NoteAtf): Turned into a non-varargs wrapper around ...
>   (m2linemap_NoteAtf_1): ... this.  New static function.

thanks for the patch, both this and the subsequent followup patch LGTM,

regards,
Gaius


[PATCH, m2]: PR-108122 Reduce sleep times in gm2/pimcoroutines/run/pass/testtime.mod

2022-12-17 Thread Gaius Mulley via Gcc-patches


PR-108122 Reduce sleep times in gm2/pimcoroutines/run/pass/testtime.mod

Change time unit to 1 jiffy (with respect to TimerHandler.def) rather
than a second.

gcc/testsuite/ChangeLog:

* gm2/pimcoroutines/run/pass/testtime.mod: Reduce sleep times in
the test by a factor of 25.

Tested on amd64, ok for Trunk?


diff --git a/gcc/testsuite/gm2/pimcoroutines/run/pass/testtime.mod 
b/gcc/testsuite/gm2/pimcoroutines/run/pass/testtime.mod
index fa43163b107..f457716c89e 100644
--- a/gcc/testsuite/gm2/pimcoroutines/run/pass/testtime.mod
+++ b/gcc/testsuite/gm2/pimcoroutines/run/pass/testtime.mod
@@ -1,4 +1,4 @@
-(* Copyright (C) 2005-2020
+(* Copyright (C) 2005-2022
  Free Software Foundation, Inc. *)
 (* This file is part of GNU Modula-2.
 
@@ -31,30 +31,34 @@ FROM SYSTEM IMPORT ADR ;
 FROM libc IMPORT write, printf ;
 
 
+CONST
+   TicksPerTimeUnit = 1 ;
+
+
 (*
-   OneSecond -
+   OneUnit -
 *)
 
-PROCEDURE OneSecond ;
+PROCEDURE OneUnit ;
 VAR
n: CARDINAL ;
 BEGIN
OldInts := TurnInterrupts (MIN (PROTECTION)) ;
-   printf ("1 second process has come to life\n");
+   printf ("1 unit second process has come to life\n");
n := 0 ;
LOOP
-  Sleep (1*TicksPerSecond) ;
+  Sleep (1*TicksPerTimeUnit) ;
   INC (n) ;
-  printf ("%d seconds\n", n);
+  printf ("%d units\n", n);
END
-END OneSecond ;
+END OneUnit ;
 
 
 (*
-   FourSeconds -
+   FourUnits -
 *)
 
-PROCEDURE FourSeconds ;
+PROCEDURE FourUnits ;
 VAR
n: CARDINAL ;
 BEGIN
@@ -62,23 +66,23 @@ BEGIN
printf ("4 seconds process has come to life\n");
n := 0 ;
LOOP
-  Sleep (4*TicksPerSecond) ;
+  Sleep (4*TicksPerTimeUnit) ;
   INC (n) ;
-  printf ("4 second alarm (%d occurance)\n", n);
+  printf ("4 units alarm (%d occurance)\n", n);
END
-END FourSeconds ;
+END FourUnits ;
 
 
 (*
-   SixSeconds -
+   SixUnits -
 *)
 
-PROCEDURE SixSeconds ;
+PROCEDURE SixUnits ;
 VAR
n: CARDINAL ;
 BEGIN
OldInts := TurnInterrupts (MAX (PROTECTION)) ;
-   printf ("6 seconds process has come to life\n");
+   printf ("6 units process has come to life\n");
n := 0 ;
LOOP
   Timeout := ArmEvent (6*TicksPerSecond) ;
@@ -87,10 +91,10 @@ BEGIN
  WriteString ('...someone cancelled it...')
   ELSE
  INC (n) ;
- printf ("6 second alarm (%d occurance)\n", n)
+ printf ("6 unit alarm (%d occurance)\n", n)
   END
END
-END SixSeconds ;
+END SixUnits ;
 
 
 CONST
@@ -107,10 +111,10 @@ BEGIN
 
printf ("now to create three processes...\n") ;
 
-   p1 := Resume (InitProcess (OneSecond  , StackSize, '1')) ;
-   p4 := Resume (InitProcess (FourSeconds, StackSize, '4')) ;
-   p6 := Resume (InitProcess (SixSeconds , StackSize, '6')) ;
+   p1 := Resume (InitProcess (OneUnit  , StackSize, '1')) ;
+   p4 := Resume (InitProcess (FourUnits, StackSize, '4')) ;
+   p6 := Resume (InitProcess (SixUnits , StackSize, '6')) ;
 
-   Sleep (20*TicksPerSecond) ;
+   Sleep (20*TicksPerTimeUnit) ;
printf ("successfully completed, finishing now.\n")
 END testtime.


[PATCH, m2] Add missing m2.stage{profile,feedback} to Make-lang.in

2022-12-16 Thread Gaius Mulley via Gcc-patches



Add missing profile and feedback hooks consistent with
all other frontends.

gcc/m2/ChangeLog:

* Make-lang.in (m2.stageprofile): Added.
(m2.stagefeedback) Added.

Bootstrapped and tested using
configure --with-build-config=bootstrap-lto-lean --enable-languages=m2
make profiledbootstrap-lean
ok for trunk?


diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index a8bd7fe4d19..be33e012dc9 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -442,6 +442,12 @@ m2.stage3: stage3-start
 m2.stage4: stage4-start
-mv m2/*$(objext) stage4/m2
 
+m2.stageprofile: stageprofile-start
+   -mv m2/*$(objext) stageprofile/m2
+
+m2.stagefeedback: stagefeedback-start
+   -mv m2/*$(objext) stagefeedback/m2
+
 quit: force
echo "calling exit"
exit 1


[committed, pushed] PR-107607 m2: Remove bdepend on realpath, cut and echo

2022-12-15 Thread Gaius Mulley via Gcc-patches



It can be replaced by a subshell'd cd just fine.
(cd gcc/m2; autoconf-2.69)

gcc/m2/ChangeLog:

* configure.ac: Stop probing for realpath.
* tools-src/calcpath: Break dependency on realpath, cut
and echo.
* configure: Rebuilt
---
 gcc/m2/configure.ac   |  5 -
 gcc/m2/tools-src/calcpath | 34 ++
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/gcc/m2/configure.ac b/gcc/m2/configure.ac
index 756e01c4321..5583af7f64c 100644
--- a/gcc/m2/configure.ac
+++ b/gcc/m2/configure.ac
@@ -24,11 +24,6 @@ AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
-AC_CHECK_PROGS(regex_realpath, realpath)
-if test x$regex_realpath = "x" ; then
-AC_MSG_ERROR([realpath is required to build GNU Modula-2 (hint install 
coreutils).])
-fi
-
 AC_CHECK_FUNCS([stpcpy])
 
 AC_CHECK_HEADERS(sys/types.h)
diff --git a/gcc/m2/tools-src/calcpath b/gcc/m2/tools-src/calcpath
index e0817704f64..05324513aa1 100755
--- a/gcc/m2/tools-src/calcpath
+++ b/gcc/m2/tools-src/calcpath
@@ -23,27 +23,29 @@
 
 
 Usage () {
-   echo "Usage: calcpath pathcomponent1 pathcomponent2 subdir"
-   echo -n "  if pathcomponent1 is relative then 
pathcomponent1/pathcomponet2/subdir is"
-   echo " returned"
-   echo "  otherwise pathcomponet2/subdir is returned"
-   echo "  the path is checked for legality in subdir."
+   cat<&2
+   exit 1
+}
 
 if [ $# -eq 3 ]; then
-   if [ "$(echo $2 | cut -b 1)" = "." ] ; then
-   # relative path
-   the_path=$1/$2/$3
+   case "$2" in
+  /*) the_path="$2/$3" ;;
+  *) the_path="$1/$2/$3" ;;
+   esac
+   cd "$3" || die "could not access $3"
+   if ( cd "$the_path" ); then
+  printf '%s\n' "${the_path}"
else
-   the_path=$2/$3
-   fi
-   cd $3
-   if realpath ${the_path} > /dev/null ; then
-   echo ${the_path}
-   else
-   echo "calcpath: error ${the_path} is not a valid path in subdirectory 
$3" 1>&2
-   exit 1
+  die "${the_path} is not a valid path in subdirectory $3"
fi
 else
Usage
-- 
2.39.0



Re: [PATCH v5 1/19] modula2 front end: Fixes, improvements detecting python3 and documentation generation (shorter).

2022-12-15 Thread Gaius Mulley via Gcc-patches
Jakub Jelinek  writes:

> On Wed, Dec 14, 2022 at 08:35:07AM +0000, Gaius Mulley via Gcc-patches wrote:
>> thanks - this is the last patch tick.  So I'll actually do the merge now :-)
>
> I've committed following patch to fix up formatting of ChangeLog entries.

Many thanks and apologies for messing up the house style.


Re: [PATCH v5 1/19] modula2 front end: Fixes, improvements detecting python3 and documentation generation (shorter).

2022-12-14 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

> On Wed, Dec 14, 2022 at 8:48 AM Gaius Mulley  wrote:
>>
>>
>>
>> This patch set adds a re-exp ACX_CHECK_PROG_VER to detect python3.
>> HAVE_PYTHON is then checked in gcc/m2/Make-lang.in to generate library
>> chapters if python3 is available.  If python3 is unavailable then the
>> chapters are copied from a target-independent version.
>>
>> Bugfixed --enable-generated-files-in-srcdir.
>>
>> Python3 modules section added to install.texi.
>>
>> Also included are the target-independent versions of the
>> documentation.  The only difference is in the SYSTEM module which if
>> generated when HAVE_PYTHON is "yes" will enumerate all fundamental
>> data types supported by the target and compiler.
>>
>> I've hand snipped to try and reduce the size/noise as some of
>> these files have already been reviewed.
>>
>> I'll post the unedited version as well for completness,
>
> LGTM.

thanks - this is the last patch tick.  So I'll actually do the merge now :-)

> I'll note that in other GCC manuals we have target dependent
> things documented for each supported target.  It looks like
> the M2 docs will have only documentation built for the target
> the compiler is built for?  So for example the online documentation
> hosted on gcc.gnu.org will then contain only documentation for
> the x86_64-linux target specific SYSTEM module?

true

> building documentation for openSUSE (caveat: we only build
> .info docs and manpages) the documentation is only built once
> (aka for rpm 'noarch') with the idea it will be the same on all targets.
>
> So it seems to me that enumerating the SYSTEM module documentation
> for all targets or somehow differently organizing it would be better?

yes it would.  There is a desire to move the non standard data types out
of SYSTEM (by the user community) for the future.  But having a comment
saying data type availability dependant upon target architecture would
suffice for now, I'll add a comment,

regards,
Gaius


Re: [PATCH v4 1/19] modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite.

2022-12-12 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

> On Sat, Dec 10, 2022 at 1:49 AM Gaius Mulley via Gcc-patches
>  wrote:
>>
>>
>> While writing the ChangeLog entries git gcc-verify spotted an oversight
>> with v3 of this patch set.  I had forgotten to post gm2.texi and also a
>> tiny patchlet in gcc/configure.ac (to detect Python).  HAVE_PYTHON is
>> used within gcc/m2/Make-lang.in to avoid generating the library section
>> included by gm2.texi should Python not be available.
>
> The configure check doesn't verify the python version.

indeed - I'll fix this

>  Does --enable-generated-files-in-srcdir (used when building release
> tarballs) generate the required section so it's packed up in the
> release tarball and avoid requiring python3 when building from the
> release tarball?

currently working on it - no it fails - should be done rsn.

> Note these kind of dependences should be mentioned in
> install.texi - for python also listing required modules would be nice.

I'll add these.

> Thanks,
> Richard.
>
>> ok to commit?  I've included gm2-lang.cc and lang.opt for reference.
>
> The python script would have been more informative, the generated
> .texi fragment and the Make-lang.in part as well

ah yes this is true, sorry.

regards,
Gaius


Re: [PATCH v5 1/19] modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite. Addendum.

2022-12-11 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

> On Sat, Dec 10, 2022 at 12:29 PM Gaius Mulley via Gcc-patches
>  wrote:
>>
>>
>> This patch contains a replacement doc/gm2.texi which uses American
>> spelling, all references to gm2 outside the gcc tree purged and the
>> News/Obtaining sections have been removed.
>>
>> Also included at the end is the lang.opt file for reference.
>
> LGTM.

thanks!


[PATCH v5 1/19] modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite. Addendum.

2022-12-10 Thread Gaius Mulley via Gcc-patches


This patch contains a replacement doc/gm2.texi which uses American
spelling, all references to gm2 outside the gcc tree purged and the
News/Obtaining sections have been removed.

Also included at the end is the lang.opt file for reference.


diff -ruw /dev/null gcc-git-devel-modula2/gcc/doc/gm2.texi
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/doc/gm2.texi  2022-12-10 10:58:06.177440039 
+
@@ -0,0 +1,2843 @@
+\input texinfo
+@c -*-texinfo-*-
+@c Copyright (C) 2001-2022 Free Software Foundation, Inc.
+@c This is part of the GM2 manual.
+
+@c User level documentation for GNU Modula-2
+@c
+@c header
+
+@setfilename gm2.info
+@settitle The GNU Modula-2 Compiler
+
+@set version-python  3.5
+
+@include gcc-common.texi
+
+@c Copyright years for this manual.
+@set copyrights-gm2 1999-2022
+
+@copying
+@c man begin COPYRIGHT
+Copyright @copyright{} @value{copyrights-gm2} Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the
+@c man end
+section entitled ``GNU Free Documentation License''.
+@ignore
+@c man begin COPYRIGHT
+man page gfdl(7).
+@c man end
+@end ignore
+@end copying
+
+@ifinfo
+@format
+@dircategory Software development
+@direntry
+* gm2: (gm2).   A GCC-based compiler for the Modula-2 language
+@end direntry
+@end format
+
+@insertcopying
+@end ifinfo
+
+@titlepage
+@title The GNU Modula-2 Compiler
+@versionsubtitle
+@author Gaius Mulley
+
+@page
+@vskip 0pt plus 1filll
+Published by the Free Software Foundation @*
+51 Franklin Street, Fifth Floor@*
+Boston, MA 02110-1301, USA@*
+@sp 1
+@insertcopying
+@end titlepage
+@contents
+@page
+
+@c `Top' Node and Master Menu
+
+@node Top, Overview, (dir), (dir)
+@top Introduction
+
+@menu
+* Overview:: What is GNU Modula-2.
+* Using::Using GNU Modula-2.
+* Licence::  Licence of GNU Modula-2
+* Copying::  GNU Public Licence V3.
+* Contributing:: Contributing to GNU Modula-2
+* Internals::GNU Modula-2 internals.
+* EBNF:: EBNF of GNU Modula-2
+* Libraries::PIM and ISO library definitions.
+* Indices::  Document and function indices.
+@end menu
+
+@node Overview, Using, Top, Top
+@chapter Overview of GNU Modula-2
+
+@menu
+* What is GNU Modula-2::  Brief description of GNU Modula-2.
+* Why use GNU Modula-2::  Advantages of GNU Modula-2.
+* Development::   How to get source code using git.
+* Features::  GNU Modula-2 Features
+@end menu
+
+@node What is GNU Modula-2, Why use GNU Modula-2, , Using
+@section What is GNU Modula-2
+
+GNU Modula-2 is a @uref{http://gcc.gnu.org/frontends.html, front end}
+for the GNU Compiler Collection (@uref{http://gcc.gnu.org/, GCC}).
+The GNU Modula-2 compiler is compliant with the PIM2, PIM3, PIM4 and
+ISO dialects.  Also implemented are a complete set of free ISO
+libraries and PIM libraries.
+
+@footnote{The four Modula-2 dialects supported are defined in the following
+references:
+
+PIM2: 'Programming in Modula-2', 2nd Edition, Springer Verlag, 1982,
+1983 by Niklaus Wirth (PIM2).
+
+PIM3: 'Programming in Modula-2', 3rd Corrected Edition, Springer Verlag,
+1985 (PIM3).
+
+PIM4: 'Programming in Modula-2', 4th Edition, Springer Verlag, 1988
+(@uref{http://freepages.modula2.org/report4/modula-2.html, PIM4}).
+
+ISO: the ISO Modula-2 language as defined in 'ISO/IEC Information
+technology - programming languages - part 1: Modula-2 Language,
+ISO/IEC 10514-1 (1996)'
+}
+
+@node Why use GNU Modula-2, Release map, What is GNU Modula-2, Using
+@section Why use GNU Modula-2
+
+There are a number of advantages of using GNU Modula-2 rather than
+translate an existing project into another language.
+
+The first advantage is of maintainability of the original sources
+and the ability to debug the original project source code using a
+combination of gm2 and gdb.
+
+The second advantage is that gcc runs on many processors and
+platforms.  gm2 builds and runs on powerpc64le, amd64, i386, aarch64
+to name but a few processors.
+
+gm2 can produce swig interface headers to allow access from Python and
+other scripting languages.  It can also be used with C/C++ and
+generate shared libraries.
+
+The compiler provides semantic analysis and runtime checking (full ISO
+Modula-2 checking is implemented) and there is a plugin which can,
+under certain conditions, detect runtime errors at compile time.
+
+The compiler supports PIM2, PIM3, PIM4 and ISO dialects of Modula-2,
+work is underway to implement M2R10.  Many of the GCC builtins are
+available and access to assembly programming is achieved using the
+same syntax as that used by GCC.
+
+The gm2 driver allows third party libraries to be installed

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

2022-12-09 Thread Gaius Mulley via Gcc-patches


While writing the ChangeLog entries git gcc-verify spotted an oversight
with v3 of this patch set.  I had forgotten to post gm2.texi and also a
tiny patchlet in gcc/configure.ac (to detect Python).  HAVE_PYTHON is
used within gcc/m2/Make-lang.in to avoid generating the library section
included by gm2.texi should Python not be available.

ok to commit?  I've included gm2-lang.cc and lang.opt for reference.

regards,
Gaius




diff -ruw gcc-git-master/gcc/configure.ac gcc-git-devel-modula2/gcc/configure.ac
--- gcc-git-master/gcc/configure.ac 2022-12-07 20:16:24.571677189 +
+++ gcc-git-devel-modula2/gcc/configure.ac  2022-12-07 19:46:20.036302786 
+
@@ -1263,6 +1263,10 @@
 # Bison?
 AC_CHECK_PROGS([BISON], bison, [$MISSING bison])

+# Python3?
+AM_PATH_PYTHON(,, [:])
+AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
+
 # Binutils are not build modules, unlike bison/flex/makeinfo.  So we
 # check for build == host before using them.

@@ -7651,4 +7655,3 @@
 ],
 [subdirs='$subdirs'])
 AC_OUTPUT
-
diff -ruw /dev/null gcc-git-devel-modula2/gcc/doc/gm2.texi
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/doc/gm2.texi  2022-12-10 00:04:30.263603238 
+
@@ -0,0 +1,2944 @@
+\input texinfo
+@c -*-texinfo-*-
+@c Copyright (C) 2001-2022 Free Software Foundation, Inc.
+@c This is part of the GM2 manual.
+
+@c User level documentation for GNU Modula-2
+@c
+@c header
+
+@setfilename gm2.info
+@settitle The GNU Modula-2 Compiler
+
+@set version-python  3.5
+
+@include gcc-common.texi
+
+@c Copyright years for this manual.
+@set copyrights-gm2 1999-2022
+
+@copying
+@c man begin COPYRIGHT
+Copyright @copyright{} @value{copyrights-gm2} Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the
+@c man end
+section entitled ``GNU Free Documentation License''.
+@ignore
+@c man begin COPYRIGHT
+man page gfdl(7).
+@c man end
+@end ignore
+@end copying
+
+@ifinfo
+@format
+@dircategory Software development
+@direntry
+* gm2: (gm2).   A GCC-based compiler for the Modula-2 language
+@end direntry
+@end format
+
+@insertcopying
+@end ifinfo
+
+@titlepage
+@title The GNU Modula-2 Compiler
+@versionsubtitle
+@author Gaius Mulley
+
+@page
+@vskip 0pt plus 1filll
+Published by the Free Software Foundation @*
+51 Franklin Street, Fifth Floor@*
+Boston, MA 02110-1301, USA@*
+@sp 1
+@insertcopying
+@end titlepage
+@contents
+@page
+
+@c `Top' Node and Master Menu
+
+@node Top, Overview, (dir), (dir)
+@top Introduction
+
+@menu
+* Overview:: What is GNU Modula-2.
+* Using::Using GNU Modula-2.
+* Licence::  Licence of GNU Modula-2
+* Copying::  GNU Public Licence V3.
+* Contributing:: Contributing to GNU Modula-2
+* Internals::GNU Modula-2 internals.
+* EBNF:: EBNF of GNU Modula-2
+* Libraries::PIM and ISO library definitions.
+* Indices::  Document and function indices.
+@end menu
+
+@node Overview, Using, Top, Top
+@chapter Overview of GNU Modula-2
+
+@menu
+* What is GNU Modula-2::  Brief description of GNU Modula-2.
+* Why use GNU Modula-2::  Advantages of GNU Modula-2.
+* News::  Latest news about GNU Modula-2.
+* Development::   How to get source code using git.
+* Obtaining:: Where to get the source code using git.
+* Features::  GNU Modula-2 Features
+@end menu
+
+@node What is GNU Modula-2, Why use GNU Modula-2, , Using
+@section What is GNU Modula-2
+
+GNU Modula-2 is a @uref{http://gcc.gnu.org/frontends.html, front end}
+for the GNU Compiler Collection (@uref{http://gcc.gnu.org/, GCC}).
+The GNU Modula-2 compiler is compliant with the PIM2, PIM3, PIM4 and
+ISO dialects.  Also implemented are a complete set of free ISO
+libraries and PIM libraries.
+
+@footnote{The four Modula-2 dialects supported are defined in the following
+references:
+
+PIM2: 'Programming in Modula-2', 2nd Edition, Springer Verlag, 1982,
+1983 by Niklaus Wirth (PIM2).
+
+PIM3: 'Programming in Modula-2', 3rd Corrected Edition, Springer Verlag,
+1985 (PIM3).
+
+PIM4: 'Programming in Modula-2', 4th Edition, Springer Verlag, 1988
+(@uref{http://freepages.modula2.org/report4/modula-2.html, PIM4}).
+
+ISO: the ISO Modula-2 language as defined in 'ISO/IEC Information
+technology - programming languages - part 1: Modula-2 Language,
+ISO/IEC 10514-1 (1996)'
+}
+
+@node Why use GNU Modula-2, Release map, What is GNU Modula-2, Using
+@section Why use GNU Modula-2
+
+There are a number of advantages of using GNU Modula-2 rather than
+translate an existing project into another language.
+
+The first advantage is of maintainability of the original sources
+and the abilit

Re: [PATCH v3 16/19] modula2 front end: bootstrap and documentation tools

2022-12-07 Thread Gaius Mulley via Gcc-patches
Martin Liška  writes:

> On 12/6/22 15:47, Gaius Mulley wrote:
>> |Hi Martin, here is the revised patch having applied all previous
>> recommendations:
>> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603436.html. Is
>> this ok now? Thanks for the improvement suggestions.|
>
> Hello.
>
> It looks much better and I'm sending a small patch that resolves the remaining
> flake8 issue. I use the following plugins (some listed here: 
> https://gcc.gnu.org/codingconventions.html#python):
>
> $ flake8 --version
> 5.0.4 (flake8-bugbear: 22.10.27, flake8-builtins: 1.5.3,
> flake8-comprehensions: 3.4.0, flake8-import-order: 0.18.1,
> flake8-quotes: 3.3.1, mccabe: 0.7.0, pycodestyle: 2.9.1, pyflakes:
> 2.5.0) CPython 3.10.8 on Linux
>
> and I see:
>
> gcc/m2/tools-src> flake8
> ./boilerplate.py:108:66: E999 SyntaxError: invalid syntax
> ./tidydates.py:26:1: I100 Import statements are in the wrong order. 'import 
> pathlib' should be before 'import sys'
> ./tidydates.py:129:50: E128 continuation line under-indented for visual indent
> ./def2doc.py:49:5: E301 expected 1 blank line, found 0
> ./def2doc.py:49:18: E211 whitespace before '('
> ./def2doc.py:51:5: E301 expected 1 blank line, found 0
> ./def2doc.py:51:18: E211 whitespace before '('
> ./def2doc.py:53:5: E301 expected 1 blank line, found 0
> ./def2doc.py:55:5: E301 expected 1 blank line, found 0
> ./def2doc.py:57:5: E301 expected 1 blank line, found 0
> ./def2doc.py:59:5: E301 expected 1 blank line, found 0
> ./def2doc.py:61:5: E301 expected 1 blank line, found 0
> ./def2doc.py:65:5: E301 expected 1 blank line, found 0
> ./def2doc.py:70:5: E301 expected 1 blank line, found 0
> ./def2doc.py:72:5: E301 expected 1 blank line, found 0
> ./def2doc.py:191:80: E501 line too long (81 > 79 characters)
> ./def2doc.py:330:22: A002 argument "dir" is shadowing a python builtin
> ./def2doc.py:348:23: A002 argument "dir" is shadowing a python builtin
> ./def2doc.py:377:17: A002 argument "dir" is shadowing a python builtin
> ./def2doc.py:396:21: A002 argument "dir" is shadowing a python builtin
> ./def2doc.py:406:16: A002 argument "dir" is shadowing a python builtin
> ./def2doc.py:418:15: A002 argument "dir" is shadowing a python builtin
> ./def2doc.py:432:25: A002 argument "dir" is shadowing a python builtin
> ./def2doc.py:437:19: Q000 Double quotes found but single quotes preferred
> ./def2doc.py:439:19: Q000 Double quotes found but single quotes preferred
> ./def2doc.py:441:19: Q000 Double quotes found but single quotes preferred
> ./def2doc.py:468:18: Q001 Single quote multiline found but double quotes 
> preferred
>
> It seems the first one is a real syntax error. Anyway, feel free to apply the 
> suggested patch.
>
> And I would consider replacing the following static 'str.' calls:
>
> def2doc.py:output.write(str.replace(str.replace(str.rstrip(line),
> def2doc.py:output.write(str.replace(str.replace(line, '{', '@{'), 
> '}', '@}'))
>
> with line.rstrip().replace(...).replace(...)
>
> Cheers,
> Martin

Hi Martin,

many thanks for the patch and suggestions (and flake8 plugin output) - I
will apply the patch and change the str calls,

regards,
Gaius


[PATCH v4 15/19] modula2 front end: cc1gm2 additional non modula2 source files

2022-12-06 Thread Gaius Mulley via Gcc-patches


Version 4 contains two missed feedback suggestions (namespace in
m2pp.cc) and use build_nonstandard_integer_type in
gm2-lang.cc:gm2_type_for_size.

This patch set contains the .h, .cc and .flex files found in
gcc/m2.  The files are tightly coupled with the gimple interface
(see 04-gimple-interface) and built using the rules found in
(01-03-make).


--8<--8<--8<--8<--8<--8<
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/gm2-lang.cc
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/gm2-lang.cc2022-12-06 18:18:32.612239623 
+
@@ -0,0 +1,889 @@
+/* gm2-lang.cc language-dependent hooks for GNU Modula-2.
+
+Copyright (C) 2002-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING.  If not, write to the
+Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
+
+#include "gm2-gcc/gcc-consolidation.h"
+
+#include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name.  */
+#include "tree-pass.h" /* FIXME: only for PROP_gimple_any.  */
+#include "toplev.h"
+#include "debug.h"
+
+#include "opts.h"
+
+#define GM2_LANG_C
+#include "gm2-lang.h"
+#include "m2block.h"
+#include "dynamicstrings.h"
+#include "m2options.h"
+#include "m2convert.h"
+#include "m2linemap.h"
+#include "init.h"
+#include "m2-tree.h"
+#include "convert.h"
+#include "rtegraph.h"
+
+static void write_globals (void);
+
+static int insideCppArgs = FALSE;
+
+#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
+
+/* start of new stuff.  */
+
+/* Language-dependent contents of a type.  */
+
+struct GTY (()) lang_type
+{
+  char dummy;
+};
+
+/* Language-dependent contents of a decl.  */
+
+struct GTY (()) lang_decl
+{
+  char dummy;
+};
+
+/* Language-dependent contents of an identifier.  This must include a
+   tree_identifier.  */
+
+struct GTY (()) lang_identifier
+{
+  struct tree_identifier common;
+};
+
+/* The resulting tree type.  */
+
+union GTY ((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
+chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), "
+"TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN "
+"(&%h.generic)) : NULL"))) lang_tree_node
+{
+  union tree_node GTY ((tag ("0"),
+desc ("tree_node_structure (&%h)"))) generic;
+  struct lang_identifier GTY ((tag ("1"))) identifier;
+};
+
+struct GTY (()) language_function
+{
+
+  /* While we are parsing the function, this contains information about
+  the statement-tree that we are building.  */
+  /* struct stmt_tree_s stmt_tree;  */
+  tree stmt_tree;
+};
+
+/* Language hooks.  */
+
+bool
+gm2_langhook_init (void)
+{
+  build_common_tree_nodes (false);
+  build_common_builtin_nodes ();
+
+  /* The default precision for floating point numbers.  This is used
+ for floating point constants with abstract type.  This may eventually
+ be controllable by a command line option.  */
+  mpfr_set_default_prec (256);
+
+  /* GNU Modula-2 uses exceptions.  */
+  using_eh_for_cleanups ();
+  return true;
+}
+
+/* The option mask.  */
+
+static unsigned int
+gm2_langhook_option_lang_mask (void)
+{
+  return CL_ModulaX2;
+}
+
+/* Initialize the options structure.  */
+
+static void
+gm2_langhook_init_options_struct (struct gcc_options *opts)
+{
+  /* Default to avoiding range issues for complex multiply and divide.  */
+  opts->x_flag_complex_method = 2;
+
+  /* The builtin math functions should not set errno.  */
+  opts->x_flag_errno_math = 0;
+  opts->frontend_set_flag_errno_math = true;
+
+  /* Exceptions are used.  */
+  opts->x_flag_exceptions = 1;
+  init_FrontEndInit ();
+}
+
+/* Infrastructure for a VEC of bool values.  */
+
+/* This array determines whether the filename is associated with the
+   C preprocessor.  */
+
+static vec filename_cpp;
+
+void
+gm2_langhook_init_options (unsigned int decoded_options_count,
+   struct cl_decoded_option *decoded_options)
+{
+  unsigned int i;
+  bool in_cpp_args = false;
+
+  f

[PATCH v3 14/19] modula2 front end: gimple interface remainder

2022-12-06 Thread Gaius Mulley via Gcc-patches
 

This patchset contains the gimple interface.

 
--8<--8<--8<--8<--8<--8< 
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/gm2-gcc/init.cc
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/gm2-gcc/init.cc2022-12-06 
02:56:51.344774733 +
@@ -0,0 +1,196 @@
+/* init.cc initializes the modules of the GNU Modula-2 front end.
+
+Copyright (C) 2012-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "init.h"
+#include "config.h"
+#include "system.h"
+
+#if defined(__GNUG__)
+#define EXTERN extern "C"
+#else /* !__GNUG__  */
+#define EXTERN extern
+#endif /* !__GNUG__  */
+
+EXTERN void _M2_M2Bitset_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_Debug_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Defaults_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_Environment_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_RTExceptions_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2EXCEPTION_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2RTS_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Dependent_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_SysExceptions_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_DynamicStrings_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_Assertion_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_FormatStrings_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_FIO_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_SFIO_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_SArgs_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_Lists_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_UnixArgs_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_Args_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_wrapc_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_TimeString_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_IO_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_StdIO_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_CmdArgs_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Preprocess_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Error_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Search_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_Indexing_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_NameKey_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_NumberIO_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_FpuIO_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_SysStorage_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_Storage_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_StrIO_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Debug_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Batch_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_StrLib_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2ALU_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Options_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Comp_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2LexBuf_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_SymbolTable_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Base_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Quads_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_SymbolKey_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_FifoQueue_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Reserved_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_M2Const_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_P1SymBuild_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_P2SymBuild_init (int argc, char *argv[], char *envp[]);
+EXTERN void _M2_P3SymBuild_init (int argc, char *argv[], char *envp[]);
+EXTERN void _

[PATCH v3 11/19] modula2 front end: gimple interface *[a-d]*.cc

2022-12-06 Thread Gaius Mulley via Gcc-patches
 

This patchset contains the gimple interface.

 
--8<--8<--8<--8<--8<--8< 
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/gm2-gcc/m2assert.cc
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/gm2-gcc/m2assert.cc2022-12-06 
02:56:51.344774733 +
@@ -0,0 +1,41 @@
+/* m2assert.cc provides a simple assertion for location.
+
+Copyright (C) 2012-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "gcc-consolidation.h"
+
+#include "../gm2-lang.h"
+#include "../m2-tree.h"
+
+#define m2assert_c
+#include "m2assert.h"
+#include "m2options.h"
+
+void
+m2assert_AssertLocation (location_t location)
+{
+  /* Internally the compiler will use unknown location and
+ builtins_location so we ignore these values.  */
+  if (location == BUILTINS_LOCATION || location == UNKNOWN_LOCATION)
+return;
+
+  if (M2Options_OverrideLocation (location) != location)
+internal_error ("the location value is corrupt");
+}
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/gm2-gcc/m2block.cc
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/gm2-gcc/m2block.cc 2022-12-06 
02:56:51.344774733 +
@@ -0,0 +1,770 @@
+/* m2block.cc provides an interface to maintaining block structures.
+
+Copyright (C) 2012-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "gcc-consolidation.h"
+
+#define m2block_c
+#include "m2assert.h"
+#include "m2block.h"
+#include "m2decl.h"
+#include "m2options.h"
+#include "m2tree.h"
+#include "m2treelib.h"
+
+/* For each binding contour we allocate a binding_level structure
+   which records the entities defined or declared in that contour.
+   Contours include:
+
+   the global one one for each subprogram definition
+
+   Binding contours are used to create GCC tree BLOCK nodes.  */
+
+struct GTY (()) binding_level
+{
+  /* The function associated with the scope.  This is NULL_TREE for the
+ global scope.  */
+  tree fndecl;
+
+  /* A chain of _DECL nodes for all variables, constants, functions,
+ and typedef types.  These are in the reverse of the order supplied.  */
+  tree names;
+
+  /* A boolean to indicate whether this is binding level is a global ie
+ outer module scope.  In which case fndecl will be NULL_TREE.  */
+  int is_global;
+
+  /* The context of the binding level, for a function binding level
+ this will be the same as fndecl, however for a global binding level
+ this is a translation_unit.  */
+  tree context;
+
+  /* The binding level below this one.  This field is only used when
+ the binding level has been pushed by pushFunctionScope.  */
+  struct binding_level *next;
+
+  /* All binding levels are placed onto this list.  */
+  struct binding_level *list;
+
+  /* A varray of trees, which represent the list of statement
+ sequences.  */
+  vec *m2_statements;
+
+  /* A list of constants (only kept in the global binding level).
+ Constants need to be kept through the life of the compilation, as the
+ same constants can be used in any scope.  */
+  tree constants;
+
+  /* A list of inner module initialization functions.  */
+  tree init_functions;
+
+  /* A list of types created by M2GCCDeclare prior to code generation
+ and those which may not be specifically declared and saved via a
+ push_decl.  */
+  tree types;
+
+  /* A list of all DECL_EXPR created within this binding le

[PATCH v3 0/19] modula-2 front end patches overview

2022-12-06 Thread Gaius Mulley via Gcc-patches


Here are the latest modula-2 front end patches.  Since the posting in
https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603161.html
I've rewritten the python3 documentation scripts (feedback from
patchset 16) and applied all the suggestions from the feedback in
patchset 15 (gm2-lang.cc).

All the patches are can also be at:
https://splendidisolation.ddns.net/public/modula2/patchsummary.html
which contains the status of the patch, their contents and testing
summary.

Thanks for the feedback - and clean up suggestions!

regards,
Gaius


Patch Summary
=

The gm2 driver program and top level makefile infrastructure

[PATCH v3] 1/19: changes outside gcc/m2, libgm2 and gcc/testsuite.
[PATCH v3] 2/19: Make-lang.in
[PATCH v3] 3/19: gm2 driver files.

The libraries /libgm2

[PATCH v3] 4/19: libgm2/libm2pim contents
[PATCH v3] 5/19: libgm2/libm2iso contents
[PATCH v3] 6/19: libgm2/libm2min contents
[PATCH v3] 7/19: libgm2/libm2log contents
[PATCH v3] 8/19: libgm2 contents

Modula-2 plugin

[PATCH v3] 9/19: plugin source files

Modula-2 to gimple interface

[PATCH v3] 10/19: gimple interface header files *.h and *.def
[PATCH v3] 11/19: gimple interface *[a-d]*.cc
[PATCH v3] 12/19: gimple interface *[e-f]*.cc
[PATCH v3] 13/19: gimple interface *[g-m]*.cc
[PATCH v3] 14/19: gimple interface remainder

Lexical analysis (flex), lang hooks and debug tree module

[PATCH v3] 15/19: cc1gm2 additional non modula2 source files

Linking bootstrap tool and documentation build script

[PATCH v3] 16/19: bootstrap and documentation tools

Testsuite and remaining files

[PATCH v3] 17/19: dejagnu expect library scripts.

[PATCH v3] 18/19: remainder of the files for the compiler and libraries.  (not 
posted)
[PATCH v3] 19/19: modula2 testsuite.  (not posted)


[PATCH v3 13/19] modula2 front end: gimple interface *[g-m]*.cc

2022-12-06 Thread Gaius Mulley via Gcc-patches
 

This patchset contains the gimple interface.

 
--8<--8<--8<--8<--8<--8< 
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/gm2-gcc/m2linemap.cc
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/gm2-gcc/m2linemap.cc   2022-12-06 
02:56:51.344774733 +
@@ -0,0 +1,254 @@
+/* m2linemap.cc provides an interface to GCC linemaps.
+
+Copyright (C) 2012-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "gcc-consolidation.h"
+
+/* Utilize some of the C build routines */
+
+#include "../gm2-lang.h"
+#include "../m2-tree.h"
+
+#include "m2assert.h"
+#include "m2block.h"
+#include "m2decl.h"
+#include "m2expr.h"
+#include "m2options.h"
+#include "m2tree.h"
+#include "m2type.h"
+#define m2linemap_c
+#include "m2linemap.h"
+
+static int inFile = FALSE;
+
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+#else
+#define EXTERN
+#endif
+
+/* Start getting locations from a new file.  */
+
+EXTERN
+void
+m2linemap_StartFile (void *filename, unsigned int linebegin)
+{
+  if (inFile)
+m2linemap_EndFile ();
+  linemap_add (line_table, LC_ENTER, false,
+   xstrdup (reinterpret_cast (filename)), linebegin);
+  inFile = TRUE;
+}
+
+/* Tell the line table the file has ended.  */
+
+EXTERN
+void
+m2linemap_EndFile (void)
+{
+  linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
+  inFile = FALSE;
+}
+
+/* Indicate that there is a new source file line number with a
+   maximum width.  */
+
+EXTERN
+void
+m2linemap_StartLine (unsigned int linenumber, unsigned int linesize)
+{
+  linemap_line_start (line_table, linenumber, linesize);
+}
+
+/* GetLocationColumn, returns a location_t based on the current line
+   number and column.  */
+
+EXTERN
+location_t
+m2linemap_GetLocationColumn (unsigned int column)
+{
+  return linemap_position_for_column (line_table, column);
+}
+
+/* GetLocationRange, returns a location based on the start column
+   and end column.  */
+
+EXTERN
+location_t
+m2linemap_GetLocationRange (unsigned int start, unsigned int end)
+{
+  location_t caret = m2linemap_GetLocationColumn (start);
+
+  source_range where;
+  where.m_start = linemap_position_for_column (line_table, start);
+  where.m_finish = linemap_position_for_column (line_table, end);
+  return make_location (caret, where);
+}
+
+
+static
+int
+isSrcLocation (location_t location)
+{
+  return (location != BUILTINS_LOCATION) && (location != UNKNOWN_LOCATION);
+}
+
+
+/* GetLocationBinary, returns a location based on the expression
+   start caret finish locations.  */
+
+EXTERN
+location_t
+m2linemap_GetLocationBinary (location_t caret, location_t start, location_t 
finish)
+{
+  if (isSrcLocation (start) && isSrcLocation (finish) && isSrcLocation (caret)
+&& (m2linemap_GetFilenameFromLocation (start) != NULL))
+{
+  linemap_add (line_table, LC_ENTER, false, xstrdup 
(m2linemap_GetFilenameFromLocation (start)), 1);
+  gcc_assert (inFile);
+  location_t location = make_location (caret, start, finish);
+  return location;
+}
+  return caret;
+}
+
+/* GetLineNoFromLocation - returns the lineno given a location.  */
+
+EXTERN
+int
+m2linemap_GetLineNoFromLocation (location_t location)
+{
+  if (isSrcLocation (location) && (!M2Options_GetCpp ()))
+{
+  expanded_location xl = expand_location (location);
+  return xl.line;
+}
+  return 0;
+}
+
+/* GetColumnNoFromLocation - returns the columnno given a location.  */
+
+EXTERN
+int
+m2linemap_GetColumnNoFromLocation (location_t location)
+{
+  if (isSrcLocation (location) && (!M2Options_GetCpp ()))
+{
+  expanded_location xl = expand_location (location);
+  return xl.column;
+}
+  return 0;
+}
+
+/* GetFilenameFromLocation - returns the filename given a location.  */
+
+EXTERN
+const char *
+m2linemap_GetFilenameFromLocation (location_t location)
+{
+  if (isSrcLocation (location) && (!M2Options_GetCpp ()))
+{
+  expanded_location xl = expand_location (location);
+  return xl.file;
+}
+  return NULL;
+}
+
+/* ErrorAt - issue an error message. 

[PATCH v3 16/19] modula2 front end: bootstrap and documentation tools

2022-12-06 Thread Gaius Mulley via Gcc-patches
 return
+else:
+outfile.write(lines[n])
+n += 1
+sys.stdout.write('%s:1:1 needs a Copyright notice..\n' % filename)
+
+
+def bash_tidy(filename):
+# bash_tidy - tidy up dates using '#' comment
+handle_header(filename, '#', ' ')
+
+
+def c_tidy(filename):
+# c_tidy - tidy up dates using '/* */' comments
+handle_header(filename, ' ', '*')
+
+
+def m2_tidy(filename):
+# m2_tidy - tidy up dates using '(* *)' comments
+handle_header(filename, ' ', ' ')
+
+
+def main():
+# main - for each file extension call the appropriate tidy routine.
+visit_dir('.', '.in', bash_tidy)
+visit_dir('.', '.py', bash_tidy)
+visit_dir('.', '.c', c_tidy)
+visit_dir('.', '.h', c_tidy)
+visit_dir('.', '.def', m2_tidy)
+visit_dir('.', '.mod', m2_tidy)
+
+
+main()
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/tools-src/boilerplate.py
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/tools-src/boilerplate.py   2022-12-06 
02:56:51.380775219 +
@@ -0,0 +1,548 @@
+#!/usr/bin/env python3
+#
+# boilerplate.py utility to rewrite the boilerplate with new dates.
+#
+# Copyright (C) 2018-2022 Free Software Foundation, Inc.
+# Contributed by Gaius Mulley .
+#
+# This file is part of GNU Modula-2.
+#
+# GNU Modula-2 is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Modula-2 is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Modula-2; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
+
+import argparse
+import datetime
+import os
+import sys
+
+
+error_count = 0
+seen_files = []
+output_name = None
+
+ISO_COPYRIGHT = 'Copyright ISO/IEC'
+COPYRIGHT = 'Copyright (C)'
+GNU_PUBLIC_LICENSE = 'GNU General Public License'
+GNU_LESSER_GENERAL = 'GNU Lesser General'
+GCC_RUNTIME_LIB_EXC = 'GCC Runtime Library Exception'
+VERSION_2_1 = 'version 2.1'
+VERSION_2 = 'version 2'
+VERSION_3 = 'version 3'
+Licenses = {VERSION_2_1: 'v2.1', VERSION_2: 'v2', VERSION_3: 'v3'}
+CONTRIBUTED_BY = 'ontributed by'
+
+
+def printf(fmt, *args):
+# printf - keeps C programmers happy :-)
+print(str(fmt) % args, end=' ')
+
+
+def error(fmt, *args):
+# error - issue an error message.
+global error_count
+
+print(str(fmt) % args, end=' ')
+error_count += 1
+
+
+def halt_on_error():
+if error_count > 0:
+os.sys.exit(1)
+
+
+def basename(f):
+b = f.split('/')
+return b[-1]
+
+
+def analyse_comment(text, f):
+# analyse_comment determine the license from the top comment.
+start_date, end_date = None, None
+contribution, summary, lic = None, None, None
+if text.find(ISO_COPYRIGHT) > 0:
+lic = 'BSISO'
+now = datetime.datetime.now()
+for d in range(1984, now.year+1):
+if text.find(str(d)) > 0:
+if start_date is None:
+start_date = str(d)
+end_date = str(d)
+return start_date, end_date, '', '', lic
+elif text.find(COPYRIGHT) > 0:
+if text.find(GNU_PUBLIC_LICENSE) > 0:
+lic = 'GPL'
+elif text.find(GNU_LESSER_GENERAL) > 0:
+lic = 'LGPL'
+for license in Licenses.keys():
+if text.find(license) > 0:
+lic += Licenses[license]
+if text.find(GCC_RUNTIME_LIB_EXC) > 0:
+lic += 'x'
+now = datetime.datetime.now()
+for d in range(1984, now.year+1):
+if text.find(str(d)) > 0:
+if start_date is None:
+start_date = str(d)
+end_date = str(d)
+if text.find(CONTRIBUTED_BY) > 0:
+i = text.find(CONTRIBUTED_BY)
+i += len(CONTRIBUTED_BY)
+j = text.index('. ', i)
+contribution = text[i:j]
+if text.find(basename(f)) > 0:
+i = text.find(basename(f))
+j = text.find('. ', i)
+if j < 0:
+error('summary of the file does not finish with a '.'')
+summary = text[i:]
+else:
+summary = text[i:j]
+return start_date, end_date, contribution, summary, lic
+
+
+def analyse_header_without_terminator(f, start):
+text = ''
+for count, l in enumerate(open(f).readlines()):
+parts = l.split(start)
+if len(parts) > 1:
+line = start.join(parts[1:])
+line = line.strip()
+text += ' '
+text += line
+elif (l.rstrip() != '') and (len(parts[0]) > 0):

[PATCH v3 2/19] modula2 front end: Make-lang.in

2022-12-06 Thread Gaius Mulley via Gcc-patches
 

The makefile fragment for modula2 which builds the gm2 driver and cc1gm2.

 
--8<--8<--8<--8<--8<--8< 
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/Make-lang.in
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/Make-lang.in   2022-12-06 02:56:51.328774517 
+
@@ -0,0 +1,1649 @@
+# Top level -*- makefile -*- fragment for GNU M2.
+
+# Copyright (C) 2000-2022 Free Software Foundation, Inc.
+
+#This file is part of GCC.
+
+#GCC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 3, or (at your option)
+#any later version.
+
+#GCC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GCC; see the file COPYING3.  If not see
+#.
+
+# Actual names to use when installing a native compiler.
+GM2_INSTALL_NAME = $(shell echo gm2|sed '$(program_transform_name)')
+GM2_TARGET_INSTALL_NAME = $(target_noncanonical)-$(shell echo gm2|sed 
'$(program_transform_name)')
+
+# Actual names to use when installing a cross-compiler.
+GM2_CROSS_NAME = `echo gm2|sed '$(program_transform_cross_name)'`
+
+M2_MAINTAINER = no
+
+GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g
+
+GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ 
-L$(objdir)/../ld $(TFLAGS)
+
+TEXISRC = $(objdir)/m2/images/gnu.eps \
+  $(srcdir)/doc/gm2.texi \
+  m2/gm2-libs.texi \
+  m2/gm2-ebnf.texi \
+  m2/SYSTEM-pim.texi \
+  m2/SYSTEM-iso.texi \
+  m2/Builtins.texi
+
+RSTSRC = $(objdir)/m2/images/gnu.eps \
+  $(srcdir)/doc/gm2.texi \
+  m2/gm2-libs.rst \
+  m2/gm2-ebnf.rst \
+  m2/SYSTEM-pim.rst \
+  m2/SYSTEM-iso.rst \
+  m2/Builtins.rst
+
+# Define the names for selecting modula-2 in LANGUAGES.
+m2 modula-2 modula2: gm2$(exeext) xgcc$(exeext) cc1gm2$(exeext) \
+ $(GCC_PASSES) $(GCC_PARTS)
+m2.serial = cc1gm2$(exeext)
+
+# Tell GNU make to ignore these if they exist.
+.PHONY: m2 modula-2 modula2
+
+GM2_PROG_DEP=gm2$(exeext) xgcc$(exeext) cc1gm2$(exeext)
+
+include m2/config-make
+
+LIBSTDCXX=../$(TARGET_SUBDIR)/libstdc++-v3/src/.libs/libstdc++.a
+
+PGE=m2/pge$(exeext)
+
+SRC_PREFIX=G
+
+m2/gm2spec.o: $(srcdir)/m2/gm2spec.cc $(SYSTEM_H) $(GCC_H) $(CONFIG_H) \
+   m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \
+   $(generated_files) $(C_TREE_H) insn-attr-common.h
+   (SHLIB_LINK='$(SHLIB_LINK)' \
+   SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
+   $(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+ $(DRIVER_DEFINES) \
+   -DLIBSUBDIR=\"$(libsubdir)\" \
+-DPREFIX=\"$(prefix)\" \
+-c $(srcdir)/m2/gm2spec.cc $(OUTPUT_OPTION))
+
+# Create the compiler driver for M2.
+CFLAGS-m2/m2/gm2spec.o += $(DRIVER_DEFINES)
+
+GM2_OBJS = $(GCC_OBJS) prefix.o intl.o m2/gm2spec.o
+
+# Create the compiler driver for gm2.
+gm2$(exeext): $(GM2_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS) \
+m2/gm2config.h
+   +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+ $(GM2_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
+ $(EXTRA_GCC_LIBS) $(LIBS)
+
+# Create a version of the gm2 driver which calls the cross-compiler.
+gm2-cross$(exeext): gm2$(exeext)
+   -rm -f gm2-cross$(exeext)
+   cp gm2$(exeext) gm2-cross$(exeext)
+
+po-generated:
+
+# Build hooks:
+
+m2.all.cross: gm2-cross$(exeext) plugin/m2rte$(exeext).so
+
+m2.start.encap: gm2$(exeext) plugin/m2rte$(exeext).so
+m2.rest.encap:
+
+
+m2.info: doc/m2.info
+
+m2.man: doc/m2.1
+
+m2.install-man: $(DESTDIR)$(man1dir)/$(GM2_INSTALL_NAME)$(man1ext)
+
+$(DESTDIR)$(man1dir)/$(GM2_INSTALL_NAME)$(man1ext): doc/m2.1 installdirs
+   -rm -f $@
+   -$(INSTALL_DATA) $< $@
+   -chmod a-x $@
+
+m2.dvi: $(TEXISRC)
+   $(TEXI2DVI) -I $(objdir)/m2 -I $(srcdir)/doc/include 
$(srcdir)/doc/gm2.texi -o $@
+
+m2.ps: m2.dvi
+   dvips -o $@ $<
+
+m2.pdf: m2.ps
+   gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ $<
+
+.INTERMEDIATE: gm2.pod
+
+m2.pod: doc/gm2.texi $(TEXISRC)
+   -$(TEXI2POD) -I $(objdir)/m2 -D m2 < $< > $@
+
+doc/m2.info: $(TEXISRC)
+   if test "x$(BUILD_INFO)" = xinfo; then \
+ rm -f doc/m2.info*; \
+  $(MAKEINFO) -I$(objdir)/m2 -I$(srcdir)/doc/include \
+  -o $@ $(srcdir)/doc/gm2.texi ; \
+   else true; fi
+
+$(objdir)/m2/images/gnu.eps: $(srcdir)/m2/images/gnupng
+   test -d m2/images || mkdir -p m2/images
+   if [ -f $(srcdir)/m2/images/gnu.eps ] ; then \
+   cp $(srcdir)/m2/images/gnu.eps $@ ; \
+else 

[PATCH v3 15/19] modula2 front end: cc1gm2 additional non modula2 source files

2022-12-06 Thread Gaius Mulley via Gcc-patches
 

This patch set contains the .h, .cc and .flex files found in
gcc/m2.  The files are tightly coupled with the gimple interface
(see 04-gimple-interface) and built using the rules found in
(01-03-make).

 
--8<--8<--8<--8<--8<--8< 
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/gm2-lang.cc
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/m2/gm2-lang.cc2022-12-06 02:57:10.909039217 
+
@@ -0,0 +1,887 @@
+/* gm2-lang.cc language-dependent hooks for GNU Modula-2.
+
+Copyright (C) 2002-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Modula-2; see the file COPYING.  If not, write to the
+Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
+
+#include "gm2-gcc/gcc-consolidation.h"
+
+#include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name.  */
+#include "tree-pass.h" /* FIXME: only for PROP_gimple_any.  */
+#include "toplev.h"
+#include "debug.h"
+
+#include "opts.h"
+
+#define GM2_LANG_C
+#include "gm2-lang.h"
+#include "m2block.h"
+#include "dynamicstrings.h"
+#include "m2options.h"
+#include "m2convert.h"
+#include "m2linemap.h"
+#include "init.h"
+#include "m2-tree.h"
+#include "convert.h"
+#include "rtegraph.h"
+
+static void write_globals (void);
+
+static int insideCppArgs = FALSE;
+
+#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
+
+/* start of new stuff.  */
+
+/* Language-dependent contents of a type.  */
+
+struct GTY (()) lang_type
+{
+  char dummy;
+};
+
+/* Language-dependent contents of a decl.  */
+
+struct GTY (()) lang_decl
+{
+  char dummy;
+};
+
+/* Language-dependent contents of an identifier.  This must include a
+   tree_identifier.  */
+
+struct GTY (()) lang_identifier
+{
+  struct tree_identifier common;
+};
+
+/* The resulting tree type.  */
+
+union GTY ((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
+chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), "
+"TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN "
+"(&%h.generic)) : NULL"))) lang_tree_node
+{
+  union tree_node GTY ((tag ("0"),
+desc ("tree_node_structure (&%h)"))) generic;
+  struct lang_identifier GTY ((tag ("1"))) identifier;
+};
+
+struct GTY (()) language_function
+{
+
+  /* While we are parsing the function, this contains information about
+  the statement-tree that we are building.  */
+  /* struct stmt_tree_s stmt_tree;  */
+  tree stmt_tree;
+};
+
+/* Language hooks.  */
+
+bool
+gm2_langhook_init (void)
+{
+  build_common_tree_nodes (false);
+  build_common_builtin_nodes ();
+
+  /* The default precision for floating point numbers.  This is used
+ for floating point constants with abstract type.  This may eventually
+ be controllable by a command line option.  */
+  mpfr_set_default_prec (256);
+
+  /* GNU Modula-2 uses exceptions.  */
+  using_eh_for_cleanups ();
+  return true;
+}
+
+/* The option mask.  */
+
+static unsigned int
+gm2_langhook_option_lang_mask (void)
+{
+  return CL_ModulaX2;
+}
+
+/* Initialize the options structure.  */
+
+static void
+gm2_langhook_init_options_struct (struct gcc_options *opts)
+{
+  /* Default to avoiding range issues for complex multiply and divide.  */
+  opts->x_flag_complex_method = 2;
+
+  /* The builtin math functions should not set errno.  */
+  opts->x_flag_errno_math = 0;
+  opts->frontend_set_flag_errno_math = true;
+
+  /* Exceptions are used.  */
+  opts->x_flag_exceptions = 1;
+  init_FrontEndInit ();
+}
+
+/* Infrastructure for a VEC of bool values.  */
+
+/* This array determines whether the filename is associated with the
+   C preprocessor.  */
+
+static vec filename_cpp;
+
+void
+gm2_langhook_init_options (unsigned int decoded_options_count,
+   struct cl_decoded_option *decoded_options)
+{
+  unsigned int i;
+  bool in_cpp_args = false;
+
+  for (i = 1; i < decoded_options_count; i++)
+{
+  switch (decoded_options[i].opt_index)
+{
+ 

[PATCH v3 4/19] modula2 front end: libgm2/libm2pim contents

2022-12-06 Thread Gaius Mulley via Gcc-patches
 

This patch set consists of the makefiles, autoconf sources necessary
to build the various libgm2/libm2pim libraries.  The c/c++/h files
are included in the patch set.  The modula-2 sources are found in
gcc/m2/ as they are used by the compiler.

 
--8<--8<--8<--8<--8<--8< 
diff -ruw /dev/null gcc-git-devel-modula2/libgm2/libm2pim/target.c
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/libgm2/libm2pim/target.c  2022-12-06 
02:56:51.432775922 +
@@ -0,0 +1,61 @@
+/* target.c provide access to miscellaneous math functions.
+
+Copyright (C) 2005-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include 
+
+#if defined(HAVE_MATH_H)
+#include 
+#endif
+
+#if !defined(HAVE_EXP10)
+#if defined(M_LN10)
+double
+exp10 (double x)
+{
+  return exp (x * M_LN10);
+}
+#endif
+#endif
+
+#if !defined(HAVE_EXP10F)
+#if defined(M_LN10)
+float
+exp10f (float x)
+{
+  return expf (x * M_LN10);
+}
+#endif
+#endif
+
+#if !defined(HAVE_EXP10L)
+#if defined(M_LN10)
+long double
+exp10l (long double x)
+{
+  return expl (x * M_LN10);
+}
+#endif
+#endif
diff -ruw /dev/null gcc-git-devel-modula2/libgm2/libm2pim/Selective.cc
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/libgm2/libm2pim/Selective.cc  2022-12-06 
02:56:51.432775922 +
@@ -0,0 +1,319 @@
+/* Selective.c provide access to timeval and select.
+
+Copyright (C) 2009-2022 Free Software Foundation, Inc.
+Contributed by Gaius Mulley .
+
+This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include 
+#include 
+
+#if defined(HAVE_STDDEF_H)
+/* Obtain a definition for NULL.  */
+#include 
+#endif
+
+#if defined(HAVE_STDIO_H)
+/* Obtain a definition for NULL.  */
+#include 
+#endif
+
+#if defined(HAVE_SYS_TIME_H)
+#include 
+#endif
+
+#if defined(HAVE_TIME_H)
+/* Obtain a definition for NULL.  */
+#include 
+#endif
+
+#if defined(HAVE_STRING_H)
+/* Obtain a definition for NULL.  */
+#include 
+#endif
+
+#if defined(HAVE_WCHAR_H)
+/* Obtain a definition for NULL.  */
+#include 
+#endif
+
+#if defined(HAVE_STDLIB_H)
+/* Obtain a prototype for free and malloc.  */
+#include 
+#endif
+
+#if defined(HAVE_SYS_TYPES_H)
+#include 
+#endif
+
+#if defined(HAVE_UNISTD_H)
+#include 
+#endif
+
+#if !defined(NULL)
+#define NULL (void *)0
+#endif
+
+#if defined(HAVE_SELECT)
+#define FDSET_T fd_set
+#else
+#define FDSET_T void
+#endif
+
+/* Select wrap a call to the C select.  */
+
+#if defined(HAVE_STRUCT_TIMEVAL)
+extern "C" int
+Selective_Select (int nooffds, fd_set *readfds, fd_set *writefds,
+  fd_set *exceptfds, struct timeval *timeout)
+{
+  return select (nooffds, readfds, writefds, exceptfds, timeout);
+}
+#else
+extern "C" int
+Selective_Select (int nooffds, void *readfds, void *writefds, void *exceptfds,
+  void *timeout)
+{
+  return 0;
+}
+#endif
+
+/* InitTime initializes a timeval structure and returns a pointer to it.  */
+
+#if defined(HAVE_STRUCT_TIMEVAL)
+extern "C" struct timeval *
+Selective_InitTime (unsigned int sec, unsigned int usec

[PATCH v3 17/19] modula2 front end: dejagnu expect library scripts

2022-12-06 Thread Gaius Mulley via Gcc-patches
 

Here are the dejagnu expect library scripts for the gm2
testsuite.

 
--8<--8<--8<--8<--8<--8< 
diff -ruw /dev/null gcc-git-devel-modula2/gcc/testsuite/lib/gm2.exp
--- /dev/null   2022-08-24 16:22:16.88870 +0100
+++ gcc-git-devel-modula2/gcc/testsuite/lib/gm2.exp 2022-12-06 
02:56:51.424775814 +
@@ -0,0 +1,498 @@
+# Copyright (C) 2003-2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file was written by Gaius Mulley (gaius.mul...@southwales.ac.uk)
+# for GNU Modula-2.
+
+# we want to use libgloss so we can get find_gcc.
+load_lib libgloss.exp
+load_lib prune.exp
+load_lib gcc-defs.exp
+load_lib target-libpath.exp
+
+
+#
+# GCC_UNDER_TEST is the compiler under test.
+#
+
+#
+# default_gcc_version -- extract and print the version number of the compiler
+#
+
+proc default_gcc_version { } {
+global GCC_UNDER_TEST
+
+gm2_init;
+
+# ignore any arguments after the command
+set compiler [lindex $GCC_UNDER_TEST 0]
+
+if ![is_remote host] {
+   set compiler_name [which $compiler];
+} else {
+   set compiler_name $compiler;
+}
+
+# verify that the compiler exists
+if { $compiler_name != 0 } then {
+   set tmp [remote_exec host "$compiler --version"]
+   set status [lindex $tmp 0];
+   set output [lindex $tmp 1];
+   regexp "version.*$" $output version
+   if { $status == 0 && [info exists version] } then {
+   clone_output "$compiler_name $version\n"
+   } else {
+   clone_output "Couldn't determine version of $compiler_name: 
$output\n"
+   }
+} else {
+   # compiler does not exist (this should have already been detected)
+   warning "$compiler does not exist"
+}
+}
+
+#
+# gcc_version -- Call default_gcc_version, so we can override it if needed.
+#
+
+proc gcc_version { } {
+default_gcc_version;
+}
+
+#
+# gm2_init -- called at the start of each .exp script.
+#
+# There currently isn't much to do, but always using it allows us to
+# make some enhancements without having to go back and rewrite the scripts.
+#
+
+set gm2_initialized 0;
+set gm2_compile_method "default";
+set gm2_link_path "";
+set gm2_link_libraries "m2pim m2iso";
+set gm2_link_objects "";
+
+proc gm2_set_compile_method { arg } {
+global gm2_compile_method;
+
+send_log "\n"
+send_log " setting gm2_compile_method to $arg \n"
+send_log "\n"
+set gm2_compile_method $arg;
+}
+
+
+proc gm2_init { args } {
+global tmpdir;
+global objdir;
+global rootme;
+global base_dir;
+global tool_root_dir;
+global gluefile wrap_flags;
+global gm2_initialized;
+global GCC_UNDER_TEST;
+global TOOL_EXECUTABLE;
+global gm2_link_libraries;
+global gm2_link_objects;
+global gm2_link_path;
+global HAVE_LIBSTDCXX_V3;
+
+if { $gm2_initialized == 1 } { return; }
+
+set gm2_link_objects "";
+set GCC_UNDER_TEST [lookfor_file $rootme gm2];
+append GCC_UNDER_TEST " " -B[file dirname $rootme]/gcc " " ${args};
+append GCC_UNDER_TEST " " -fno-diagnostics-show-caret
+append GCC_UNDER_TEST " " -fno-diagnostics-show-line-numbers
+append GCC_UNDER_TEST " " -fdiagnostics-color=never
+send_log "GCC_UNDER_TEST is ${GCC_UNDER_TEST}\n"
+
+if ![info exists tmpdir] then {
+   set tmpdir /tmp;
+}
+if {[target_info needs_status_wrapper] != "" && \
+   [target_info needs_status_wrapper] != "0" && \
+   ![info exists gluefile]} {
+   set gluefile ${tmpdir}/gcc-testglue.o;
+   set result [build_wrapper $gluefile];
+   if { $result != "" } {
+   set gluefile [lindex $result 0];
+   set wrap_flags [lindex $result 1];
+   } else {
+   unset gluefile
+   }
+}
+
+set gm2_link_path "[gm2_link_flags [get_multilibs]]";
+verbose $gm2_link_path 1
+}
+
+#
+# gm2_target_compile_default -- compile a source file
+#
+
+proc gm2

  1   2   3   >