Bug#289884: Problem with compiler optimization (now with a patch)
On Sunday 30 May 2010 22:35:49 Niko Tyni wrote: > On Thu, May 27, 2010 at 08:29:14AM +0200, Marc Pignat wrote: ... > All my tests indicate that your solution works, so I intend to include > it in the next upload soon and notify upstream when we've verified the > bug is actually fixed with the new packages. The test attached with the bug report (md5.pl) runs fine on my (armel) n2100 using this patch. pooky:/tmp# perl ./md5.pl 1..14 ok 1 ok 2 ok 4 ok 10 ok 11 Best regards Marc -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#289884: Problem with compiler optimization (now with a patch)
On Thu, May 27, 2010 at 08:29:14AM +0200, Marc Pignat wrote: > Only the -O0 fails... the compiler seems to have optimized away most of our > test!!! > > My proposed solution is to use the 'volatile' keyword to make sure the > compiler > will really do the job. > > Please note that it does not work with -O3, but the configure script compile > with > -O2, so this should be fine. I'd love to have a fix that works with -O3 too, but that may be better to resolve upstream. Making the test program depend on its input (arguments, stdin or whatever) should help, but as Configure is actually a generated file, I assume some things are easier to implement than others. Meanwhile, I'll use the 'volatile' solution and hope that gcc -O2 doesn't become more aggressive soon. I wonder if this should be considered a gcc optimization bug. > At this time I've only tested the Configure scripts, which now detects the > align problem on ARM. I'm compiling the whole thing to check if the md5 bug > goes away! All my tests indicate that your solution works, so I intend to include it in the next upload soon and notify upstream when we've verified the bug is actually fixed with the new packages. Thanks for your work on this, -- Niko Tyni nt...@debian.org -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#289884: Problem with compiler optimization (now with a patch)
Hi! I think I've found the (very bad) joke! I've extracted the code which detect alignment failures into a test/try.c, then I tried it : gcc -O0 -Wall -o try try.c && ./try write failed (efbe) pooky:~/test# gcc -O -Wall -o try try.c && ./try pooky:~/test# gcc -O1 -Wall -o try try.c && ./try pooky:~/test# gcc -O2 -Wall -o try try.c && ./try pooky:~/test# gcc -O3 -Wall -o try try.c && ./try Only the -O0 fails... the compiler seems to have optimized away most of our test!!! My proposed solution is to use the 'volatile' keyword to make sure the compiler will really do the job. Please note that it does not work with -O3, but the configure script compile with -O2, so this should be fine. At this time I've only tested the Configure scripts, which now detects the align problem on ARM. I'm compiling the whole thing to check if the md5 bug goes away! I hope this will fix this *5 years* old bug, and the upstream bug as well! Best regards Marc --- Configure |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Configure b/Configure index 01fa3c0..19327b7 100755 --- a/Configure +++ b/Configure @@ -18549,8 +18549,8 @@ $signal_t bletch(int s) { exit(4); } #endif int main() { #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321 -U8 buf[8]; -U32 *up; +volatile U8 buf[8]; +volatile U32 *up; int i; if (sizeof(U32) != 4) { -- 1.7.1 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org