Thread: Lisp
View Single Post
Posts: 72 | Thanked: 58 times | Joined on Feb 2008
#9
In case anyone else finds this thread, I decided to have a look at porting the ffcall library, used by clisp for its FFI, to the ARM EABI. This despite my egregious lack of clue in anything to do with modern instruction sets or assembler or ABIs or Clisp. So far I've managed to get just one piece, avcall, passing its unit tests. Maybe this will give some pointers to anyone else who wants to have a go.

Code:
apt-get source libffcall1
wget http://mat.exon.name/ffcall-arm.diff
patch -p0 < ffcall-arm.diff
make -C ffcall-1.10+2.41/ffcall/avcall -f Makefile.devel avcall-arm.S
make -C ffcall-1.10+2.41/ffcall/callback/vacall_r -f Makefile.devel vacall-arm.S
make -C ffcall-1.10+2.41/ffcall/vacall -f Makefile.devel vacall-arm.S
cd ffcall-1.10+2.41/ffcall
./configure
make extracheck
This should pass avcall, and then fail on vacall which I haven't started yet.

As far as I've been able to make out, the main changes are:
  • doubles and long longs have 8-byte alignment, previously it was 4
  • 8-byte structs are no longer considered "small", and are passed on the stack
  • chars in structs are aligned left, rather than being promoted to ints
  • as a result, it's necessary to round up the number of words being passed in registers
Also, I can't figure out how the whole build system is supposed to work, so I just hacked it to make it work. The tarball comes with pre-generated assembler which doesn't seem to have been regenerated since gcc 2.6.3, and this assembler doesn't compile under armel. There's a Makefile.devel to rebuild, but then it passes the assembler through a wacky sed script which strips out some underscores for some reason, and this fails too. So I had to hack the sed script as well. I guess someone out there understands how this is all supposed to work, but I'm just happy to get it passing its unit tests.