This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] GCC tree linkage types
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Chris Lattner <sabre at nondot dot org>
- Cc: Matt Austern <austern at apple dot com>, gcc at gcc dot gnu dot org, Gabriel Dos Reis <gdr at integrable-solutions dot net>, Richard Henderson <rth at redhat dot com>
- Date: 06 Nov 2003 23:36:36 -0500
- Subject: Re: [C++] GCC tree linkage types
- References: <Pine.LNX.4.44.0311061607210.6778-100000@nondot.org>
Chris Lattner <sabre@nondot.org> writes:
> In LLVM, we currently have the following linkage types:
>
> * internal linkage (ie, static)
> * linkonce (globals which merge when linking, but can be deleted from a
> translation unit if they are not used, basically like 'extern inline').
I would normally say that linkonce means that all but one copy can be
deleted. It may be that the way gcc uses linkonce ensures that it is
OK to delete all copies, but it is logically possible to make a global
constructor linkonce, and it would not be OK to delete that even if
nothing referred to it.
> * weak (like linkonce, but cannot be deleted if they are unused in a
> xlation unit)
I wouldn't say that weak symbols merge; I would say that weak symbols
are hidden by strong symbols, or by earlier weak symbols.
> * external (normal strong, externally visible symbol)
>
> Is there anything wrong with this classification of linkage types? Is
> there something we are missing?
You didn't mention common symbols, which really do merge. Even g++
can generate common symbols when using the -fconserve-space option.
The GNU linker supports more exotic linkage types like `indirect',
`warning', and `set'. But these are probably not of interest to the
compiler.
Ian