Subject: Re: bug#22065: core dumped during compilation (emacs-25 branch on FreeBSD 9)

From: Wolfgang Jenkner <[email-masked]>
Date: Sun, 14 Feb 2016 17:12:46 +0100

On Mon, Nov 30 2015, Joseph Mingrone wrote:

> There is a compilation issue on FreeBSD 9 (which has about another
> year of life) for the emacs-25 branch.  The error/warnings suggest the
> problems may be related to bug 18410.  It compiles fine on FreeBSD 10.
> Attached is a build log.

The pkg-fallout list indicates that that the build has been broken since
13 Nov 2014, although at that time it failed while temacs was loading up
stuff, with a different error message.

http://docs.freebsd.org/cgi/mid.cgi?201411130859.sAD8xATU001375

According to

https://svnweb.freebsd.org/ports/head/editors/emacs-devel/Makefile?view=log

this seems to correlate to a ports update to emacs bzr version 118251
from the previous 117676 (on Aug 10 2014).

There's a prominent change concerning the stack in this time frame, viz.

  commit c7dfea947eba1980fe3a23ad13f04dd40c6c0d68
  Author: Dmitry Antipov
  Date:   Tue Sep 9 07:44:06 2014 +0400

  Add macros to allocate temporary Lisp objects with alloca.

So, on FreeBSD 10, in a jail containing a basic FreeBSD 9 amd64 userland
I bisected between the above commit, which is still good, and some later
bad commit.

As USE_STACK_LISP_OBJECTS wasn't turned on by default before 2014-09-24,
I configured with

$ ./configure --without-all --without-x CPPFLAGS=-DUSE_STACK_LISP_OBJECTS=1

In the last few steps I had to delete the INLINE specifier in the
definition of local_vector_init() in src/alloc.c because it conflicted
with a declaration in src/lisp.h.

The first bad commit turns out to be

  commit edb0288b83b45d295df52ce7644e897613358971
  Author: Dmitry Antipov <[email-masked]>
  Date:   Mon Sep 15 18:53:23 2014 +0400

  If USE_LOCAL_ALLOCATORS, allocate some Lisp objects on stack.

Unfortunately, --enable-checking or --enable-check-lisp-object-type
also somehow makes the bootstrapping failure disappear.

On a current emacs master, after adding
CPPFLAGS=-DUSE_STACK_LISP_OBJECTS=0 to the configure command line
bootstrapping emacs works (in the above jail).

Alternatively (though not very practically), adding CFLAGS="-g -O0"
works (but CFLAGS="-g -O" doesn't).

Alternatively, bootstrapping even with the oldest gcc available from
ports (4.6.4) works.

So, perhaps, the FreeBSD 9 default base cc (a patched gcc 4.2.1) has
some stack-related optimization bug, even on amd64?