I see following ICE from r224248: $ cat 1.ii cat 1.ii extern "C" { struct { } ltregul_; } $ cat 2.F common /ltregul/ zeroeps end $ g++ 1.ii 2.F -flto -O2 2.F:1:3: warning: type of ‘ltregul’ does not match original declaration [-Wlto-type-mismatch] 1 | common /ltregul/ zeroeps | ^ lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:995 0x626616 warn_types_mismatch(tree_node*, tree_node*, unsigned int, unsigned int) /home/marxin/Programming/gcc/gcc/ipa-devirt.c:995 0x7e536c lto_symtab_merge_decls_2 /home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:722 0x7e536c lto_symtab_merge_decls_1 /home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:861 0x7e536c lto_symtab_merge_decls() /home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:887 0x7f0f28 read_cgraph_and_symbols(unsigned int, char const**) /home/marxin/Programming/gcc/gcc/lto/lto-common.c:2839 0x7d7702 lto_main() /home/marxin/Programming/gcc/gcc/lto/lto.c:616
This seems to work for me with current trunk hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/1.ii extern "C" { struct { } ltregul_; } hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/2.F common /ltregul/ zeroeps end hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./gfortran -B ./ ~/1.ii ~/2.F -flto -O2 -B ../x86_64-pc-linux-gnu/libgfortran/ hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./xg++ -B ./ ~/1.ii ~/2.F -flto -O2 -B ../x86_64-pc-linux-gnu/libgfortran/ /usr/local/x86_64-pc-linux-gnu/bin/ld: /tmp/cck5WNC7.ltrans0.ltrans.o: in function `main': <artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args' /usr/local/x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text.startup+0x14): undefined reference to `_gfortran_set_options' collect2: error: ld returned 1 exit status
(In reply to Jan Hubicka from comment #1) > This seems to work for me with current trunk No, it's broken also on current trunk. > > hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/1.ii > extern "C" { > struct { > } ltregul_; > } > hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/2.F > common /ltregul/ zeroeps > end > hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./gfortran -B ./ ~/1.ii > ~/2.F -flto -O2 -B ../x86_64-pc-linux-gnu/libgfortran/ > hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./xg++ -B ./ ~/1.ii > ~/2.F -flto -O2 -B ../x86_64-pc-linux-gnu/libgfortran/ > /usr/local/x86_64-pc-linux-gnu/bin/ld: /tmp/cck5WNC7.ltrans0.ltrans.o: in > function `main': > <artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args' > /usr/local/x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text.startup+0x14): > undefined reference to `_gfortran_set_options' > collect2: error: ld returned 1 exit status Please run it from a location where you have properly installed compiler: $ gcc -v gcc --version gcc (GCC) 10.0.0 20190723 (experimental $ g++ 1.ii 2.F -flto -O2 2.F:1:3: warning: type of ‘ltregul’ does not match original declaration [-Wlto-type-mismatch] 1 | common /ltregul/ zeroeps | ^ lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:995 0xcab6f2 warn_types_mismatch(tree_node*, tree_node*, unsigned int, unsigned int) /home/marxin/Programming/gcc/gcc/ipa-devirt.c:995 0x89f8d7 lto_symtab_merge_decls_2 /home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:722 0x89ffe9 lto_symtab_merge_decls_1 /home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:861 0x8a00e3 lto_symtab_merge_decls() /home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:887 0x8b4854 read_cgraph_and_symbols(unsigned int, char const**) /home/marxin/Programming/gcc/gcc/lto/lto-common.c:2839 0x885bb5 lto_main() /home/marxin/Programming/gcc/gcc/lto/lto.c:616
Still works for me hubicka@lomikamen-jh:~$ /aux/hubicka/trunk-install/bin/g++ 1.ii 2.F -O2 -flto /usr/local/bin/ld: /tmp/ccpfzvWm.ltrans0.ltrans.o: in function `main': <artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args' /usr/local/bin/ld: <artificial>:(.text.startup+0x14): undefined reference to `_gfortran_set_options' collect2: error: ld returned 1 exit status also with system compiler on tumbleweed There is extra cat in 1.ii, perhaps it is truncated?
Created attachment 46633 [details] 1.ii
Created attachment 46634 [details] 2.F
(In reply to Jan Hubicka from comment #3) > Still works for me > hubicka@lomikamen-jh:~$ /aux/hubicka/trunk-install/bin/g++ 1.ii 2.F -O2 -flto > /usr/local/bin/ld: /tmp/ccpfzvWm.ltrans0.ltrans.o: in function `main': > <artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args' > /usr/local/bin/ld: <artificial>:(.text.startup+0x14): undefined reference to > `_gfortran_set_options' > collect2: error: ld returned 1 exit status > > also with system compiler on tumbleweed > There is extra cat in 1.ii, perhaps it is truncated? I've just uploaded test-cases, please test it. Using TW GCC: $ g++ --version g++ (SUSE Linux) 9.1.1 20190723 [gcc-9-branch revision 273734] $ g++ 1.ii 2.F -flto -O2 2.F:1:3: warning: type of ‘ltregul’ does not match original declaration [-Wlto-type-mismatch] 1 | common /ltregul/ zeroeps | ^ lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:1133 0x7fc5fcd15bca __libc_start_main ../csu/libc-start.c:308
aha, relies on indentation of common in 2.F. i will check what goes wrong.
SPEC2017 case 507.cactuBSSN_r, also has ICE failure from r273571: lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:995 0x105dad1f warn_types_mismatch(tree_node*, tree_node*, unsigned int, unsigned int) /home/gcc/gcc-10-trunk-2019-08-16/gcc/ipa-devirt.c:995 0x101dd147 lto_symtab_merge_decls_2 /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-symtab.c:723 0x101dd147 lto_symtab_merge_decls_1 /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-symtab.c:862 0x101dd147 lto_symtab_merge_decls() /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-symtab.c:888 0x101f2e47 read_cgraph_and_symbols(unsigned int, char const**) /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-common.c:2839 0x101c7def lto_main() Compiler options used: "-O3 -mcpu=power9 -flto"
@Honza: Is there any progress?
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Dup. *** This bug has been marked as a duplicate of bug 91222 ***