[cfe-dev] Weak aliases on OSX

Martin Whitaker mailing-list at martin-whitaker.me.uk
Mon Sep 26 10:09:27 PDT 2011


Douglas Gregor wrote:
>
> On Sep 25, 2011, at 3:15 AM, Martin Whitaker wrote:
>
>> Hi,
>>
>> On another open source project I work on, one of our users is trying to build
>> the code for OSX 10.7 using clang. This is failing on the following piece of code:
>>
>> PLI_INT32 tf_getlongtime(PLI_INT32 *high)
>> {
>>        return tf_igetlongtime(high, 0);
>> }
>>
>> PLI_INT32 tf_getlongsimtime(PLI_INT32 *high) \
>>        __attribute__ ((weak, alias ("tf_getlongtime")));
>>
>> clang gives the following error:
>>
>> getsimtime.c:88:29: error: only weak aliases are supported on darwin
>> __attribute__ ((weak, alias ("tf_getlongtime")));
>> ^
>>
>> Looking at the clang source code, it appears to reject any form of alias when
>> targeting darwin. So is the error message wrong, or is there an alternative
>> way to create a weak alias that works for darwin?
>
>
> I think the correct alternative is the weakref attribute documented here:
>
> 	http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
>
> 	- Doug

Thanks for the reply. However, weakref can only be attached to a static 
declaration, so I don't see how it can be used to provide the required 
functionality - exporting a weak symbol. Am I missing something?

Martin

P.S. I should have added that the original code does build on OSX 10.6 using 
gcc, which suggests this is a clang limitation, not a darwin one.



More information about the cfe-dev mailing list