Subject: Re: bug#47067: 28.0.50; [feature/native-comp] Crash while scrolling through dispnew.c

From: Pip Cet <[email-masked]>
Date: Sun, 14 Mar 2021 11:44:14 +0000

On Sun, Mar 14, 2021 at 11:39 AM Eli Zaretskii <[email-masked]> wrote:
> > From: Pip Cet <[email-masked]>
> > Date: Sun, 14 Mar 2021 08:06:30 +0000
> > Cc: Andrea Corallo <[email-masked]>, [email-masked]
> >
> > > Sorry, I don't understand: what is the procedure for testing this
> > > patch?
> >
> > - apply the patch
> > - rebuild Emacs
> > - remove the problematic file (but not necessarily any others)
> > - rerun your recipe
>
> Thanks.  After patching and rebuilding Emacs, compilation of
> cc-engine.el fails with these error messages:
>
>   Warning (comp): D:\usr\bin\libgccjit-0.dll: error: gcc_jit_context_new_call: mismatching types for argument 2 of function "_setjmp": assignment to param ret (type: unsigned int) from __builtin_frame_address ((unsigned int)0) (type: void *)

Sorry, thinko. Better patch attached.

Pip
diff --git a/src/comp.c b/src/comp.c
index b24fcb5bf5a99..7df8c6a93e1c6 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -1946,6 +1946,11 @@ emit_setjmp (gcc_jit_rvalue *buf)
   return gcc_jit_context_new_call (comp.ctxt, NULL, f, 1, args);
 #else
   /* _setjmp (buf, __builtin_frame_address (0)) */
+  gcc_jit_param *params[] =
+  {
+    gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "buf"),
+    gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "frame"),
+  };
   gcc_jit_rvalue *args[2];
 
   args[0] =
@@ -1959,8 +1964,14 @@ emit_setjmp (gcc_jit_rvalue *buf)
 					    "__builtin_frame_address"),
       1, args);
   args[0] = buf;
-  return emit_call (intern_c_string (STR (SETJMP_NAME)), comp.int_type, 2, args,
-                    false);
+  gcc_jit_function *f =
+    gcc_jit_context_new_function (comp.ctxt, NULL,
+				  GCC_JIT_FUNCTION_IMPORTED,
+				  comp.int_type, STR (SETJMP_NAME),
+				  ARRAYELTS (params), params,
+				  false);
+
+  return gcc_jit_context_new_call (comp.ctxt, NULL, f, 2, args);
 #endif
 }