Subject: Re: bug#28882: [bug-gnu-emacs] emacs-26.0.90 build feedback

From: "Nelson H. F. Beebe" <[email-masked]>
Date: Wed, 18 Oct 2017 08:17:14 -0600

The emacs-26.0.90 etc/PROBLEMS file suggests another approach to work
around kernel memory layout randomizations for Red Hat systems.
Curiously, I had no difficulty building emacs-26.0.90 on CentOS 6 and
7 on x86-64 systems, and CentOS 5 IA-64 (Itanium), but on CentOS 5 x86
and x86-64, I get

	Dumping under the name emacs
	**************************************************
	Warning: Your system has a gap between BSS and the
	heap (8467071 bytes).  This usually means that exec-shield
	or something similar is in effect.  The dump may
	fail because of this.  See the section about
	exec-shield in etc/PROBLEMS for more information.
	**************************************************
	make[1]: *** [bootstrap-emacs] Segmentation fault

Today, as root, I ran 

	# cat /proc/sys/kernel/exec-shield
	1

	# echo 0 > /proc/sys/kernel/exec-shield

	# cat /proc/sys/kernel/exec-shield
	0

and then as an unprivileged user, restarted the make.  Unlike on
Alpine Linux, the kernel symbol-value change had no effect: the build
still gets a segmentation fault.

I then tried

	% ./src/temacs
	Loading loadup.el (source)...
	Using load-path (/local/build/cc/emacs-26.0.90/lisp)
	Loading emacs-lisp/byte-run...
	...
	Finding pointers to doc strings...done
	Pure-hashed: 15477 strings, 4055 vectors, 40214 conses, 3919 bytecodes, 175 others

At that point, a normal emacs X11 window appears on my screen, so most
of emacs is working.

However, the dumped executable is unusable:

	% ls -l src/*emacs
	-rwxrwxr-x 1 beebe sysstaff 84149492 Oct 18 07:40 src/emacs
	-rwxrwxr-x 1 beebe sysstaff 48352600 Oct 18 07:40 src/temacs

	% file src/emacs
	src/emacs: data

	% ./src/emacs
	src/emacs: Exec format error. Binary file not executable.

	% ldd ./src/emacs
        not a dynamic executable

In CentOS 5 and 6, the exec-shield variable is 1 by default; it does
not exist on CentOS 7.  The latter instead has
/proc/sys/kernel/randomize_va_space set to 2, but a successful dump to
create src/emacs does not require changing that variable.

Next, I tried another suggestion from etc/PROBLEMS:

	% rm src/emacs src/temacs
	$ bash
	$ export PATH=/bin:/usr/bin:/sbin:/usr/sbin
	$ setarch $(uname -m ) -R make

That one succeeded in making a usable src/emacs executable on both x86
and x86-64 CentOS 5 systems, with /usr/local hidden; I then restored
/usr/local and successfully installed emacs-26.0.90 on those servers.

Thus, the build problems for emacs-26.0.90 on CentOS 5 are resolved,
and my count of successes has increased to 138.

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: [email-masked]  -
- 155 S 1400 E RM 233                       [email-masked]  [email-masked] -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------