Bug 29826 - __attribute__ dllimport makes optimization crash on cygwin
Summary: __attribute__ dllimport makes optimization crash on cygwin
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 27924 31275 31347 31457 31595 (view as bug list)
Depends on: 27924
Blocks:
  Show dependency treegraph
 
Reported: 2006-11-14 09:03 UTC by Denis Excoffier
Modified: 2007-04-23 20:51 UTC (History)
6 users (show)

See Also:
Host:
Target: i686-pc-cygwin
Build:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2006-11-25 03:08:35


Attachments
Patch for testcase in 31636 (506 bytes, patch)
2007-04-22 02:01 UTC, Danny Smith
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Excoffier 2006-11-14 09:03:48 UTC
the exact version of GCC is 4.1.1
the system type is i686-pc-cygwin
the options given when GCC was configured/built:
  --prefix=/tmp/local/unixutil/gcc-4.1.1
  --with-local-prefix=/usr/local/myCompanyName
  ("myCompanyName" is not the exact wording)
  (also, there is a symlink /tmp/local/unixutil/gcc -> gcc-4.1.1)
the complete command line that triggers the bug:
  /tmp/local/unixutil/gcc/bin/gcc -O -Wall -Wextra -c zim.c
the compiler output (error messages, warnings, etc.):
  stdout: nothing
  stderr:
    zim.c: In function 'ffff':
    zim.c:16: error: unrecognizable insn:
    (insn 20 19 21 2 (set (reg:SI 66)
            (const:SI (plus:SI (mem:SI (symbol_ref:SI ("#i.vvvv") <var_decl 0x194500b0 vvvv>) [0 S4 A8])
                    (const_int 4 [0x4])))) -1 (nil)
        (nil))
    zim.c:16: internal compiler error: in extract_insn, at recog.c:2084
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <URL:http://gcc.gnu.org/bugs.html> for instructions.
  zim.o: not created
the preprocessed file: see below
additional remarks:
  1) if "-O" is removed, all seems OK
  2) if "__attribute__((dllimport))" is removed, all seems OK
  3) if "-Wall" or "-Wextra" is removed, no change (still crash)


---zim.i-----------------------------------------------------
# 1 "zim.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "zim.c"
struct ssss {
  const char *xxxx1;
  const char *xxxx2;
};

extern __attribute__((dllimport)) struct ssss vvvv[];

int zzzz();

int ffff() {
  int i;
  for (i = 0; i < 2; i++) {
    zzzz(vvvv[i].xxxx2);
  };
  return(0);
};
-------------------------------------------------------------
Comment 1 Denis Excoffier 2006-11-14 11:39:41 UTC
To be connected to Bug 29825.
Comment 2 Andrew Pinski 2006-11-25 02:33:21 UTC
(In reply to comment #1)
> To be connected to Bug 29825.

No that is unrelated.
Comment 3 Andrew Pinski 2006-11-25 02:37:29 UTC
This is related to PR 27924 and I bet really a dup.
Comment 4 Andrew Pinski 2006-11-25 03:08:35 UTC
Confirmed.
Comment 5 Andrew Pinski 2006-11-25 04:13:59 UTC
*** Bug 27924 has been marked as a duplicate of this bug. ***
Comment 6 Danny Smith 2007-02-22 01:32:06 UTC
This testcase and the one in 27924 now compile successfully on

gcc version 4.2.0 20070218 (prerelease)
and
gcc version 4.3.0 20070218 (experimental)

on i686-pc-mingw32
Danny
Comment 7 Andrew Pinski 2007-03-20 15:20:05 UTC
*** Bug 31275 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2007-03-20 15:21:36 UTC
Fixed.
Comment 9 Andrew Pinski 2007-03-25 18:20:05 UTC
*** Bug 31347 has been marked as a duplicate of this bug. ***
Comment 10 Danny Smith 2007-04-03 09:54:21 UTC
*** Bug 31457 has been marked as a duplicate of this bug. ***
Comment 11 arcangelpip 2007-04-05 13:21:23 UTC
I'm sorry to drag this back up again, but it happened again on 4.2.
Again it is with the gettext package which seems to love me so much.

Using built-in specs.
Target: i686-pc-mingw32
Configured with: ../gcc-4.2/configure --prefix=/crosstools/gccwin --target=i686-pc-mingw32 --enable-shared --enable-threads --disable-multilib --disable-nls --enable-languages=c,c++,ada,fortran,objc,obj-c++ --enable-c99 --enable-long-long --enable-sjlj-exceptions --enable-libada --enable-boehm-gc
Thread model: win32
gcc version 4.2.0 20070403 (prerelease)

It ICEs with the following.

make[4]: Entering directory `/mnt/hd2/build/gettextbuild/gettext-tools/src'
/bin/sh ../libtool --tag=CC   --mode=compile i686-pc-mingw32-gcc -DLOCALEDIR=\"/crosstools/gccwin/share/locale\" -DBISON_LOCALEDIR=\"/usr/share/locale\" -DLOCALE_ALIAS_PATH=\"/crosstools/gccwin/share/locale\" -DUSEJEXE=0 -DGETTEXTJEXEDIR=\"/crosstools/gccwin/lib/gettext\" -DGETTEXTJAR=\"/crosstools/gccwin/share/gettext/gettext.jar\" -DLIBDIR=\"/crosstools/gccwin/lib\" -DGETTEXTDATADIR=\"/crosstools/gccwin/share/gettext\" -DPROJECTSDIR=\"/crosstools/gccwin/share/gettext/projects\" -DHAVE_CONFIG_H -I. -I.. -I../../../gettext-0.16.1/gettext-tools/src  -I. -I../../../gettext-0.16.1/gettext-tools/src -I.. -I../../../gettext-0.16.1/gettext-tools -I../../../gettext-0.16.1/gettext-tools/libgrep -I../../../gettext-0.16.1/gettext-tools/libuniname -I../gnulib-lib -I../../../gettext-0.16.1/gettext-tools/gnulib-lib -I../intl -I../../../gettext-0.16.1/gettext-tools/../gettext-runtime/intl -I/crosstools/gccwin/include  -g -O2 -c -o msgl-check.lo ../../../gettext-0.16.1/gettext-tools/src/msgl-check.c
 i686-pc-mingw32-gcc -DLOCALEDIR=\"/crosstools/gccwin/share/locale\" -DBISON_LOCALEDIR=\"/usr/share/locale\" -DLOCALE_ALIAS_PATH=\"/crosstools/gccwin/share/locale\" -DUSEJEXE=0 -DGETTEXTJEXEDIR=\"/crosstools/gccwin/lib/gettext\" -DGETTEXTJAR=\"/crosstools/gccwin/share/gettext/gettext.jar\" -DLIBDIR=\"/crosstools/gccwin/lib\" -DGETTEXTDATADIR=\"/crosstools/gccwin/share/gettext\" -DPROJECTSDIR=\"/crosstools/gccwin/share/gettext/projects\" -DHAVE_CONFIG_H -I. -I.. -I../../../gettext-0.16.1/gettext-tools/src -I. -I../../../gettext-0.16.1/gettext-tools/src -I.. -I../../../gettext-0.16.1/gettext-tools -I../../../gettext-0.16.1/gettext-tools/libgrep -I../../../gettext-0.16.1/gettext-tools/libuniname -I../gnulib-lib -I../../../gettext-0.16.1/gettext-tools/gnulib-lib -I../intl -I../../../gettext-0.16.1/gettext-tools/../gettext-runtime/intl -I/crosstools/gccwin/include -g -O2 -c ../../../gettext-0.16.1/gettext-tools/src/msgl-check.c  -DDLL_EXPORT -DPIC -o .libs/msgl-check.o
../../../gettext-0.16.1/gettext-tools/src/msgl-check.c: In function 'plural_help':
../../../gettext-0.16.1/gettext-tools/src/msgl-check.c:195: error: unrecognizable insn:
(insn 40 39 41 6 ../../../gettext-0.16.1/gettext-tools/src/msgl-check.c:180 (set (reg:SI 76)
        (const:SI (plus:SI (mem:SI (symbol_ref:SI ("#i.plural_table") <var_decl 0x402449f8 plural_table>) [0 S4 A8])
                (const_int 4 [0x4])))) -1 (nil)
    (nil))
../../../gettext-0.16.1/gettext-tools/src/msgl-check.c:195: internal compiler error: in extract_insn, at recog.c:2077
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

I configured gettext with

../gettext-0.16.1/configure --prefix=/crosstools/gccwin --build=i686-pc-linux-gnu --host=i686-pc-mingw32 --disable-java --disable-native-java --with-libiconv-prefix=/crosstools/gccwin --disable-threads --disable-openmp

If I am doing anything wrong here I'm open to suggestions.
Comment 12 Andrew Pinski 2007-04-17 16:03:07 UTC
*** Bug 31595 has been marked as a duplicate of this bug. ***
Comment 13 arcangelpip 2007-04-18 14:34:39 UTC
I'm going to try again since it seems my last post was just ignored.
The test case works fine on 4.2 but it still occurs under some circumstances.
As I stated in my previous post Gettext is where it dies but I can compile the original test case with no problems.
The compiler I am using is a linux to mingw cross compiler configured as I stated below. It was built from mondays source with a 4.2 bootstrap compiler and binutils 2.17.
To reiterate, the simple testcase works fine, but I still have this bug appear while compiling gettext using the cross compiler targetted at mingw.
Comment 14 Danny Smith 2007-04-20 07:49:16 UTC
(In reply to comment #13)
> I'm going to try again since it seems my last post was just ignored.
> The test case works fine on 4.2 but it still occurs under some circumstances.

If you provide preprocessed source that reproduces the circumstances , as suggested,  I will not ignore it.

Danny  
Comment 15 arcangelpip 2007-04-20 17:06:10 UTC
Don't you just hate idiots in these cases. (Yes, I am referring to myself here) 
Well, it's completely broken again on my system, look here.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31636

I apologise for being less than helpful here.
Comment 16 Danny Smith 2007-04-22 02:01:18 UTC
Created attachment 13403 [details]
Patch for testcase in 31636

Could you please test the attached patch to tree-ssa-address.c which is a reversal of a fragment of the reversion of the 4.2.0  TLS emulation patch.  

After I re-re-reverted this patch in my local tree, I see the ICE in your testcase.

Danny
Comment 17 arcangelpip 2007-04-23 20:51:31 UTC
Yup, that did it. Building the cross compiler with that patch fixed the test case ICE and the one I kept getting from gettext.