huge gcc 4.1.{0,1} __weak problem
Quoted 10 lines · Linus Torvalds
Quoted 8 lines · Andrew Morton
Quoted 6 lines
I see only the following choices:
- remove__weakand replace all current usages
- move all__weakfunctions into own files, and ensure that also happens for future usages
- #error for gcc 4.1.{0,1}Can we detect the {0,1}?
__GNUC_EVEN_MORE_MINOR__?
Quoted 8 lines
It's
__GNUC_PATCHLEVEL__, I believe.So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} (bad, and rather uncommon).
And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to begin with, I think it's better to just not support it.Linus
Unfortunately Debian Stable (i.e. Etch), which is relatively popular for server
use, is still using 4.1.1 :-( (The current gcc package is gcc-4.1.1-21)
I have not looked to see if Debian Stable's gcc-4.1.1-21 has been patched for
the currently discussed __weak bug.
-- Chris
Chris Knadle
[email protected]
Quoted 13 lines · Chris Knadle
Quoted 12 lines · Linus Torvalds
Quoted 8 lines · Andrew Morton
Quoted 6 lines
I see only the following choices:
- remove__weakand replace all current usages
- move all__weakfunctions into own files, and ensure that also happens for future usages
- #error for gcc 4.1.{0,1}Can we detect the {0,1}?
__GNUC_EVEN_MORE_MINOR__?It's
__GNUC_PATCHLEVEL__, I believe.
Quoted 7 lines
Quoted 4 lines
So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} (bad, and rather uncommon).
And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to begin with, I think it's better to just not support it.Unfortunately Debian Stable (i.e. Etch), which is relatively popular for server
use, is still using 4.1.1 :-( (The current gcc package is gcc-4.1.1-21)
Well the package version string is 4.1.1, but the compiler thinks it's 4.1.2, at least on i386, amd64 and ia64:
$ cc -v gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
A small test program agrees:
printf("%d\n", __GNUC_PATCHLEVEL__);
$ ./a.out
2Mike.
Hi Chris,
(I fixed the corrupted CC and Reply-to: address from your email.)
Quoted 17 lines · On Friday 02 May 2008 00:55:58 Chris Knadle wrote:
Quoted 16 lines · Linus Torvalds
Quoted 7 lines · Andrew Morton
Quoted 5 lines
I see only the following choices:
- remove__weakand replace all current usages
- move all__weakfunctions into own files, and ensure that also happens for future usages
- #error for gcc 4.1.{0,1}Can we detect the {0,1}?
__GNUC_EVEN_MORE_MINOR__?It's
__GNUC_PATCHLEVEL__, I believe.So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} (bad, and rather uncommon).
And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to begin with, I think it's better to just not support it.
Quoted 8 lines
Quoted 1 line
Linus
Unfortunately Debian Stable (i.e. Etch), which is relatively popular for
server use, is still using 4.1.1 :-( (The current gcc package is gcc-4.1.1-21)I have not looked to see if Debian Stable's gcc-4.1.1-21 has been
patched for the currently discussed__weakbug.
I checked and it has been patched in 4.1.1-21. This would make checking for 4.1.1 via __GNUC_PATCHLEVEL__ potentially invalid, as patched distro compilers may (and in this case do) have this fixed.
Signature · 4 lines
Cheers, Alistair. 137/1 Warrender Park Road, Edinburgh, UK.
Quoted 28 lines · Alistair John Strachan
Hi Chris,
(I fixed the corrupted CC and Reply-to: address from your email.)
Quoted 23 lines · On Friday 02 May 2008 00:55:58 Chris Knadle wrote:
Quoted 9 lines · Linus Torvalds
Quoted 7 lines · Andrew Morton
Quoted 5 lines
I see only the following choices:
- remove__weakand replace all current usages
- move all__weakfunctions into own files, and ensure that also happens for future usages
- #error for gcc 4.1.{0,1}Can we detect the {0,1}?
__GNUC_EVEN_MORE_MINOR__?Quoted 8 lines
It's
__GNUC_PATCHLEVEL__, I believe.So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} (bad, and rather uncommon).
And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to begin with, I think it's better to just not support it.Linus
Unfortunately Debian Stable (i.e. Etch), which is relatively popular for
server use, is still using 4.1.1 :-( (The current gcc package is gcc-4.1.1-21)
Quoted 6 lines
Quoted 2 lines
I have not looked to see if Debian Stable's gcc-4.1.1-21 has been
patched for the currently discussed__weakbug.I checked and it has been patched in 4.1.1-21. This would make checking for 4.1.1 via
__GNUC_PATCHLEVEL__potentially invalid, as patched distro compilers may (and in this case do) have this fixed.
Is it possible to cook up a small sample file we could build as part of the kernel build. If it fails => error out.
If someone comes up with the code I shall try to integrate it in the build system.
Sam
On Friday 02 May 2008 11:43:48 Sam Ravnborg wrote:
[snip]
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 8 lines
It's
__GNUC_PATCHLEVEL__, I believe.So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} (bad, and rather uncommon).
And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to begin with, I think it's better to just not support it.Linus
Unfortunately Debian Stable (i.e. Etch), which is relatively popular
for server use, is still using 4.1.1 :-( (The current gcc package is gcc-4.1.1-21)I have not looked to see if Debian Stable's gcc-4.1.1-21 has been
patched for the currently discussed__weakbug.
Quoted 8 lines
Quoted 3 lines
I checked and it has been patched in 4.1.1-21. This would make checking for 4.1.1 via
__GNUC_PATCHLEVEL__potentially invalid, as patched distro compilers may (and in this case do) have this fixed.Is it possible to cook up a small sample file we could build as part of the kernel build. If it fails => error out.
If someone comes up with the code I shall try to integrate it in the build system.
The GCC PR has a test case for this regression which might be usable.
Signature · 4 lines
Cheers, Alistair. 137/1 Warrender Park Road, Edinburgh, UK.
Quoted 22 lines · Alistair John Strachan
On Friday 02 May 2008 11:43:48 Sam Ravnborg wrote:
[snip]Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
It's
__GNUC_PATCHLEVEL__, I believe.So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} (bad, and rather uncommon).
And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to begin with, I think it's better to just not support it.Quoted 8 lines
Quoted 1 line
Linus
Unfortunately Debian Stable (i.e. Etch), which is relatively popular
for server use, is still using 4.1.1 :-( (The current gcc package is gcc-4.1.1-21)I have not looked to see if Debian Stable's gcc-4.1.1-21 has been
patched for the currently discussed__weakbug.I checked and it has been patched in 4.1.1-21. This would make checking for 4.1.1 via
__GNUC_PATCHLEVEL__potentially invalid, as patched distro compilers may (and in this case do) have this fixed.
Quoted 8 lines
Quoted 4 lines
Is it possible to cook up a small sample file we could build as part of the kernel build. If it fails => error out.
If someone comes up with the code I shall try to integrate it in the build system.The GCC PR has a test case for this regression which might be usable.
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;
}Sam
Quoted 9 lines · Sam Ravnborg
OK, can anyone confirm that this fails to build which a buggy gcc:
void __attribute__((weak)) func(void)
{ /* no code */ }
Quoted 5 lines
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
Quoted 17 lines · On Friday 02 May 2008 15:11:32 Jakub Jelinek wrote:
Quoted 9 lines · Sam Ravnborg
OK, can anyone confirm that this fails to build which a buggy gcc:
void __attribute__((weak)) func(void)
{ /* no code */ }Quoted 5 lines
int
main(){ func(); return 0; }Of course it doesn't fail to build.
[snip]
Quoted 3 lines
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).
Signature · 4 lines
Cheers, Alistair. 137/1 Warrender Park Road, Edinburgh, UK.
Quoted 9 lines · Sam Ravnborg
OK, can anyone confirm that this fails to build which a buggy gcc:
void __attribute__((weak)) func(void)
{ /* no code */ }
Quoted 6 lines
int
main(){ func(); return 0; }
I think the problem is that main() would have no call to func(), not that it wouldn't build.
Does making func noinline fix it? I wonder if we should make __weak implicitly make the function noinline too.
J
Quoted 24 lines · Alistair John Strachan
Quoted 23 lines · On Friday 02 May 2008 00:55:58 Chris Knadle wrote:
Quoted 9 lines · Linus Torvalds
Quoted 7 lines · Andrew Morton
Quoted 5 lines
I see only the following choices:
- remove__weakand replace all current usages
- move all__weakfunctions into own files, and ensure that also happens for future usages
- #error for gcc 4.1.{0,1}Can we detect the {0,1}?
__GNUC_EVEN_MORE_MINOR__?Quoted 8 lines
It's
__GNUC_PATCHLEVEL__, I believe.So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} (bad, and rather uncommon).
And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to begin with, I think it's better to just not support it.Linus
Unfortunately Debian Stable (i.e. Etch), which is relatively popular for
server use, is still using 4.1.1 :-( (The current gcc package is gcc-4.1.1-21)
Quoted 6 lines
Quoted 2 lines
I have not looked to see if Debian Stable's gcc-4.1.1-21 has been
patched for the currently discussed__weakbug.I checked and it has been patched in 4.1.1-21. This would make checking for 4.1.1 via
__GNUC_PATCHLEVEL__potentially invalid, as patched distro compilers may (and in this case do) have this fixed.
Not a problem for the Debian Stable Version, as someone already wrote, it calls itself 4.1.2, even if the package version number is 4.1.1-xx
Quoted 1 line
gcc --version
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
c'ya
sven
Signature · 2 lines
The Internet treats censorship as a routing problem, and routes around it. (John Gilmore on http://www.cygnus.com/~gnu/)