I got this ICE when trying to compile the openMSX package using -flto. I managed to reduce it to this: > cat bug.ii template<typename T> struct Identity { typedef T type; }; struct S { typedef void (S::*FP)(); FP fp; }; void g(); void f() { typedef Identity<S>::type Dummy; S s; g(); } > g++-snapshot -r -nostdlib -g -flto bug.ii ... bug.ii:11:1: internal compiler error: in splice_child_die, at dwarf2out.c:8064 ... I'm using revision trunk@171714. This may or may not be a duplicate of bug 46135. Though the testcase looks very different.
Confirmed.
Same ICE now reproduces with Mozilla build
It is caused by revision 170321: http://gcc.gnu.org/ml/gcc-cvs/2011-02/msg00866.html
In the cc1plus case the type for s is already output and we return in static void gen_type_die_with_usage (tree type, dw_die_ref context_die, enum debug_info_usage usage) { ... if (TREE_ASM_WRITTEN (type)) return; that isn't the case for lto1. Called from cc1plus via #4 0x00000000009e9d25 in dwarf2out_type_decl (decl=0x7ffff5b86450, local=0) at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:21985 21985 dwarf2out_decl (decl); (gdb) #5 0x0000000000cd1e8c in rest_of_type_compilation (type=0x7ffff5b7f7e0, toplev=1) at /space/rguenther/src/svn/trunk/gcc/passes.c:230 230 debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev); (gdb) #6 0x000000000062c460 in finish_struct_1 (t=0x7ffff5b7f7e0) at /space/rguenther/src/svn/trunk/gcc/cp/class.c:5760 5760 rest_of_type_compilation (t, ! LOCAL_CLASS_P (t)); not doing that does not make us ICE the same way from cc1plus but we are outputting the type then via the Dummy typedef instead. The scope blocks look the same for cc1plus and lto1: { Scope block 0x7ffff5b42058#2 typedef struct Dummy Dummy; (unused) struct S s; (unused) } One difference is that cc1plus sees DECL_ORIGINAL_TYPE for the TYPE_DECL while lto1 does not (it's not streamed), and thus is_typedef_decl will always return false as well. I have a patch.
Created attachment 24343 [details] patch Honza, can you try this on mozilla?
It seems that we can pull in types via that link that have function-decls in them (methods) that do not have an assembler name set. But we happily enter them into symtab merging and so we ICE. See also PR48437 for a related case. Hohumm.
> Honza, can you try this on mozilla? Can try, but only after returning from Bertinoro. All connections I found here filters VPN. Honza
Hmm, so shall I still try the patch? The ICE is now more common. We used to fail twice during mozilla build, now we fail about approximately 5 different shared libraries.
On Fri, 27 May 2011, hubicka at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48354 > > --- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-05-27 21:37:46 UTC --- > Hmm, so shall I still try the patch? > The ICE is now more common. We used to fail twice during mozilla build, now we > fail about approximately 5 different shared libraries. The patch isn't complete. It at least misses walking DECL_ORIGINAL_TYPE in free-lang-data.
Created attachment 24395 [details] updated patch Updated patch containing the fld hunk. See also the dwarf2out.c commented change which might be necessary (ISTR to run into this). I also seem to remember that the gimple.c change has issues during LTO bootstrap for some reason. So, I'm not entirely happy, but somehow we have to stream DECL_ORIGINAL_TYPE.
The patch seems to work. I now get the ICE at output_die (already reported) but also new /abuild/jh/trunk-install/bin/g++ -flto=24 -fuse-linker-plugin -o dump_syms -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -pedantic -Wno-long-long -fno-strict-aliasing -std=gnu++0x -pthread -pipe -DNDEBUG -DTRIMMED -g -O3 -lpthread -Wl,-rpath-link,/abuild/jh/build-mozilla-new12/dist/bin -Wl,-rpath-link,/usr/local/lib -static host_dump_syms.o ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/linux/libhost_breakpad_linux_common_s.a ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/libhost_breakpad_common_s.a ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/dwarf/libhost_breakpad_dwarf_s.a In file included from /abuild/jh/trunk-install/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_tree.h:930:0, from :311: /abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc: In function 'FindElfClassTextSection': /abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc:133:73: internal compiler error: in gen_typedef_die, at dwarf2out.c:21064 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. make[6]: *** [/tmp/ccaKinu0.ltrans21.ltrans.o] Error 1 Shall I try to get testcase?
On Tue, 31 May 2011, hubicka at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48354 > > --- Comment #11 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-05-31 16:05:49 UTC --- > The patch seems to work. I now get the ICE at output_die (already reported) > but also new > /abuild/jh/trunk-install/bin/g++ -flto=24 -fuse-linker-plugin -o dump_syms > -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth > -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof > -Wno-variadic-macros -Werror=return-type -pedantic -Wno-long-long > -fno-strict-aliasing -std=gnu++0x -pthread -pipe -DNDEBUG -DTRIMMED -g -O3 > -lpthread -Wl,-rpath-link,/abuild/jh/build-mozilla-new12/dist/bin > -Wl,-rpath-link,/usr/local/lib -static host_dump_syms.o > ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/linux/libhost_breakpad_linux_common_s.a > ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/libhost_breakpad_common_s.a > ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/dwarf/libhost_breakpad_dwarf_s.a > In file included from > /abuild/jh/trunk-install/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_tree.h:930:0, > from :311: > /abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc: > In function 'FindElfClassTextSection': > /abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc:133:73: > internal compiler error: in gen_typedef_die, at dwarf2out.c:21064 > Please submit a full bug report, > with preprocessed source if appropriate. > See <http://gcc.gnu.org/bugs.html> for instructions. > make[6]: *** [/tmp/ccaKinu0.ltrans21.ltrans.o] Error 1 > > > Shall I try to get testcase? No, that's another expected one. I'll attach an updated patch.
Created attachment 24407 [details] another update Try this instead.
Same get_typedef_die ICE with this patch, too.
This issue appears to still exist in gcc trunk. The same failure is seen building libnmrPot.dylib in xplor-nih with -flto... g++-fsf-4.7 -dynamiclib -Ofast -funroll-loops -g -flto -fdefault-integer-8 -flat_namespace -undefined suppress -single_module noePot.o atomProb.o rdcPot1.o csaPot.o jCoupPot.o shapePot.o atomDensity.o probDistPot.o cosRatioPot.o ncsPot.o prePot.o rdcWavePot.o varTensor.o surfaceArea.o psolPot.o orderPot.o posRMSDPot.o utils.o posSymmPot.o sphereFun.o volume.o planeDistPot.o selNBPot.o gyrPot.o cstMagPot.o diffPot.o relaxRatioPot.o distSymmPot.o sardcPot.o surfTessellation.o torsionDBPot.o nbTargetPot.o solnScatPot.o -o libnmrPot.dylib -lcrypto -L/Users/howarth/xplor-nih-2.27/bin.Darwin_11_x86_64/ -lspecfun -lsurfD -llapack -lblas In file included from surfaceArea.cc:1276:0, from /Users/howarth/xplor-nih-2.27/CDSlib/cdsSStream.cc:327, from :1669: /Users/howarth/xplor-nih-2.27/nmrPot/relaxRatioPot.hh: In member function ‘numRestraints’: /Users/howarth/xplor-nih-2.27/nmrPot/relaxRatioPot.hh:163:37: internal compiler error: in splice_child_die, at dwarf2out.c:5009 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: g++-fsf-4.7 returned 1 exit status collect2: error: lto-wrapper returned 1 exit status
The original test case still fails on x86_64-apple-darwin11 as well at r180780... g++-fsf-4.7 -r -nostdlib -g -flto bug.ii In file included from bug.ii:8:0, from :2: bug.ii: In function ‘f’: bug.ii:11:1: internal compiler error: in splice_child_die, at dwarf2out.c:5009 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: g++-fsf-4.7 returned 1 exit status collect2: error: lto-wrapper returned 1 exit status
*** Bug 50279 has been marked as a duplicate of this bug. ***
Created attachment 26058 [details] update I'm testing an updated patch.
Author: rguenth Date: Tue Dec 13 14:43:44 2011 New Revision: 182286 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182286 Log: 2011-12-13 Richard Guenther <rguenther@suse.de> PR lto/48354 * tree.c (find_decls_types_r): Also walk DECL_ORIGINAL_TYPE. * tree-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers): Stream DECL_ORIGINAL_TYPE. * tree-streamer-out.c (write_ts_decl_non_common_tree_pointers): Likewise. lto/ * lto.c (lto_ft_decl_non_common): When we merged DECL_ORIGINAL_TYPE with the type of the TYPE_DECL clear DECL_ORIGINAL_TYPE. * g++.dg/lto/pr48354-1_0.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/lto/pr48354-1_0.C Modified: trunk/gcc/ChangeLog trunk/gcc/lto/ChangeLog trunk/gcc/lto/lto.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-streamer-in.c trunk/gcc/tree-streamer-out.c trunk/gcc/tree.c
Fixed.