Subject: Re: bug#65640: 30.0.50; segfault when building emacs with native-comp

From: Eli Zaretskii <[email-masked]>
Date: Thu, 31 Aug 2023 08:40:08 +0300

> From: StrawberryTea <[email-masked]>
> Date: Wed, 30 Aug 2023 14:38:55 -0500
> 
> 
> Hi. I just set up a fresh install of Gentoo with Clang as my default
> compiler. At first, I was trying to compile Emacs with Clang and Emacs
> was finding -lgccjit but not finding the libgccjit.h header file. So I
> overwrote the compiler Emacs was using to GCC instead and now it
> compiles but segfaults when native-compiling some Elisp files.
> 
> Build log with Clang (configure error): https://bpa.st/ODFBK
> Build log with GCC (segfault): https://0x0.st/Hpbz.txt

First, you apply local patches to the Emacs tree, so you are compiling
code that is not from our Git repository, but some variation of that.

More importantly: it looks like you build Emacs with "-O3 -march=native",
which are not the default compilation switches, and cause GCC to
over-optimize the code.  Please try again without those switches.

If using the default compiler switches doesn't help, please run the
crashing command under GDB, and when it segfaults, produce the
C-level backtrace and post it here.

Please also always post the build logs as plain text or attachments to
your messages, instead of pointing to a URL that could some day go
away, and thus years from now people will be unable to see the log by
reading this discussion.

Thanks.

P.S. Adding Andrea.