Bug 112678 - gcc -O2 hangs compiler
gcc -O2 hangs compiler
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
1
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-12-27 16:52 EST by Gene Czarcinski
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version: 3.3.2-6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-02 14:12:43 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
network.i without the -O2 parameter (375.12 KB, text/plain)
2003-12-27 17:30 EST, Gene Czarcinski
no flags Details
network.i when -O2 specified and gcc hangs (402.00 KB, text/plain)
2003-12-27 17:32 EST, Gene Czarcinski
no flags Details

  None (edit)
Description Gene Czarcinski 2003-12-27 16:52:33 EST
Description of problem:
I am attempting the build the libnessus (one of three nessus packages)
on my Opteron system.  These are the 2.0.9 version of nessus.  I can
make the package(s) available (via ftp) if you need them.

These packages build, install and run properly on i386.
When I attempt to build libnessus (nessus-libraries) on x86_64, the
gcc compiler hangs compiling network.c.

In an attempt to narrow the problem, I ran things manually after doing
rpmbuild -bp -- run ./configure and make with the same operands as in
the spec file.

I have narrows the problem to compiling with "-O2" -- without this,
the compile is OK ... with it, the compiler hangs.

If I use gcc32 to compile network.c, the compile does not hang
although I get some warning messages about "cast from pointer to
integer of different size" so I am not sure just how good the result
is anyway ... mmm, I get the same warnings if I compile using gcc
3.3.2 but without -O2 (just no hang).

Version-Release number of selected component (if applicable):
Fedora Core 1 x86_64 preview
gcc 3.3.2-2

How reproducible:
every time



NOTE:  I tried to assign to 64bit_fedora@comcast.net but bugzilla
would not accept that.
Comment 1 Jakub Jelinek 2003-12-27 17:00:44 EST
Please attach preprocessed network.i (add -save-temps option to gcc
when compiling network.c) and write what exact other compiler flags
you've used to make it hang.
Comment 2 Gene Czarcinski 2003-12-27 17:29:30 EST
The only parameter difference is -O2.  Here are the two command line
entries:

with -O2:
 
gcc -pipe -I../ -DHAVE_CONFIG_H -DNESSUS_ON_SSL -I.
-I/usr/kerberos/include -DHAVE_SSL -I/usr/include/openssl
-I/home/genec/devel/redhat/BUILD/nessus-libraries/include
-I/home/genec/devel/redhat/BUILD/nessus-libraries/libpcap-nessus -g
-O2 -save-temps  -pipe -c network.c  -fPIC -DPIC -o .libs/network.lo
 
without -O2:
gcc -pipe -I../ -DHAVE_CONFIG_H -DNESSUS_ON_SSL -I.
-I/usr/kerberos/include -DHAVE_SSL -I/usr/include/openssl
-I/home/genec/devel/redhat/BUILD/nessus-libraries/include
-I/home/genec/devel/redhat/BUILD/nessus-libraries/libpcap-nessus -g
-save-temps  -pipe -c network.c  -fPIC -DPIC -o .libs/network.lo

Since the network.i output is different for the -O2 and non-O2 cases,
I am attaching both.

Comment 3 Gene Czarcinski 2003-12-27 17:30:57 EST
Created attachment 96708 [details]
network.i without the -O2 parameter
Comment 4 Gene Czarcinski 2003-12-27 17:32:12 EST
Created attachment 96709 [details]
network.i when -O2 specified and gcc hangs
Comment 5 Gene Czarcinski 2003-12-29 07:02:01 EST
I ran some additional tests.

Using the general form of "gcc -c -o xxx" and either of the attached
files ..

With nothing or -O1 specified, it takes about 1 second to compile.

With -O2, -O3, or -Os, the compile hangs.
Comment 6 Gene Czarcinski 2003-12-29 09:03:18 EST
The compile (-O2) also works OK when these files are compiled on a
dual Athlon for the network.i generated by -O2 on the Opteron x86_64
system.
Comment 7 Jakub Jelinek 2003-12-29 10:34:35 EST
Simplified to:
extern int f1 (int, void *);
extern int *f2 (void) __attribute__ ((__const__));
extern int f3 (int, void *);

int
test (int x, char *y, int z)
{
  int b = 0;

  if (x < 1024)
    {
      y[0] = '\0';

      do
        {
          switch (f1 (x, y + b))
            {
            case -1:
              if (b == 0)
                return -1;
              else
                return b;

            default:
              b++;
            }
        }
      while (y[b - 1] != '\0' && y[b - 1] != '\n' && b < z);
    }
  else
    {
      do
        {
          switch (f3 (x, y + b))
            {
            case -1:
              if ((*f2 ()) == 4)
                continue;
              if (b == 0)
                return -1;
              else
                return b;

            default:
              b++;
            }
        }
      while (y[b - 1] != '\0' && y[b - 1] != '\n' && b < z);
    }
  return b;
}
Comment 8 Jakub Jelinek 2003-12-30 10:22:09 EST
http://gcc.gnu.org/PR13521
Comment 10 Gene Czarcinski 2004-01-07 20:19:51 EST
1. patch works!

I took the 3.3.2-5 version of src.rpm, applied the patch (after some
fiddling but no real changes), rebuilt all of gcc and installed.  Then
I ran the rpmbuild for libnessus which had hung and it not compiles
just fine.

2.  I would appreciate it if this patch could be installed into a
"development" version of gcc since that will make it easier to
incorporate into the x86_64 version of FC1 (as an update if not in the
base).

Thanks Jakub!

Now I need to play with the nessus rpms to get it to properly handle
being on a x86_64 system (/usr/lib64, etc).
Comment 11 Gene Czarcinski 2004-01-07 20:20:52 EST
not => now
Comment 12 Justin M. Forbes 2004-02-04 15:16:05 EST
Was this patch added to the current release or testing release? 
Comment 13 Gene Czarcinski 2004-02-04 15:50:41 EST
I applied the above patch to gcc-3-3-2-5 and rebuild ... it fixed the
problem.

This fix has been incorporated into gcc-3.3.2-6 (last seen in
development).  I have since rebuilt gcc-3.3.2-6 (src.rpm from
development) for the x86_64 and installed it ... it also fixes the
loop problem.

I see that development currently has gcc-3.3.2-8 (which probably works
but I have not tried it).

The binaries I did are on ftp://czarc.net/pub/x86_64 ... if you need
the 3.3.2-6 src.rpm, I can upload it.

When I get a change, I will rebuild to gcc-3.3.2-8.

BTW, you need glibc-devel for the i386(!!) to build gcc.  Since that
is true, it probably should be part of the distribution.

Note You need to log in before you can comment on or make changes to this bug.