This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: weak-attribute over-optimisation with 4.1
- From: Tom Rini <trini at kernel dot crashing dot org>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: Jan Kiszka <jan dot kiszka at web dot de>, gcc-help at gcc dot gnu dot org
- Date: Mon, 22 May 2006 14:07:39 -0700
- Subject: Re: weak-attribute over-optimisation with 4.1
- References: <446F567B.6060101@web.de> <8764jz92sf.fsf@mid.deneb.enyo.de>
[ Please keep me on the CC list, thanks! ]
On Sun, May 21, 2006 at 10:53:52AM +0200, Florian Weimer wrote:
> * Jan Kiszka:
>
> > So, is this a regression? Does it also happen with vanilla 4.1?
>
> According to the documentation, the weak attribute affects
> declarations, not definitions, and is an instruction to the linker.
> Technically, the GCC 4.1 behavior is correct. I'm not sure if it's
> desirably, though.
I've got a few questions then, does this mean that for gcc-4.1 the
correct answer is:
1) foo.h includes weak declarations
2) foo.c does not provide any copy of the function, only calls.
3) bar.c may or may not provide the function call
4) foo.o and bar.o get linked together and we would get the desired
results (functions called if provided, otherwise we link fine and the
call goes away) ?
If so, is there a recommended way to write all of that so that gcc-3.2
will work as well (since this is code for the Linux Kernel)
Thanks!
--
Tom Rini