[cfe-commits] r66270 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/attributes.c

Daniel Dunbar daniel at zuster.org
Fri Mar 6 09:59:41 PST 2009


On Fri, Mar 6, 2009 at 9:28 AM, Chris Lattner <clattner at apple.com> wrote:
> On Mar 6, 2009, at 8:20 AM, Daniel Dunbar wrote:
>> +    } else if (D->getAttr<WeakAttr>() ||
>> +               D->getAttr<WeakImportAttr>()) {
>> +      // "extern_weak" is overloaded in LLVM; we probably should have
>> +      // separate linkage types for this.
>
> What is the issue here?

Assuming I understand reality correctly, which is unlikely:

weak (for extern declarations) and weak_import have slightly different
semantics. This relates to Darwin using a two level namespace.
weak_import means resolve this symbol at link time but allow it to be
absent at runtime. weak (for extern declarations, on Linux) means
resolve this symbol at runtime (and allow it to be absent).

It works out in practice, since Darwin only support weak_import, and
Linux et al only support weak, so extern_weak happens to work
appropriately on the respective platforms. However, it would in theory
be nice to have the semantics at the LLVM level be more defined.

Nick has some good suggestions about how LLVM linkage types could be
improved here:
<rdar://problem/5684011> llvm should not generate 'weak global' for commons
Seems like we should get that information out publicly?

 - Daniel

> -Chirs
>




More information about the cfe-commits mailing list