[Openmcl-devel] Interface translator for x86-64 Darwin, finally

Gary Byers gb at clozure.com
Sun May 13 15:14:16 UTC 2007

On Sun, 13 May 2007, Gary Byers wrote:

> Another approach - which avoids the question of whether a useful
> answer would come back from DTS before October - would be to
> make a Leopard-aware version of the interface translator available
> (all of that's based on (GPLed) source that Apple release and/or
> is available in GCC's SVN repo) and make it easier for Leopard
> users to generate their own interfaces.
> Whether anyone (preferably someone with a "good attitude") talks to
> Apple about legal issues related to distributing Leopard interfaces,
> this should be done; it happens to also provide a way of avoiding
> those legal issues entirely (since it provides a means for Leopard
> users to generate their own interfaces.)
> I'll do this (as I've been alternately threatening/avoiding for 6
> months or so.)

I uploaded:

ffigen-for-apple-gcc-5363.tar.gz - "source" (makefile + patch to Apple's
ffigen-apple-gcc-5363-x86-64.tar.gz - binary compiled on x86-64 Tiger



In order to use the former, you need a copy of Apple's "gcc-5363.tar.gz"
archive; it's available from


"gcc-5363" is Apple's build of a GCC pretty similar to what ships with
current versions of XCode for Tiger (the version that I have installed
on a Tiger claims to be build 5367.)

If you un-tar "ffigen-for-apple-gcc-5363.tar.gz", you'll find that it
expands into a directory named "ffigen-for-apple-gcc-5363" which
contains a Makefile, a fairly large patch (diff), and a copy of the
"h-to-ffi.sh" driver script used in the FFI translator.

If you copy the gcc source archive into that directory and invoke
"make" in that directory, the Makefile will:

- un-tar the gcc-5363.tar.gz archive into a "gcc-5363" subdirectory
- apply a fairly large patch to the gcc-5363 sources.  The patch
   includes the FFI generation changes as well as code that Apple
   comitted to the GCC SVN tree to support ObjC 2.0 and some related
   parsing changes (I don't know/remember all of the details, but
   it seems that the Apple changes allow the __attribute__ keyword
   to be used in different contexts than it had been allowed in even
   when ObjC 2.0 isn't enabled.)  I don't know that I'd trust the
   merged compiler to actually generate reasonable code, but it does
   seem to handle the job of translating both Leopard and Tiger
   C header files into equivalent .ffi files.
- create a temporary "build" directory and configure and build
   the ObjC compiler from the patched sources.  (Since ObjC is
   a superset of C, the same compiler frontend can be used to parse C
   and ObjC header files.)
- create "bin" and "ffigen" directories, copying the "h-to-ffi.sh"
   script to bin and the modified compiler and compiler-specific
   header files to the "ffigen" directory.
- create a compressed tarball containing "bin" and "ffigen".  If
   this extracted into someplace that has a "bin" directory that
   on your shell's search path (e.g., /usr/local if you've created
   that hierarchy and have /usr/local/bin on your path), it should
   work without modification; if the "bin" and "ffigen" directories
   things are installed in aren't siblings, you'll need to modify
   h-to-ffi.sh so that it can find the "ffigen" directory.

ffigen-apple-gcc-5363-x86-64.tar.gz is the end result, as produced
on an x86-64 Tiger system.  I believe that something built on Tiger
will generally run on Leopard, though it may not be the case that
Leopard binaries will run on Tiger unless special steps are taken.
(There hasn't been any version of the FFI translator for x86-64
Tiger up to this point.)

Unless I botched something (I didn't test it and may have), the
same build process should work on PPC Leopard.  (It was once
necessary to say that you wanted a biarch compiler when building
on PPC, and I'm not sure if the Makefile does that.)  At least one
of the patched source files is sensitive to differences between
Tiger and Leopard, and I didn't try to do anything to hide those
differences.  The existing version of the ffi translator should
continue to work under Tiger, and this version would only be interesting
to people using Leopard (and needing the ObjC 2.0 support).

More information about the Openmcl-devel mailing list