[cfe-dev] Hack for FreeBSD ABI support

Anton Korobeynikov anton at korobeynikov.info
Sun Aug 16 05:45:39 PDT 2009


Hello, Everyone

> There may be some differences between Darwin and FreeBSD (in particular in
> vector handling, which I didn't test), but with clang using the Darwin ABI I
> have programs compiled with Clang linking against AppKit compiled with gcc,
> Foundation compiled with Clang and other frameworks compiled with gcc and
> working without issue.
That's rather strange since freebsd folks definitely test the normal
ELF ABI and never complained about this :) The only difference between
linux / freebsd found in gcc sources is DEFAULT_PCC_STRUCT_RETURN
define, which is set to 1 on linux and 0 on bsd. The description is:

@defmac DEFAULT_PCC_STRUCT_RETURN
Define this macro to be 1 if all structure and union return values must be
in memory.  Since this results in slower code, this should be defined
only if needed for compatibility with other compilers or with an ABI at .
If you define this macro to be 0, then the conventions used for structure
and union return values are decided by the @code{TARGET_RETURN_IN_MEMORY}
target hook.

If not defined, this defaults to the value 1.
@end defmac

So, BSD definitely does not use Darwin ABI (and darwin does not use
BSD ABI :) ). The hook TARGET_RETURN_IN_MEMORY can be found in
gcc/config/i386.c under the name ix86_return_memory(). The single use
of the mentioned flag (pcc_struct_return) is in
gcc/function.c:aggregate_value_p()

Hopefully this will provide enough information for proper implementation

-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University



More information about the cfe-dev mailing list