lkml.org 
[lkml]   [2008]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: huge gcc 4.1.{0,1} __weak problem
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. With buggy gcc it will be optimized
to
void __attribute__((weak)) func (void)
{
}

int main ()
{
return 0;
}

(similarly how all recent gccs optimize this without the weak attribute)
while non-buggy gcc keeps the func call.
So, you either need to grep the assembly (that's what e.g. the GCC testcase
does), or you can e.g. use a runtime testcase:
extern void abort (void);
void __attribute__((weak)) func (void) { }
int main () { func (); abort (); }
in one compilation unit and
extern void exit (int);
void func (void) { exit (0); }
in another one. 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.).

Jakub


\
 
 \ /
  Last update: 2008-05-02 16:15    [W:0.061 / U:0.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site