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

From: Arash Esbati <[email-masked]>
Date: Fri, 09 Jun 2023 00:27:43 +0200

Eli Zaretskii <[email-masked]> writes:

> If this is not related to native-compilation, my first suspect is GCC
> optimizations.  Try building with -Og or -O1, and see if that avoids
> the problem.

Ok, I tried the different optimization levels and this is the result.  

Running the standard procedure

  $ git clean -fdx
  $ ./autogen.sh
  $ ./configure --with-native-compilation

Gives this in the summary

  What compiler should emacs be built with?  gcc  -g3 -O2 -gdwarf-2

which breaks during the make run.

Lowering the -O option works for these three scenarios and Emacs builds
successfully with GCC 13.1:

  $ git clean -fdx
  $ ./autogen.sh
  $ CFLAGS='-g3 -O0 -gdwarf-2' ./configure --with-native-compilation
  $ make

  $ git clean -fdx
  $ ./autogen.sh
  $ CFLAGS='-g3 -O1 -gdwarf-2' ./configure --with-native-compilation
  $ make

  $ git clean -fdx
  $ ./autogen.sh
  $ CFLAGS='-g3 -Og -gdwarf-2' ./configure --with-native-compilation
  $ make

Best, Arash