0

I want to build the latest version of Emacs (from git.sv.gnu.org) for a CentOS system, but the building must be done on a Debian system1. Both systems run on x86_64 architectures.

I've seen instructions for doing this sort of thing before, but now that I need them, I can't find them (i.e., I have not found the right keywords for my Google searches).

I can't find the instructions I'm looking in the installation info for Emacs, either. Again, this could also be due to a faulty search strategy, but it occurred to me that maybe the reason I'm not finding this info is that it is simply generic Unix knowledge (like, e.g., unpacking a tar ball, or changing the ownership of the unpacked contents), not specific to Emacs. Hence, I'm posting the question here.

To recap, my goal is to create a self-contained Emacs executable that does not require any libraries from its host system.

What settings must I use to compile Emacs to achieve this goal? More specifically, how would I have to change the following sequence

./autogen.sh
./configure --prefix=${INSTALL_DIR} --with--m17n-flt
./make bootstrap
./make install

...to do this?

For what it's worth, in the "build" (Debian) system, cc is symlinked to /usr/bin/x86_64-linux-gnu-gcc-6.


1It's a long story, but basically, I have root access in the Debian system, but not in the CentOS one.

  • Use flatpak/appimage/snap. Much easier than a static compile. – Ipor Sircer Oct 3 '18 at 13:20
  • @IporSircer: Thank you for the pointer. Maybe for someone familiar with those tools they would indeed be easier than a static compile. For me, however, I'm skeptical. I'd never heard of them before, so I would have to learn to use one of them before I could put in practice your suggestion. – kjo Oct 3 '18 at 13:23
  • 1
    @IporSircer: I stand corrected. I found this flathub.org/apps/details/org.gnu.emacs . It looks like now my problem reduces to installing flatpak on the target system, as a non-root user... – kjo Oct 3 '18 at 14:02
  • why do you need to be root in order to build emacs? also, building it with eg. --prefix=/your/home/emacs and just copying the whole thing over may just work (or it will easily fixable by copying the couple of missing libs somewhere and using LD_LIBRARY_PATH -- again, no need to be root for that). – mosvy Oct 3 '18 at 14:16
  • @mosvy: because that would require building all of Emacs bazillion dependencies from source. Have you ever tried it? It is a far cry from apt-get install emacs. I was at it for a couple of days, and had to give up... – kjo Oct 3 '18 at 14:26
0

The way to create a statically-linked binary is to pass the -static option to the linker. Since you don't run the linker directly, you'll need to get that through the build system (and probably through the compiler, too).

Emacs is a GNU package, so it probably uses autotools for its build. In that case, you need to use the LDFLAGS variable:

./configure LDFLAGS="-static"

Unfortunately, upon trying this out, I found that emacs uses a number of glibc function calls that don't work in static binaries; and the "bootstrap-emacs" which is built as part of that will even segfault at startup because of it. So you can't do it with a static build.

Instead, you could do one of the following:

  • You set up a CentOS chroot on your Debian box in which you do the build, and then copy the binaries to the CentOS chroot
  • You can build an autotools package with an alternative prefix, so it works from your home directory:

    ./configure --prefix=$HOME/emacs --exec-prefix=$HOME/bin
    

    This will compile emacs so that it installs in $HOME/bin, with any support files found under $HOME/emacs. Of course, that assumes that the required libraries are available on the CentOS machine, which might not be the case.

  • You can just ask your local root to install emacs for you...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.