Subject: bug#51254: sysdep.c:1821:22: error: variably modified ‘sigsegv_stack’ at file scope

From: Eli Zaretskii <[email-masked]>
Date: Mon, 18 Oct 2021 05:28:16 +0300

> From: Håkon Hægland
>  <[email-masked]>
> Date: Sun, 17 Oct 2021 22:49:08 +0200
> 
> I am trying to install emacs 27.2 from source on Ubuntu 21.10:
> 
> $ gcc --version
> gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0
> [...]
>   CC       sysdep.o
> sysdep.c:1821:22: error: variably modified ‘sigsegv_stack’ at file scope
>  1821 | static unsigned char sigsegv_stack[SIGSTKSZ];
>       |                      ^~~~~~~~~~~~~
> make[1]: *** [Makefile:406: sysdep.o] Error 1
> make[1]: Leaving directory '/home/hakon/test/install_emacs/emacs-27.2/src'
> make: *** [Makefile:424: src] Error 2

This is due to a change in your system headers.

There won't be any Emacs 27 releases, and the problem is fixed in the
current development sources, which will become Emacs 28.1.  So my
suggestion is to use the code we have there now:

  /* Storage for the alternate signal stack.
     64 KiB is not too large for Emacs, and is large enough
     for all known platforms.  Smaller sizes may run into trouble.
     For example, libsigsegv 2.6 through 2.8 have a bug where some
     architectures use more than the Linux default of an 8 KiB alternate
     stack when deciding if a fault was caused by stack overflow.  */
  static max_align_t sigsegv_stack[(64 * 1024
				    + sizeof (max_align_t) - 1)
				   / sizeof (max_align_t)];