Common Lisp on iPhone: ECL comes through at last!

In Uncategorized on March 27, 2009 at 8:38 pm

** UPDATE** See http://funcall.posterous.com/ecl-on-iphone-redux for a more up-to-date description of how to get this to work.  **

Common Lisp is finally on the iPhone!  After waaaaay too much time in C and Makefile world, I have gotten ECL to cross-compile for the ARM processor and iPhone OS.  The whole process required some changes to the ECL code itself, the ECL make process, and changes to the garbage collector.

To get ECL cross-compiling was a challenge for someone without much experience building C libraries and dealing with platform dependencies.

I made a script that should make this process easy at least 1000 times less painful than my experience.  Just get ECL from the Floatopian repository and build it with a simple script:

git clone http://floatopian.com/~reddaly/ecl/ecl/.git/

cd ecl

sh make-iphone

The library files should be installed in install_iPhoneOS/lib/.  If they are not, then something probably went wrong during the installation process.  The build script is pretty dumb, so it will keep going even if individual steps encounter errors.  So if you get problems look for the error highest up in the output.

THIS VERSION OF ECL does not have any extra bells and whistles.  It is built without threads, bignum support, and ASDF.  If you add any of these features, let me or the ECL list know so we can all share the wealth.

Some notes on ASDF:

> However, I still don’t have all the bells and whisltes working correctly.
> My current problem is getting ASDF to properly compile into ECL.  I cannot
> get ECL to build, even for the i386 Darwin non-cross-compiled version of
> ECL, when I have ASDF enabled and the –disable-shared flag set in the
> configuration script.  […]

> Any idea what’s going on here?  The error message doesn’t really tell me
> much about what’s going wrong.  I am even more confused about why the
> –disable-shared flag makes any difference.

–disable-shared means you cannot compile code and load it. That is
why ASDF is not building. My question now is, does you iPhone have a C
compiler? If not then you will have to install a fake version of
COMPILE-FILE and COMPILE and try to teach ASDF to use it. It might be
a nice addition to ECL for environments without a C compiler but, as I
said, it is fake: there will be no compilation going on.

Some notes on cross-compiling GMP: http://gmplib.org/list-archives/gmp-bugs/2008-April/000997.html

Finally, I would like to get SLIME working on the iPhone to bring the advantages of REPL development to the iPhone.  If you get that working, let me know.


  • Ported Boehm garbage collector to iPhone.  I believe I ported everything necessary to get it to work in a threaded environment, but threading is currently broken so the GC part may not be functional.  Look at the changes to gcconfig.h
  • various fixes to ensure that the build and host ECLs use the same exact built-in symbol table. (The build ECL is the one with the i386 architecture that you use to cross-compile the ARMV6 architecture host ECL)  ECL uses a tool called DPP to compile lispish C to something gcc can understand.  If the build and host ECLs are not compiled with the same settings, then the symbol tables do not line up and you get strange runtime bugs.  I changed a bunch of C #defines so to make sure the same symbol sets were used.
  • fixed some problems assumptions that precluded cross-compilation and non-GMP builds
  1. […] Common Lisp on iPhone: ECL comes through at last! « LambdaJive (tags: lisp iphone) […]

  2. Hi, I am interested in the changes you made to boehm gc for an unrelated project of mine. I tried your git link, but it did not seem to work (maybe I don’t know how to use git). Where the changes simple, or did you have to do a bit more?

  3. I am really interested in your work. I am a mobility developer and its very challenging supporting so many devices. It’s a booming market like the web however has NOTHING in common on any of the devices.

    Mono framework has been AOT compiled onto the iPhone however most of the seamless integration is private to the Unity3D product. Great blog post about it here:


    I’m wondering if some of your work could be leveraged for going the last mile in this respect? You seem super knowledgable.

    I am nowhere near this level however like I said supporting so many mobile platforms is becoming hugely challenging.

    We support iPhone, WM and BlackBerry and can obviously expect Palm Pre and Android coming soon as well.

    Mono is a very powerful framework and great set of developer libraries.

    If we could just find some way to get it ported to more mobile platforms it would be an awesome opportunity.

    Any comments would be greatly appreciated!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: