[cfe-dev] Weak linkage for inline

Argiris Kirtzidis akyrtzi at gmail.com
Fri Jun 27 09:53:09 PDT 2008


Eli Friedman wrote:
> On Fri, Jun 27, 2008 at 4:21 AM, Argiris Kirtzidis <akyrtzi at gmail.com> wrote:
>   
>> Hi,
>>
>> This test case:
>>
>> inline void f(void) {}
>>
>> when compiled with llvm-gcc, produces this output:
>>
>> define void @f() nounwind  {
>>
>> but when compiled with clang, this output:
>>
>> define weak void @f() {
>>
>>
>> Should clang mirror llvm-gcc and not use 'weak' linkage for inline
>> functions ?
>>     
>
> The correct comparison is with llvm-gcc -std=c99.  clang is in fact
> wrong here, but it's a bit more complicated.
>   

Can we change it to 'linkonce' until the correct semantics are in place ?
The issue with 'weak' is that the inliner leaves it untouched and this 
section is produced in the assembly output:

    .section    .llvm.linkonce.t._f,"ax", at progbits

which is ELF specific, is this correct ?


-Argiris



More information about the cfe-dev mailing list