public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] modula2: Fix up bootstrap on powerpc64le-linux [PR108147]
@ 2022-12-19 11:11 Jakub Jelinek
  2022-12-19 13:17 ` Gaius Mulley
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2022-12-19 11:11 UTC (permalink / raw)
  To: Gaius Mulley; +Cc: gcc-patches

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  <jakub@redhat.com>

	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.

--- gcc/m2/gm2-gcc/m2linemap.def.jj	2022-12-14 20:30:41.110303552 +0100
+++ gcc/m2/gm2-gcc/m2linemap.def	2022-12-16 18:44:04.029951259 +0100
@@ -47,11 +47,6 @@ PROCEDURE GetLineNoFromLocation (locatio
 PROCEDURE GetColumnNoFromLocation (location: location_t) : INTEGER ;
 PROCEDURE GetFilenameFromLocation (location: location_t) : ADDRESS ;
 PROCEDURE ErrorAt (location: location_t; message: ADDRESS) ;
-(*
-PROCEDURE ErrorAtf (location: location_t; message: ADDRESS; ...) ;
-PROCEDURE WarningAtf (location: location_t; message: ADDRESS; ...) ;
-PROCEDURE NoteAtf (location: location_t; message: ADDRESS; ...) ;
-*)
 PROCEDURE ErrorAtf (location: location_t; message: ADDRESS) ;
 PROCEDURE WarningAtf (location: location_t; message: ADDRESS) ;
 PROCEDURE NoteAtf (location: location_t; message: ADDRESS) ;
--- gcc/m2/gm2-gcc/m2linemap.h.jj	2022-12-14 20:30:41.111303537 +0100
+++ gcc/m2/gm2-gcc/m2linemap.h	2022-12-16 18:44:19.443727288 +0100
@@ -55,9 +55,9 @@ EXTERN int m2linemap_GetLineNoFromLocati
 EXTERN int m2linemap_GetColumnNoFromLocation (location_t location);
 EXTERN const char *m2linemap_GetFilenameFromLocation (location_t location);
 EXTERN void m2linemap_ErrorAt (location_t location, char *message);
-EXTERN void m2linemap_ErrorAtf (location_t location, const char *message, ...);
-EXTERN void m2linemap_WarningAtf (location_t location, const char *message, ...);
-EXTERN void m2linemap_NoteAtf (location_t location, const char *message, ...);
+EXTERN void m2linemap_ErrorAtf (location_t location, const char *message);
+EXTERN void m2linemap_WarningAtf (location_t location, const char *message);
+EXTERN void m2linemap_NoteAtf (location_t location, const char *message);
 EXTERN void m2linemap_internal_error (const char *message);
 
 
--- gcc/m2/gm2-gcc/m2linemap.cc.jj	2022-12-14 20:30:41.110303552 +0100
+++ gcc/m2/gm2-gcc/m2linemap.cc	2022-12-16 18:50:00.763767826 +0100
@@ -182,8 +182,8 @@ m2linemap_ErrorAt (location_t location,
 
 /* m2linemap_ErrorAtf - wraps up an error message.  */
 
-void
-m2linemap_ErrorAtf (location_t location, const char *message, ...)
+static void
+m2linemap_ErrorAtf_1 (location_t location, const char *message, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
@@ -195,10 +195,16 @@ m2linemap_ErrorAtf (location_t location,
   va_end (ap);
 }
 
+void
+m2linemap_ErrorAtf (location_t location, const char *message)
+{
+  m2linemap_ErrorAtf_1 (location, message);
+}
+
 /* m2linemap_WarningAtf - wraps up a warning message.  */
 
-void
-m2linemap_WarningAtf (location_t location, const char *message, ...)
+static void
+m2linemap_WarningAtf_1 (location_t location, const char *message, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
@@ -210,10 +216,16 @@ m2linemap_WarningAtf (location_t locatio
   va_end (ap);
 }
 
+void
+m2linemap_WarningAtf (location_t location, const char *message)
+{
+  m2linemap_WarningAtf_1 (location, message);
+}
+
 /* m2linemap_NoteAtf - wraps up a note message.  */
 
-void
-m2linemap_NoteAtf (location_t location, const char *message, ...)
+static void
+m2linemap_NoteAtf_1 (location_t location, const char *message, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
@@ -225,6 +237,12 @@ m2linemap_NoteAtf (location_t location,
   va_end (ap);
 }
 
+void
+m2linemap_NoteAtf (location_t location, const char *message)
+{
+  m2linemap_NoteAtf_1 (location, message);
+}
+
 /* m2linemap_internal_error - allow Modula-2 to use the GCC internal error.  */
 
 void

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] modula2: Fix up bootstrap on powerpc64le-linux [PR108147]
  2022-12-19 11:11 [PATCH] modula2: Fix up bootstrap on powerpc64le-linux [PR108147] Jakub Jelinek
@ 2022-12-19 13:17 ` Gaius Mulley
  0 siblings, 0 replies; 2+ messages in thread
From: Gaius Mulley @ 2022-12-19 13:17 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

Jakub Jelinek <jakub@redhat.com> 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  <jakub@redhat.com>
>
> 	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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-19 13:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 11:11 [PATCH] modula2: Fix up bootstrap on powerpc64le-linux [PR108147] Jakub Jelinek
2022-12-19 13:17 ` Gaius Mulley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).