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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 09 May 2023 08:05:39 +0300

> From: Arash Esbati <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Mon, 08 May 2023 21:34:22 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > The recipe goes like this:
> >
> >   sed -n 's/.*\[\(.*\)]$/\1/p' BACKTRACE | addr2line -C -f -i -p -e BINDIR/EMACS-BINARY
> >
> > (It is broken in the manual into two lines, because the line is long,
> > but it is a single long command that runs Sed and pipes its output
> > into addr2line, a program that comes with GNU Binutils.)
> 
> Yes, I think I grasped that one.  The problem I'm facing is that my
> lisp/emacs_backtrace.txt looks like this:
> 
>   Backtrace:
>   00007ff61166a12e
>   00007ff611538be1
>   00007ff611559601
>   00007ff6116ce84a
>   00007ff9b7977ff0
>   ...
> 
> and the sed command doesn't match on the addresses above.  It works for
> the example given in the manual like this:
> 
>   Backtrace:
>   emacs[0x5094e4]
>   emacs[0x4ed3e6]
>   emacs[0x4ed504]
>   /lib64/libpthread.so.0[0x375220efe0]
>   /lib64/libpthread.so.0(read+0xe)[0x375220e08e]
>   emacs[0x509af6]
>   emacs[0x5acc26]
> 
> So in my case, sed returns nothing which is piped into addr2line.

Right, forgot about that factoid.  On Windows, the Sed part is not
required, so the command is just

  addr2line -C -f -i -p -e BINDIR/EMACS-BINARY < emacs_backtrace.txt

> > Can you show a full C compilation command of one of the C source
> > files?  Like this:
> >
> >   $ cd /path/to/emacs/src
> >   $ make data.o -W data.c V=1
> >
> > I'd like to see all of the compiler's command-line options your build
> > uses.
> 
> It looks like this; line-breaks added manually:

OK, so you compile with "-O2 -gdwarf-2 -g3", the default optimization
options, and with -mtune=generic (also the default).  Things to try,
in order to better understand the scope of the problem:

  1) try removing -mtune=generic
  2) try using -O1 instead of -O2

For 1), edit src/Makefile to remove -mtune=generic from any GCC
options there, then remove src/*.o files and say "make" to rebuild.
For 2), edit src/Makefile to change -O2 to -O1, and again remove *.o
files and rebuild.  But let's first establish the exact locus of the
crashes first, without any changes in the build options.