简体   繁体   中英

How to cross compile Emacs for iOS

Emacs 23.2 has been compiled for iOS by making use of cydia on a jailbroken iOS device - source

How would I go about cross-compiling a staticaly linked, 64-bit, minimal, non-gui emacs to iOS using only a mac as a build host? Preferably by using Emacs own configure & make (a patch is probably needed).

Lets ignore both the code-signing and the problem of running this cli binary on a non-jailbroken iOS device (I know how to solve both those problems).

Emacs doesn't really support cross-compilation as such, no. A few people have done cross compilation, but it requires a fair bit of fiddling and noone has contributed patches to Emacs to ease the job :-(

The problems that show up are the following:

  • when building Emacs from a Git clone, some files are built by Emacs itself (mostly the .elc files), so you'll need to first build a "host Emacs" to compile those files before cross-compiling a "target Emacs". When building from an official release tarball those files should already be built and included in the tarball, so this problem should hopefully not appear.
  • More problematic: like @lawlist mentions, the Emacs build procedure first builds a temacs executable, which is then executed to load a bunch of "preloaded" Elisp files after which the in-memory image of the process is used to generate a new executable binary (the actual emacs ). This is called "dump"ing. This is done so that starting Emacs is faster because it doesn't need to go and load all those Elisp files.

You can actually use temacs rather than emacs and it should mostly work. There's even a CPP flag called CANNOT_DUMP which you can use to tweak some things so that temacs works presumably a bit better. It will make it slower to launch a new Emacs process, and is a mode which is basically never tested, so expect quirks and problems.

You can work around that problem by first cross-building temacs , and then running it on the target host. of course. But note that this "dumping" operation requires 100% unportable hacks which need to be tweaked for each OS, so it's very likely that the existing dumping code won't work quite right for iOS (ie will generate a binary which will crash&burn right from the start).

Your stating that "Emacs 23.2 has been compiled for iOS" makes it sound like some of those problems have been solved for an older Emacs version, so maybe there's hope, I don't know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM