Subject: Re: bug#63365: 30.0.50; GCC 13.1 breaks building Emacs with native-compilation

From: Cyril Arnould <[email-masked]>
Date: Tue, 14 May 2024 21:52:42 +0200

I believe the problem is centered around the mark_threads function (in
thread.c). I still have no idea if the issue is with emacs or GCC, but
I hope this helps narrow it down.

I found it by trying to suppress the sibling call optimization through
printf statements at the end of every function that showed differences
between the objdump files. With the additional printf calls, the
native-compilation build works together with the
-foptimize-sibling-calls flag.

After that, it was just a matter of narrowing it down. You can try it
for yourself with the following patch:

diff --git a/src/thread.c b/src/thread.c
index 040ca39511e..b522d146779 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -696,6 +696,7 @@ mark_threads_callback (void *ignore)
  mark_threads (void)
  {
    flush_stack_call_func (mark_threads_callback, NULL);
+  printf("");
  }

  void

Note that by now I've moved on to emacs-29.3 on GCC 14, however it
seems that the issue is still exactly the same.