[patches] Alternatives for static functions in extern C contexts

John McCall rjmccall at apple.com
Wed Feb 20 20:21:48 PST 2013


On Feb 20, 2013, at 8:00 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Wed, Feb 20, 2013 at 5:22 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Wed, Feb 20, 2013 at 3:19 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
> Ping. Any preferences?
> 
> Both patches seem like an improvement on the status quo to me. I'm waiting to hear opinions from CWG.
> 
> OK, apparently CWG discussed and decided this 12 years ago.
> 
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#4
> 
> I wonder how much code is actually broken by mangle_static_extern_c.patch. LLVM is probably not a representative measure here -- IIRC all the hits in LLVM code were in the JITs.

Well, you have to be doing either a dynamic symbol lookup or reverse lookup.  The former's not particularly unlikely in scripting environments.  The latter seems pretty implausible — I mean, I can imagine some *hilarious* caller-inspection code doing it, but we don't need to fall over ourselves supporting that.

Of course, we're talking about static functions, so an environment trying to find it with dynamic lookup will probably have to throw __attribute__((used)) on the declaration.  I really don't want to key something like mangling or overloading on that, though!

My worry here is that nobody will actually benefit from this (your symbol tables are slightly larger! hooray!), but somebody out there might be *really* unhappy (you have to give all these functions external linkage! hooray!).  But maybe we'd get lucky and nobody would have a problem.

John.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130220/76892efe/attachment.html>


More information about the cfe-commits mailing list