James Thornton logo
James Thornton
Google
Web jamesthornton.com
Internet Business Consultant
Home Blog Bio Projects Contact
JamesThornton.com -\> Writing -\> Compiling Emacs on RHEL3/Fedora

Compiling Emacs on Redhat Enterprise Linux 3 and Fedora: HOWTO

Summary: Instructions for compiling emacs on Redhat Enterprise Linux 3 and Fedora with error explanations and workarounds.

Emacs does not compile cleanly on Redhat Enterprise Linux 3 or Fedora. I prefer Emacs 20.7 over the more current 21.x versions since it's lighter and faster over remote connections, but I encounted exactly the same errors when compiling Emacs 21.3.

Exec-shield Conflict

In recent Linux kernels, there is a new Exec-shield security feature that conflicts.

Exec-shield is a security-enhancing modification to the Linux kernel that makes large parts of specially-marked programs _ including their stack _ not executable. This can reduce the potential damage of some security holes. Exec-shield is related to the older "non-exec stack patch" but has the potential to provide greater protection.

Exec-shield can also randomize the virtual memory addresses at which certain binaries are loaded. This randomized VM mapping makes it more difficult for a malicious application to improperly access code or data based on knowledge of the code or data's virtual address.

Exec-shield functionality is available only to binaries that have been built (and marked) using the toolchain (compiler, assembler, linker) available with Fedora.

The problem is that Exec-shield enables a different memory layout that breaks the emacs dumper.

To get around this issue, you can temporarily disable Exec-shield while building emacs, using the setarch command. Here are the commands to configure and make emacs with X enabled:

# setarch i386 ./configure --x-libraries=/usr/X11R6/lib/ \
--x-includes=/usr/X11R6/include/ --with-x --with-x-toolkit=yes
# setarch i386 make

XFree86 Development Libraries Required

If you get an error like this:

/usr/local/src/emacs-20.7/lib-src/movemail.c: In function `strerror':
/usr/local/src/emacs-20.7/lib-src/movemail.c:924: conflicting types for `sys_errlist'
/usr/include/bits/sys_errlist.h:28: previous declaration of `sys_errlist'
make[1]: *** [movemail.o] Error 1
make[1]: Leaving directory `/usr/local/src/emacs-20.7/lib-src'
make: *** [lib-src] Error 2
...then you need to install the XFree86 development libraries. On Redhat, you can install them with this command:
up2date --nox XFree86-devel

nocombreloc

combreloc has become the default for recent GNU ld, which breaks the unexec/undump on all versions of both Emacs and XEmacs. It has been patched in newer versions of Emacs, but older versions, including Emacs 20.7, are still bit by this bug. Emacs will dump core at XtInitializeWidgetClass () with Fatal Error (11).Segmentational Fault. To fix this error, add the following to LDFLAGS in Makefile, after you run configure:

-z nocombreloc

Build Procedure

So to build emacs with X enabled on a RHEL 3 server, I did the following:

# up2date --nox XFree86-devel
# setarch i386 ./configure --x-libraries=/usr/X11R6/lib/ --x-includes=/usr/X11R6/include/ --with-x --with-x-toolkit=yes

(add -z nocombreloc to LDFLAGS in Makefile)

# setarch i386 make
# setarch i386 make install

Related


Follow espeed on Twitter