Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 25461 - openssl-0.9.7b CRASHES gcc 3.3-r1 when -march in CFLAGS
Summary: openssl-0.9.7b CRASHES gcc 3.3-r1 when -march in CFLAGS
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Daniel Ahlberg (RETIRED)
URL:
Whiteboard:
Keywords:
: 25518 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-07-28 15:19 UTC by Boyd Waters
Modified: 2003-09-17 05:16 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to openssl-0.9.7b.ebuild to correct compiler flags (openssl-0.9.7b-gcc3.3.1.patch,781 bytes, patch)
2003-07-28 15:20 UTC, Boyd Waters
Details | Diff
Compiler output that caused gcc to crash (long) (cck3AK1G.out,53.92 KB, text/plain)
2003-07-28 15:23 UTC, Boyd Waters
Details
fprefetch-loop-arrays filter flag (openssl-0.9.7b.diff,566 bytes, patch)
2003-08-01 11:31 UTC, Mario Vazquez
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Boyd Waters 2003-07-28 15:19:24 UTC
gcc (GCC) 3.3 20030718 (Gentoo Linux 3.3-r1, propolice) 
 
When building openssl-0.9.7b on my Pentium3 (coppermine) machine, I get 
openssl-0.9.7b/crypto/mem_clr.c: internal compiler error: Floating point exception 
 
(I will attach the intermediate output from cpp for reporting to GCC maintainers) 
 
I have narrowed this one down to a "collision" between the "-march=pentium3" switch 
that I specified in my CFLAGS and the switch hard-coded into the openSSL configure 
system: "-mcpu=pentium". 
 
Attached is a patch to the ebuild which removes the -mcpu optimization if -march is in 
CFLAGS. This worksforme. 
 
(This is more properly a GCC bug, but it arises because of a peculiarity in the openSSL 
build, so I fix the openSSL ebuild...) 
 

Reproducible: Always
Steps to Reproduce:
1.
2.
3.



This occurred in a stage2 installation; after bootstrap.sh I emerged gcc-3.3-r1 before 
proceeding with a "emerge system".
Comment 1 Boyd Waters 2003-07-28 15:20:54 UTC
Created attachment 15155 [details, diff]
Patch to openssl-0.9.7b.ebuild to correct compiler flags
Comment 2 Boyd Waters 2003-07-28 15:23:00 UTC
Created attachment 15156 [details]
Compiler output that caused gcc to crash (long)

This is the file that the crash report from GCC instructed me to report to the
GCC maintainers.
Comment 3 Mario Vazquez 2003-08-01 11:10:28 UTC
got same error, but fix it by filtering -fprefetch-loop-arrays flag.
After that, compiles fine, and no change to -march  (which BTW, I use -march=pentium4)


Comment 4 Mario Vazquez 2003-08-01 11:31:35 UTC
Created attachment 15335 [details, diff]
fprefetch-loop-arrays filter flag

filter -fprefetch-loop-arrays flag to enable gcc-3.3 compilation
Comment 5 Boyd Waters 2003-08-06 14:33:17 UTC
I can compile openssh by removing the mcpu flag if-and-only-if the march flag is specified in CFLAGS -- which means that you can keep the -fprefetch-loop-arrays flag.

Did my new ebuild not work for you? I am using Pentium III (x86 coppermine).
Comment 6 Martin Schlemmer (RETIRED) gentoo-dev 2003-08-21 13:13:37 UTC
Its the combination with then the mismatched -march and -mcpu ... :

--------------------------------------------------------------------
azarah@nosferatu tmp $ cat t1.c
#include <string.h>
 
unsigned char cleanse_ctr = 0;
void *ptr;
size_t len;
                                                                                                                            
void cleanse(void *ptr, size_t len)
{
        unsigned char *p = ptr;
        size_t loop = len;
        while(loop--) {
                *(p++) = cleanse_ctr;
                cleanse_ctr += (17 + (unsigned char)((int)p & 0xF));
        }
        if(memchr(ptr, cleanse_ctr, len)) {
                cleanse_ctr += 63;
        }
}
 
 
azarah@nosferatu tmp $ gcc -c t1.c -march=pentium3 -mcpu=pentium -O2 -fprefetch-loop-arrays
t1.c: In function `cleanse':
t1.c:18: internal compiler error: Floating point exception
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.
Preprocessed source stored into /tmp/cc6DARhi.out file, please attach this to your bugreport
azarah@nosferatu tmp $ gcc -c t1.c -march=pentium3 -mcpu=pentium3 -O2 -fprefetch-loop-arrays
azarah@nosferatu tmp $ gcc -c t1.c -march=pentium3 -mcpu=pentium2 -O2 -fprefetch-loop-arrays
azarah@nosferatu tmp $ gcc -c t1.c -march=pentium2 -mcpu=pentium -O2 -fprefetch-loop-arrays
cc1: warning: -fprefetch-loop-arrays not supported for this target (try -march switches)
azarah@nosferatu tmp $ gcc -c t1.c -march=pentium4 -mcpu=pentium -O2 -fprefetch-loop-arrays
t1.c: In function `cleanse':
t1.c:18: internal compiler error: Floating point exception
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.
Preprocessed source stored into /tmp/ccQT53sX.out file, please attach this to your bugreport
azarah@nosferatu tmp $
Comment 7 Boyd Waters 2003-08-21 17:38:52 UTC
Yes, that is clear to me. 

See the first patch of this bug which modifies the ebuild to fix this. It has little or nothing to do with prefetch-loop-arrays, I think. Or maybe prefetch-loop-arrays triggers it too.

Anyway, I think my first patch should be applied.
Thanks!
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2003-08-21 21:13:08 UTC
Right, but -march=foo imply -mcpu=foo, so I do not know how valid it is
to not set them the same, or at least set -mcpu lower than -march ....
Comment 9 Boyd Waters 2003-08-22 12:04:12 UTC
Yes, that's correct.

So my patch modifies the ebuild so that the -mcpu flag is REMOVED IFF -march is defined in CFLAGS. This would avoid any conflict, between the two flags, I think.

Comment 10 SpanKY gentoo-dev 2003-08-22 12:08:29 UTC
why not always patch it out ... that way if user wants to use debug flags or
whatever, they dont have to worry about it
Comment 11 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-06 20:20:08 UTC
Its an option, but we should submit to the gcc guys as a bug.  I will try
to do that somewhere tomorrow.  Here is the latest version of the code that
cause the issue (more compact):

-------------------------------------
void foofunc(void *ptr, int len)
{
        unsigned char *p = (char *)ptr;
        unsigned char ctr = 0;
        int loop = len;
                                                                                                                            
        while(loop--)
                *(p++) = ctr;
}
Comment 12 Daniel Ahlberg (RETIRED) gentoo-dev 2003-09-17 00:29:16 UTC
*** Bug 25518 has been marked as a duplicate of this bug. ***
Comment 13 Daniel Ahlberg (RETIRED) gentoo-dev 2003-09-17 05:16:20 UTC
OpenSSL 0.9.7b-r2 commited.