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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Sam Ravnborg <sam@...>
Cc: Alistair John Strachan <alistair@...>, Chris Knadle <Chris.Knadle@...>, Andrew Morton <akpm@...>, Adrian Bunk <bunk@...>, <venkatesh.pallipadi@...>, <davem@...>, <trini@...>, <mingo@...>, <tglx@...>, <hpa@...>, <linux-kernel@...>, <suresh.b.siddha@...>, Linus Torvalds <torvalds@...>
Date: Friday, May 2, 2008 - 10:11 am

On Fri, May 02, 2008 at 03:57:08PM +0200, Sam Ravnborg wrote:

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
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: huge gcc 4.1.{0,1} __weak problem, Chris Knadle, (Thu May 1, 7:55 pm)
Re: huge gcc 4.1.{0,1} __weak problem, Alistair John Strachan, (Fri May 2, 5:55 am)
Re: huge gcc 4.1.{0,1} __weak problem, Sven-Haegar Koch, (Fri May 2, 8:40 am)
Re: huge gcc 4.1.{0,1} __weak problem, Sam Ravnborg, (Fri May 2, 6:43 am)
Re: huge gcc 4.1.{0,1} __weak problem, Alistair John Strachan, (Fri May 2, 7:48 am)
Re: huge gcc 4.1.{0,1} __weak problem, Sam Ravnborg, (Fri May 2, 9:57 am)
Re: huge gcc 4.1.{0,1} __weak problem, Jeremy Fitzhardinge, (Fri May 2, 10:57 am)
Re: huge gcc 4.1.{0,1} __weak problem, Jakub Jelinek, (Fri May 2, 10:11 am)
Re: huge gcc 4.1.{0,1} __weak problem, Alistair John Strachan, (Fri May 2, 11:26 am)
Re: huge gcc 4.1.{0,1} __weak problem, Miquel van Smoorenburg, (Fri May 2, 5:19 am)