Libffi problem on darwin (MacOSX)

Ronald Oussoren oussoren@cistron.nl
Fri May 16 20:56:00 GMT 2003


Hi,

The libffi mailing seems to be dead, hence my post here. I'm using  
libffi to interface Python and Objective-C (http://pyobjc.sf.net). This  
is working pretty well, but I'm running into a problem that seems to be  
libffi related.

We're using libffi closures in the Objective-C method tables to forward  
calls from Objective-C to python. This is working fine for basic calls,  
but gives wrong results when structs are passed. It looks like a  
mismatch between the compiler and libffi: ffi_closure_helper_DARWIN in  
libffi_darwin.c seems to assume that structs are passed "by reference"  
(line 615), while the compiler passes small structs entirely in  
registers (see assembly code emited by the following C snippet):

struct foobar {
         float a;
         int b;
};

extern struct foobar h;
extern int i;


void callee(struct foobar a1, int a2)
{
}

void caller(void)
{
         struct foobar g = { 1.0, 2.0 };
         callee(g, 42);
}


The compiler behaviour seems to be the same as prescribed by 'Mach-O  
runtime conventions on PowerPC'  
(http://developer.apple.com/techpubs/macosx/DeveloperTools/ 
MachORuntime/2rt_powerpc_abi/index.html).

I'm using Apple's version of GCC 3.1 and a libffi from the GCC  
repository (HEAD branch). I've disabled the eh_frames in darwin*.S  
(otherwise this version of libffi won't work with Apple's GCC), but  
otherwise it's the same as in CVS.

Ronald



More information about the Gcc mailing list