Re: huge gcc 4.1.{0,1} __weak problem

Alistair John Strachan
2008-05-02T15:29:26Z

On Friday 02 May 2008 15:11:32 Jakub Jelinek wrote:
> On Fri, May 02, 2008 at 03:57:08PM +0200, Sam Ravnborg wrote:
> > OK, can anyone confirm that this fails to build which a
> > buggy gcc:
> >
> >
> > void __attribute__((weak)) func(void)
> > {
> > /* no code */
> > }
> >
> > int main()
> > {
> > func();
> > return 0;
> > }
>
> Of course it doesn't fail to build.
[snip]
>  I doubt a runtime testcase is acceptable though for the
> kernel, as the cross compiler used to build the kernel might not be able to
> create userland executables (missing C library, etc.).

I assume the GCC testsuite has the same generic problem, which is probably why
it uses the -fdump-tree-optimized parameter to gcc. For example:

alistair@just:~$ cat test.c
void __attribute__((weak)) func(void)
{
/* no code */
}

int main()
{
func();
return 0;
}

alistair@just:~$ gcc -O2 -fdump-tree-optimized test.c
alistair@just:~$ rm -f a.out
alistair@just:~$ cat test.c*.optimized | egrep "func \\(\\);"
func ();

Ergo, my compiler isn't buggy. As this doesn't require a runtime test I think
it would be OK for the kernel.

Of course, whether or not it's worth it is now debatable, given the
information Sven-Haegar Koch provided (Debian's GCC version number is
actually 4.1.2).

--
Cheers,
Alistair.

137/1 Warrender Park Road, Edinburgh, UK.