This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCC tree linkage types

--- background ---

LLVM has two different notions of "common" linkage.  The first type, which
we call "linkonce" is basically the same as a C++ inline function: it is
okay to not emit the body of a "linkonce" function if there is nothing in
the current translation unit that uses it.  Any other modules which use
the linkonce function/variable are guaranteed to have its definition.
When linking, all but one linkonce function is eliminated from the

The second type of common linkage in LLVM is called "weak" linkage.  The
linker treats this basically the same as a "linkonce" function, the
difference being that if there are no references to a "weak" function,
the function cannot be deleted.

As far as the LLVM optimizer goes, it is much better to mark things
linkonce than to mark them weak.  Unfortunately, for the 1.0 release, I
had to have everything end up being marked 'weak'.

--- GCC specific question ---

Given a FUNCTION_DECL, how do I tell if it is "linkonce"?  I used to use
DECL_DECLARED_INLINE_P(subr) to determine this, but this fails for
explicitly instantiated templates (The explicit instantiates were marked
as "linkonce", deleted by the optimizer, then resulted in unresolved

Is there any way to tell if something is an explicitly instantiated
template, or more to the point, is there a better way of getting this
information?  Likewise, for global VAR_DECL's, as far as I can tell, none
of DECL_WEAK, DECL_COMMON, or DECL_VIRTUAL_P are sufficient to tell
whether something should have linkonce linkage.

Anyone have any ideas?  Thanks in advance!



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]