Subject: Re: bug#65727: 30.0.50; Build failure in MSYS2 when --with-native-compilation

From: Cyril Arnould <[email-masked]>
Date: Wed, 15 May 2024 01:29:40 +0200

> Interesting, would you mind instead of using 'printf' to try using
 > '__attribute__((optimize("O0")))' on the function to verify that the
 > issue is really an optimization?

With the following, the build fails:

diff --git a/src/thread.c b/src/thread.c
index 040ca39511e..ffdcf420af0 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -692,6 +692,7 @@ mark_threads_callback (void *ignore)
      }
  }

+__attribute__((optimize("O0")))
  void
  mark_threads (void)
  {

I hope this was correct? If I replace it with
'__attribute__((optimize("no-optimize-sibling-calls")))', the build
succeeds again.

I therefore tried to compile the entirety of thread.c with -O0
instead, upon which the build succeeded again. I'll try to add the
'__attribute__((optimize("O0")))' in more thread.c functions to see
which ones need it for a successful build (unless you have a better
suggestion?).

To summarize the current state:

thread.c compiled with -O2: build fails
thread.c compiled with -O2 -fno-optimize-sibling-calls: build succeeds
thread.c compiled with -O0: build succeeds

thread.c compiled with -O2 and
- mark_threads with printf: build succeeds
- mark_threads with 
__attribute__((optimize("no-optimize-sibling-calls"))): build succeeds
- mark_threads with __attribute__((optimize("O0"))): build fails