[cfe-dev] Hack for FreeBSD ABI support

David Chisnall csdavec at swansea.ac.uk
Mon Aug 17 11:02:47 PDT 2009


On 17 Aug 2009, at 06:36, Anton Korobeynikov wrote:

> Hello, Eli
>
>> Note that by "ABI" here only includes the calling convention, and  
>> that
>> makes it sound like FreeBSD is a lot closer to the Darwin calling
>> convention than the Linux one...
> But vector stuff is purely linux, so I'd say - "something in the  
> middle" :)

The attached patch is a bit less of an hack.  It changes the isDarwin  
flag to specify whether we should use the Darwin calling convention  
for vectors (I don't think this calling convention is used elsewhere,  
but it might be...) and adds a second flag to specify whether small  
structures are returned in registers or on the stack.  This is set to  
true for FreeBSD and Darwin and no for other operating systems (I've  
no idea what it should be for Net/OpenBSD; someone with access to  
these operating systems on x86 should run my test program and see if  
it breaks with current clang compiling one file and gcc compiling the  
others).  Since DragonFly is a fork of Free, I believe it should also  
have this flag set, but (again) I don't have a machine I can test this  
on.  I'm a bit surprised no one running FreeBSD or DragonFly BSD has  
encountered this problem before...  Apparently it's also the default  
on MinGW, so maybe this test should be inverted; it seems that only  
GNU/Linux defaults to returning these structures on the stack, so  
possibly we should just test for "linux" in the triple and clear the  
flag in this case?

This second flag should, in future, be overridden by the -fpcc-struct- 
return / -freg-struct-return flags.  These are used by GCC to override  
the host platform calling convention, so they're not widely used  
(although there's a kernel by some Finnish guy which apparently uses - 
freg-struct-return).

With this applied, I believe we get the correct calling convention for  
everything on FreeBSD.  Please let me know if it breaks any other  
platforms before I commit (and if anyone wants to let me know what the  
correct values are for other *BSDs, I'll integrate those at the same  
time).

David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.diff
Type: application/octet-stream
Size: 2448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090817/992c9e02/attachment.obj>
-------------- next part --------------



More information about the cfe-dev mailing list