Configured with: ../configure --prefix=/usr --build=powerpc64-linux --host=powerpc64-linux --enable-shared --enable-threads --enable-__cxa_atexit --with-system-zlib --with-cpu=default32 --with-cpu-64=power4 --enable-secureplt --with-long-double-128 $ ./xgcc -B./ ../../gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c ../../gcc/testsuite/gcc.c-torture/execute/builtins/abs-1-lib.c ../../gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c -flto lto1: internal compiler error: in lto_varpool_replace_node, at lto-symtab.c:306
Now that we use -fuse-linker-plugin by default - do you use gold or GNU ld and what version? Does it use the linker plugin? Thus, please provide output with -v appended.
Reading specs from ./specs COLLECT_GCC=./xgcc COLLECT_LTO_WRAPPER=./lto-wrapper Target: powerpc64-linux Configured with: ../configure --prefix=/usr --build=powerpc64-linux --host=powerpc64-linux --enable-shared --enable-threads --enable-__cxa_atexit --with-system-zlib --with-cpu=default32 --with-cpu-64=power4 --enable-secureplt --with-long-double-128 Thread model: posix gcc version 4.6.0 20110111 (experimental) (GCC) COLLECT_GCC_OPTIONS='-B' './' '-flto' '-v' ./cc1 -quiet -v -iprefix /daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/ -isystem ./include -isystem ./include-fixed -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix ../../gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c -msecure-plt -quiet -dumpbase abs-1.c -auxbase abs-1 -version -flto -o /tmp/cc5tSkJl.s GNU C (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/include-fixed" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/include-fixed" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/include" #include "..." search starts here: #include <...> search starts here: ./include ./include-fixed /usr/local/include /usr/include End of search list. GNU C (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 00974a4f682cf3e5d3da12c4fdb5bd16 COLLECT_GCC_OPTIONS='-B' './' '-flto' '-v' ./as -a32 -mppc -many -Qy -o /tmp/ccyVTDiU.o /tmp/cc5tSkJl.s COLLECT_GCC_OPTIONS='-B' './' '-flto' '-v' ./cc1 -quiet -v -iprefix /daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/ -isystem ./include -isystem ./include-fixed -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix ../../gcc/testsuite/gcc.c-torture/execute/builtins/abs-1-lib.c -msecure-plt -quiet -dumpbase abs-1-lib.c -auxbase abs-1-lib -version -flto -o /tmp/cc5tSkJl.s GNU C (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/include-fixed" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/include-fixed" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/include" #include "..." search starts here: #include <...> search starts here: ./include ./include-fixed /usr/local/include /usr/include End of search list. GNU C (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 00974a4f682cf3e5d3da12c4fdb5bd16 COLLECT_GCC_OPTIONS='-B' './' '-flto' '-v' ./as -a32 -mppc -many -Qy -o /tmp/ccbKKCgO.o /tmp/cc5tSkJl.s COLLECT_GCC_OPTIONS='-B' './' '-flto' '-v' ./cc1 -quiet -v -iprefix /daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/ -isystem ./include -isystem ./include-fixed -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix ../../gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c -msecure-plt -quiet -dumpbase main.c -auxbase main -version -flto -o /tmp/cc5tSkJl.s GNU C (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/include-fixed" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/include" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/include-fixed" ignoring nonexistent directory "/daten/gcc/gcc-20110111/Build/gcc/../lib/gcc/../../lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/include" #include "..." search starts here: #include <...> search starts here: ./include ./include-fixed /usr/local/include /usr/include End of search list. GNU C (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 00974a4f682cf3e5d3da12c4fdb5bd16 COLLECT_GCC_OPTIONS='-B' './' '-flto' '-v' ./as -a32 -mppc -many -Qy -o /tmp/ccaUKDML.o /tmp/cc5tSkJl.s COMPILER_PATH=./ LIBRARY_PATH=./:/lib/../lib/:/usr/lib/../lib/:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-B' './' '-flto' '-v' ./collect2 -plugin ./liblto_plugin.so -plugin-opt=./lto-wrapper -plugin-opt=-fresolution=/tmp/ccDnbr5O.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -flto --eh-frame-hdr -V -Qy -m elf32ppclinux -dynamic-linker /lib/ld.so.1 /usr/lib/../lib/crt1.o /usr/lib/../lib/crti.o ./crtbegin.o -L. -L/lib/../lib -L/usr/lib/../lib /tmp/ccyVTDiU.o /tmp/ccbKKCgO.o /tmp/ccaUKDML.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed ./crtend.o /usr/lib/../lib/crtn.o GNU ld (GNU Binutils; openSUSE 11.3) 2.21 Supported emulations: elf32ppclinux elf32ppc elf32ppcsim elf64ppc elf32_spu ./xgcc @/tmp/ccEsmmlM.args Reading specs from ./specs COLLECT_GCC=./xgcc COLLECT_LTO_WRAPPER=./lto-wrapper Target: powerpc64-linux Configured with: ../configure --prefix=/usr --build=powerpc64-linux --host=powerpc64-linux --enable-shared --enable-threads --enable-__cxa_atexit --with-system-zlib --with-cpu=default32 --with-cpu-64=power4 --enable-secureplt --with-long-double-128 Thread model: posix gcc version 4.6.0 20110111 (experimental) (GCC) COLLECT_GCC_OPTIONS='-c' '-B' './' '-v' '-fltrans-output-list=/tmp/cc98gwft.ltrans.out' '-fwpa' '-fresolution=/tmp/ccDnbr5O.res' ./lto1 -msecure-plt -quiet -dumpbase ccyVTDiU.o -auxbase ccyVTDiU -version -fltrans-output-list=/tmp/cc98gwft.ltrans.out -fwpa -fresolution=/tmp/ccDnbr5O.res @/tmp/ccw7xsBw GNU GIMPLE (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU GIMPLE (GCC) version 4.6.0 20110111 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110111 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 lto1: internal compiler error: in lto_varpool_replace_node, at lto-symtab.c:306 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: ./xgcc returned 1 exit status lto-wrapper failedcollect2: ld returned 1 exit status
I'm seeing this too: # cat test1.c void *ptr; # cat test2.c extern void *ptr; void foo() { ptr = 0; } # gcc -flto -c test1.c # gcc -flto -c test2.c # gcc -flto test1.o test2.o lto1: internal compiler error: in lto_varpool_replace_node, at lto-symtab.c:306 Please submit a full bug report -v output: Using built-in specs. COLLECT_GCC=/root/gcc-installed/bin/gcc COLLECT_LTO_WRAPPER=/root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/lto-wrapper Target: powerpc64-linux Configured with: ../gcc/configure --build=powerpc64-linux --enable-targets=powerpc64-linux --prefix=/root/gcc-installed --disable-nls --with-gmp=/root/gcc-installed --with-mpfr=/root/gcc-installed --with-libelf=/root/gcc-installed --with-cloog=/root/gcc-installed --with-ppl=/root/gcc-installed --disable-werror --with-ld=/root/gcc-installed/bin/ld --with-as=/root/gcc-installed/bin/as --enable-languages=c,c++,fortran --enable-lto : (reconfigured) ../gcc/configure --build=powerpc64-linux --enable-targets=powerpc64-linux --prefix=/root/gcc-installed --disable-nls --with-gmp=/root/gcc-installed --with-mpfr=/root/gcc-installed --with-libelf=/root/gcc-installed --with-cloog=/root/gcc-installed --with-ppl=/root/gcc-installed --disable-werror --with-ld=/root/gcc-installed/bin/ld --with-as=/root/gcc-installed/bin/as --enable-lto build_alias=powerpc64-linux --enable-languages=c,c++,fortran,lto --no-create --no-recursion Thread model: posix gcc version 4.6.0 20110114 (experimental) (GCC) COMPILER_PATH=/root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/:/root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/:/root/gcc-installed/libexec/gcc/powerpc64-linux/:/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/:/root/gcc-installed/lib/gcc/powerpc64-linux/:/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/bin/ LIBRARY_PATH=/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/:/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/lib/:/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-flto' /root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/collect2 -plugin /root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/liblto_plugin.so -plugin-opt=/root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccSsas7e.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -flto --eh-frame-hdr -V -Qy -m elf64ppc -dynamic-linker /lib64/ld64.so.1 /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/crtbegin.o -L/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0 -L/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/../../../../powerpc64-linux/lib -L/root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/../../.. test1.o test2.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /root/gcc-installed/lib/gcc/powerpc64-linux/4.6.0/crtend.o /usr/lib/../lib64/crtn.o GNU ld (GNU Binutils) 2.21.51.20110113 Supported emulations: elf64ppc elf32ppclinux elf32ppc elf32ppcsim /root/gcc-installed/bin/gcc @/tmp/ccgYtfeo.args Using built-in specs. COLLECT_GCC=/root/gcc-installed/bin/gcc COLLECT_LTO_WRAPPER=/root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/lto-wrapper Target: powerpc64-linux Configured with: ../gcc/configure --build=powerpc64-linux --enable-targets=powerpc64-linux --prefix=/root/gcc-installed --disable-nls --with-gmp=/root/gcc-installed --with-mpfr=/root/gcc-installed --with-libelf=/root/gcc-installed --with-cloog=/root/gcc-installed --with-ppl=/root/gcc-installed --disable-werror --with-ld=/root/gcc-installed/bin/ld --with-as=/root/gcc-installed/bin/as --enable-languages=c,c++,fortran --enable-lto : (reconfigured) ../gcc/configure --build=powerpc64-linux --enable-targets=powerpc64-linux --prefix=/root/gcc-installed --disable-nls --with-gmp=/root/gcc-installed --with-mpfr=/root/gcc-installed --with-libelf=/root/gcc-installed --with-cloog=/root/gcc-installed --with-ppl=/root/gcc-installed --disable-werror --with-ld=/root/gcc-installed/bin/ld --with-as=/root/gcc-installed/bin/as --enable-lto build_alias=powerpc64-linux --enable-languages=c,c++,fortran,lto --no-create --no-recursion Thread model: posix gcc version 4.6.0 20110114 (experimental) (GCC) COLLECT_GCC_OPTIONS='-c' '-v' '-fltrans-output-list=/tmp/ccd96jEi.ltrans.out' '-fwpa' '-fresolution=/tmp/ccSsas7e.res' /root/gcc-installed/libexec/gcc/powerpc64-linux/4.6.0/lto1 -quiet -dumpbase test1.o -auxbase test1 -version -fltrans-output-list=/tmp/ccd96jEi.ltrans.out -fwpa -fresolution=/tmp/ccSsas7e.res @/tmp/cciQWnDi GNU GIMPLE (GCC) version 4.6.0 20110114 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110114 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU GIMPLE (GCC) version 4.6.0 20110114 (experimental) (powerpc64-linux) compiled by GNU C version 4.6.0 20110114 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 lto1: internal compiler error: in lto_varpool_replace_node, at lto-symtab.c:306 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: /root/gcc-installed/bin/gcc returned 1 exit status /root/gcc-installed/bin/ld: lto-wrapper failed collect2: ld returned 1 exit status
(In reply to comment #3) > lto1: internal compiler error: in lto_varpool_replace_node, at lto-symtab.c:306 > Please submit a full bug report > On darwin with the collect2 lto, this test case emits the same expected error with and without -flto... gcc-4 -flto test1.o test2.o Undefined symbols: "_main", referenced from: start in crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit status
lto_varpool_replace_node has been broken since it was added in r158854.
I can't reproduce this with the testcase from comment #3 on x86_64-linux with either gold or GNU ld from stock binutils 2.21 nor without using the linker plugin. The only call to lto_varpool_replace_node sees Breakpoint 5, lto_varpool_replace_node (vnode=0x7ffff5d041a0, prevailing_node=0x7ffff5d040d0) at /space/rguenther/src/svn/trunk/gcc/lto-symtab.c:304 304 if (vnode->needed) (gdb) n 306 gcc_assert (!vnode->analyzed || prevailing_node->analyzed); (gdb) p vnode->analyzed $1 = 0 (gdb) p prevailing_node->analyzed $2 = 1 Note that the assert probably should do &&, not ||. Or it doesn't make sense at all. Asserting that the prevailing_node is analyzed should be enough. Honza? People, you have to show us what goes wrong for you.
Resolution file is: 3 abs-1.o 3 70 262910e5 PREEMPTED_IR main_test 84 262910e5 PREEMPTED_IR abs 88 262910e5 PREEMPTED_IR abs_called abs-1-lib.o 3 70 b13b015b PREVAILING_DEF_IRONLY abs 101 b13b015b PREEMPTED_IR inside_main 103 b13b015b PREVAILING_DEF_IRONLY abs_called main.o 3 70 e5772d37 PREVAILING_DEF main 76 e5772d37 PREVAILING_DEF_IRONLY main_test 79 e5772d37 PREVAILING_DEF_IRONLY inside_main /tmp/ccJGcG05.lto.o is empty: dave@gsyprf11:~/gcc-4.6/objdir/gcc/testsuite/gcc$ ls -l /tmp/ccJGcG05.lto.o -rw------- 1 dave users 0 Jan 17 07:20 /tmp/ccJGcG05.lto.o Assert fails at this point: Breakpoint 1, lto_varpool_replace_node (prevailing_node=0x404591c0, vnode=0x40459150) at ../../gcc/gcc/lto-symtab.c:306 306 gcc_assert (!vnode->analyzed || prevailing_node->analyzed); (gdb) p vnode->analyzed $7 = 1 (gdb) p prevailing_node->analyzed $8 = 0 (gdb) p *vnode $9 = {decl = 0x4045a480, next = 0x0, prev = 0x404591c0, next_needed = 0x404591f8, prev_needed = 0x0, extra_name = 0x0, same_comdat_group = 0x0, ref_list = {references = 0x0, refering = 0xc652e0}, lto_file_data = 0x4045b000, aux = 0x0, order = 3, resolution = LDPR_UNKNOWN, needed = 1, force_output = 0, analyzed = 1, finalized = 1, output = 0, externally_visible = 1, alias = 0, used_from_other_partition = 0, in_other_partition = 0} (gdb) p *prevailing_node $10 = {decl = 0x4045a780, next = 0x40459150, prev = 0x404591f8, next_needed = 0x0, prev_needed = 0x0, extra_name = 0x0, same_comdat_group = 0x0, ref_list = {references = 0x0, refering = 0xc65be8}, lto_file_data = 0x4045b0a0, aux = 0x0, order = 8, resolution = LDPR_PREVAILING_DEF_IRONLY, needed = 1, force_output = 0, analyzed = 0, finalized = 0, output = 0, externally_visible = 0, alias = 0, used_from_other_partition = 0, in_other_partition = 0} (gdb) p debug_tree (vnode->decl) <var_decl 0x4045a480 abs_called type <integer_type 0x403fc2a0 int public SI size <integer_cst 0x403f1270 constant 32> unit size <integer_cst 0x403f10a8 constant 4> align 32 symtab 0 alias set -1 structural equality precision 32 min <integer_cst 0x403f1228 -2147483648> max <integer_cst 0x403f1240 2147483647> pointer_to_this <pointer_type 0x403fcb40>> used public static SI file /home2/dave/gcc-4.6/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c line 7 col 5 size <integer_cst 0x403f1270 32> unit size <integer_cst 0x403f10a8 4> align 32 context <translation_unit_decl 0x40404700 D.1190> initial <integer_cst 0x403f1528 0> (mem/c/i:SI (symbol_ref:SI ("abs_called") [flags 0x2] <var_decl 0x4045a480 abs_called>) [0 abs_called+0 S4 A32])> $11 = void (gdb) p debug_tree (prevailing_node->decl) <var_decl 0x4045a780 abs_called type <integer_type 0x403fc2a0 int public SI size <integer_cst 0x403f1270 constant 32> unit size <integer_cst 0x403f10a8 constant 4> align 32 symtab 0 alias set -1 structural equality precision 32 min <integer_cst 0x403f1228 -2147483648> max <integer_cst 0x403f1240 2147483647> pointer_to_this <pointer_type 0x403fcb40>> used public external common SI file /home2/dave/gcc-4.6/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1-lib.c line 2 col 12 size <integer_cst 0x403f1270 32> unit size <integer_cst 0x403f10a8 4> align 32 context <translation_unit_decl 0x40404770 D.1196>> $12 = void
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47274 > > --- Comment #7 from John David Anglin <danglin at gcc dot gnu.org> 2011-01-17 15:42:26 UTC --- > Resolution file is: > > 3 > abs-1.o 3 > 70 262910e5 PREEMPTED_IR main_test > 84 262910e5 PREEMPTED_IR abs > 88 262910e5 PREEMPTED_IR abs_called > abs-1-lib.o 3 > 70 b13b015b PREVAILING_DEF_IRONLY abs > 101 b13b015b PREEMPTED_IR inside_main > 103 b13b015b PREVAILING_DEF_IRONLY abs_called > main.o 3 > 70 e5772d37 PREVAILING_DEF main > 76 e5772d37 PREVAILING_DEF_IRONLY main_test > 79 e5772d37 PREVAILING_DEF_IRONLY inside_main > > /tmp/ccJGcG05.lto.o is empty: > dave@gsyprf11:~/gcc-4.6/objdir/gcc/testsuite/gcc$ ls -l /tmp/ccJGcG05.lto.o > -rw------- 1 dave users 0 Jan 17 07:20 /tmp/ccJGcG05.lto.o > > Assert fails at this point: > > Breakpoint 1, lto_varpool_replace_node (prevailing_node=0x404591c0, > vnode=0x40459150) at ../../gcc/gcc/lto-symtab.c:306 > 306 gcc_assert (!vnode->analyzed || prevailing_node->analyzed); > (gdb) p vnode->analyzed > $7 = 1 > (gdb) p prevailing_node->analyzed > $8 = 0 We need to debug how the defined node ends up to be unanalyzed. I assume it is abs_called variable? It seems that we get wrong already when streaming abs-1-lib.o file. Would be possible to attach cgraph dump from WPA? Honza
> Note that the assert probably should do &&, not ||. Or it doesn't > make sense at all. Asserting that the prevailing_node is analyzed > should be enough. No, the assert basically test that when node is analyzed prevailing_node must be analyzed, too. So the test tests the implication, not conjunction. It is possible that we merge two unanalyzed nodes (such as aliases). Honza
The GNU linker made extern int abs_called; prevailing (it's a common, probably works with -fno-common?) instead of int abs_called = 0; thus I think this is a bug in the GNU linker (we remove the zero initializer I think, so maybe out LTO symtab we create is slightly odd).
Created attachment 22998 [details] abs-1-lib.c.006t.vcg (In reply to comment #10) > The GNU linker made > > extern int abs_called; > > prevailing (it's a common, probably works with -fno-common?) instead of > > int abs_called = 0; > > thus I think this is a bug in the GNU linker (we remove the zero initializer > I think, so maybe out LTO symtab we create is slightly odd). Which means you can also try -fno-zero-initialized-in-bss
Created attachment 22999 [details] abs-1-lib.c.092t.pre On Mon, 17 Jan 2011, hubicka at ucw dot cz wrote: > It seems that we get wrong already when streaming abs-1-lib.o file. Would be > possible to attach cgraph dump from WPA? Is this what you wanted? Dave
Created attachment 23007 [details] abs-1-lib.c.000i.cgraph Last graph.
Created attachment 23008 [details] abs-1.c.000i.cgraph This is it! Dave
Created attachment 23039 [details] main.c.000i.cgraph Here is abs-1.c.000i.cgraph:
On Tue, 18 Jan 2011, dave at hiauly1 dot hia.nrc.ca wrote: > Here is abs-1.c.000i.cgraph: The above call graph indicates main_test is not called. Here is main.c.000i.cgraph. It also seems wrong...
You uploaded the cgraph files from local compilation.main_test is not called in abs-1.c I need to see the dump from merging, too. They gets name of one of the .o files when -save-temps is used. I.e. ./xgcc -B ./ -O2 abs-1-lib.c abs-1.c m.c -fdump-ipa-cgraph -save-temps -flto gets me the dump in abs-1-lib.o.000i.cgraph Honza
On Thu, 27 Jan 2011, hubicka at gcc dot gnu.org wrote: > I need to see the dump from merging, too. > They gets name of one of the .o files when -save-temps is used. > I.e. > ./xgcc -B ./ -O2 abs-1-lib.c abs-1.c m.c -fdump-ipa-cgraph -save-temps -flto > gets me the dump in abs-1-lib.o.000i.cgraph It seems the ICE occurs before the merge files are generated: Reading specs from /home2/dave/gcc-4.6/objdir/gcc/specs COLLECT_GCC=/home2/dave/gcc-4.6/objdir/gcc/xgcc COLLECT_LTO_WRAPPER=/home2/dave/gcc-4.6/objdir/gcc/lto-wrapper Target: hppa-linux Configured with: ../gcc/configure --with-gnu-as --with-gnu-ld --enable-shared --enable-nls --prefix=/home2/dave/opt/gnu/gcc/gcc-4.6.0 --with-local-prefix=/home2/dave/opt/gnu --enable-threads=posix --enable-__cxa_atexit --build=hppa-linux --enable-clocale=gnu --enable-java-gc=boehm --enable-java-awt=xlib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada Thread model: posix gcc version 4.6.0 20110126 (experimental) [trunk revision 169296] (GCC) COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/cc1 -E -quiet -v -iprefix /home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/ -isystem /home2/dave/gcc-4.6/objdir/gcc/include -isystem /home2/dave/gcc-4.6/objdir/gcc/include-fixed /home2/dave/gcc-4.6/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c -w -flto -fno-builtin-abs -fdump-ipa-cgraph -O2 -fpch-preprocess -o abs-1.i ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/include-fixed" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/../../../../hppa-linux/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/include-fixed" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/../../../../hppa-linux/include" #include "..." search starts here: #include <...> search starts here: /home2/dave/gcc-4.6/objdir/gcc/include /home2/dave/gcc-4.6/objdir/gcc/include-fixed /home2/dave/opt/gnu/include /usr/include End of search list. COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/cc1 -fpreprocessed abs-1.i -quiet -dumpbase abs-1.c -auxbase abs-1 -O2 -w -version -flto -fno-builtin-abs -fdump-ipa-cgraph -o abs-1.s GNU C (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 394c56f917a1cdcda6b767bcbf6fcebb COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/as -v -W -o abs-1.o abs-1.s GNU assembler version 2.21.51 (hppa-unknown-linux-gnu) using BFD version (GNU Binutils) 2.21.51.20110116 COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/cc1 -E -quiet -v -iprefix /home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/ -isystem /home2/dave/gcc-4.6/objdir/gcc/include -isystem /home2/dave/gcc-4.6/objdir/gcc/include-fixed /home2/dave/gcc-4.6/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1-lib.c -w -flto -fno-builtin-abs -fdump-ipa-cgraph -O2 -fpch-preprocess -o abs-1-lib.i ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/include-fixed" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/../../../../hppa-linux/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/include-fixed" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/../../../../hppa-linux/include" #include "..." search starts here: #include <...> search starts here: /home2/dave/gcc-4.6/objdir/gcc/include /home2/dave/gcc-4.6/objdir/gcc/include-fixed /home2/dave/opt/gnu/include /usr/include End of search list. COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/cc1 -fpreprocessed abs-1-lib.i -quiet -dumpbase abs-1-lib.c -auxbase abs-1-lib -O2 -w -version -flto -fno-builtin-abs -fdump-ipa-cgraph -o abs-1-lib.s GNU C (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 394c56f917a1cdcda6b767bcbf6fcebb COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/as -v -W -o abs-1-lib.o abs-1-lib.s GNU assembler version 2.21.51 (hppa-unknown-linux-gnu) using BFD version (GNU Binutils) 2.21.51.20110116 COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/cc1 -E -quiet -v -iprefix /home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/ -isystem /home2/dave/gcc-4.6/objdir/gcc/include -isystem /home2/dave/gcc-4.6/objdir/gcc/include-fixed /home2/dave/gcc-4.6/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c -w -flto -fno-builtin-abs -fdump-ipa-cgraph -O2 -fpch-preprocess -o main.i ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/include-fixed" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/hppa-linux/4.6.0/../../../../hppa-linux/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../include" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/include-fixed" ignoring nonexistent directory "/home2/dave/gcc-4.6/objdir/gcc/../lib/gcc/../../lib/gcc/hppa-linux/4.6.0/../../../../hppa-linux/include" #include "..." search starts here: #include <...> search starts here: /home2/dave/gcc-4.6/objdir/gcc/include /home2/dave/gcc-4.6/objdir/gcc/include-fixed /home2/dave/opt/gnu/include /usr/include End of search list. COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/cc1 -fpreprocessed main.i -quiet -dumpbase main.c -auxbase main -O2 -w -version -flto -fno-builtin-abs -fdump-ipa-cgraph -o main.s GNU C (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 394c56f917a1cdcda6b767bcbf6fcebb COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/as -v -W -o main.o main.s GNU assembler version 2.21.51 (hppa-unknown-linux-gnu) using BFD version (GNU Binutils) 2.21.51.20110116 COMPILER_PATH=/home2/dave/gcc-4.6/objdir/gcc/ LIBRARY_PATH=/home2/dave/gcc-4.6/objdir/gcc/:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-flto' '-fno-builtin-abs' '-o' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7' '-fdump-ipa-cgraph' '-save-temps' '-v' /home2/dave/gcc-4.6/objdir/gcc/collect2 -plugin /home2/dave/gcc-4.6/objdir/gcc/liblto_plugin.so -plugin-opt=/home2/dave/gcc-4.6/objdir/gcc/lto-wrapper -plugin-opt=-fresolution=abs-1.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -flto --eh-frame-hdr -dynamic-linker /lib/ld.so.1 -o /home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/abs-1.x7 /usr/lib/crt1.o /usr/lib/crti.o /home2/dave/gcc-4.6/objdir/gcc/crtbegin.o -L/home2/dave/gcc-4.6/objdir/gcc abs-1.o abs-1-lib.o main.o -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home2/dave/gcc-4.6/objdir/gcc/crtend.o /usr/lib/crtn.o /home2/dave/gcc-4.6/objdir/gcc/xgcc @/tmp/ccwlzcU3.args Reading specs from /home2/dave/gcc-4.6/objdir/gcc/specs COLLECT_GCC=/home2/dave/gcc-4.6/objdir/gcc/xgcc COLLECT_LTO_WRAPPER=/home2/dave/gcc-4.6/objdir/gcc/lto-wrapper Target: hppa-linux Configured with: ../gcc/configure --with-gnu-as --with-gnu-ld --enable-shared --enable-nls --prefix=/home2/dave/opt/gnu/gcc/gcc-4.6.0 --with-local-prefix=/home2/dave/opt/gnu --enable-threads=posix --enable-__cxa_atexit --build=hppa-linux --enable-clocale=gnu --enable-java-gc=boehm --enable-java-awt=xlib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada Thread model: posix gcc version 4.6.0 20110126 (experimental) [trunk revision 169296] (GCC) COLLECT_GCC_OPTIONS='-c' '-B' '/home2/dave/gcc-4.6/objdir/gcc/' '-w' '-O2' '-fno-builtin-abs' '-fdump-ipa-cgraph' '-save-temps' '-v' '-dumpdir' '/home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/' '-dumpbase' 'abs-1.x7.wpa' '-fltrans-output-list=abs-1.x7.ltrans.out' '-fwpa' '-fresolution=abs-1.res' /home2/dave/gcc-4.6/objdir/gcc/lto1 -quiet -dumpdir /home2/dave/gcc-4.6/objdir/gcc/testsuite/gcc/ -dumpbase abs-1.x7.wpa -auxbase abs-1 -O2 -w -version -fno-builtin-abs -fdump-ipa-cgraph -fltrans-output-list=abs-1.x7.ltrans.out -fwpa -fresolution=abs-1.res @/tmp/ccHvnWi6 GNU GIMPLE (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU GIMPLE (GCC) version 4.6.0 20110126 (experimental) [trunk revision 169296] (hppa-linux) compiled by GNU C version 4.6.0 20110126 (experimental) [trunk revision 169296], GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 lto1: internal compiler error: in lto_varpool_replace_node, at lto-symtab.c:305 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: /home2/dave/gcc-4.6/objdir/gcc/xgcc returned 1 exit status [Leaving LTRANS abs-1.x7.ltrans.out] [Leaving LTRANS /tmp/ccwlzcU3.args] /home2/dave/opt/gnu/bin/ld: lto-wrapper failed collect2: ld returned 1 exit status Dave
Created attachment 23144 [details] abs-1.x7.wpa.000i.cgraph > lto1: internal compiler error: in lto_varpool_replace_node, at lto-symtab.c:305 Merging should happen after unmerged files are dumped. Perhaps they go to some funny place, like /tmp? Honza
On Thu, 27 Jan 2011, hubicka at ucw dot cz wrote: > Merging should happen after unmerged files are dumped. Perhaps they go to some > funny place, > like /tmp? They are not in /tmp. There is one other cgraph file which I attach. Dave
Thanks. Looking at compilation time callgraphs, they are all as expected. At link time however, the resolution info seems however all wrong. That results in wrong merging. Not only for vars, but also for functions: main_test/7(-1) @0x4045f5b0 (asm: main_test) prevailing_def_ironly called by: main/6 (1.00 per call) calls: References: Refering this function: main_test/0(-1) @0x4045f000 (asm: main_test) analyzed 19 time, 12 benefit 13 size, 4 benefit externally_visible finalized inlinable called by: calls: abort/1 abort/1 abs/2 (1.00 per call) References: var:abs_called (read) Refering this function: The first node is main_test comming from main.c, the second is one comming from abd-1.c defining the function. The problem is that first one is defined as prevailing_def_ironly while it is not an definition, just use of the symbol. Correct would be to have PREVAILING_DEF_IRONLY on the second and PREEMTED_IR on the first. We probably should add sanity check that functions with PREVAILING_DEFs are always analyzed and vars finalized. As observer by Richard, it comes from resolution file already: abs-1.o 3 70 262910e5 PREEMPTED_IR main_test main.o 3 76 e5772d37 PREVAILING_DEF_IRONLY main_test should be the other way around I am quite convinced that we are seeing GNU LD bug and adding Dave Korn to CC thus. The other alternative would be that lto symbol table is output incorrectly at compilation time. You might try to experiment with NM's plugin support to try to dump LTO symbol table of main.o. I never tried it myself as I never really needed to dump LTO symbol table, but it should be supported now. But given that the code in write_symbol is quite straighforward: if (DECL_EXTERNAL (t)) { if (DECL_WEAK (t)) kind = GCCPK_WEAKUNDEF; else kind = GCCPK_UNDEF; } else { if (DECL_WEAK (t)) kind = GCCPK_WEAKDEF; else if (DECL_COMMON (t)) kind = GCCPK_COMMON; else kind = GCCPK_DEF; /* When something is defined, it should have node attached. */ gcc_assert (alias || TREE_CODE (t) != VAR_DECL || varpool_get_node (t)->finalized); gcc_assert (alias || TREE_CODE (t) != FUNCTION_DECL || (cgraph_get_node (t) && cgraph_get_node (t)->analyzed)); } (kind should be GCCPK_UNDEF for main_test in main.o) I would not expect bug to be on symbol streaming side.
(In reply to comment #21) > The problem is that first one is defined as prevailing_def_ironly while it is > not an definition, just use of the symbol. Correct would be to have > PREVAILING_DEF_IRONLY on the second and PREEMTED_IR on the first. > We probably should add sanity check that functions with PREVAILING_DEFs are > always analyzed and vars finalized. > > As observer by Richard, it comes from resolution file already: > abs-1.o 3 > 70 262910e5 PREEMPTED_IR main_test > main.o 3 > 76 e5772d37 PREVAILING_DEF_IRONLY main_test > should be the other way around > > I am quite convinced that we are seeing GNU LD bug and adding Dave Korn to CC > thus. Looking into it.
(In reply to comment #21) > The problem is that first one is defined as prevailing_def_ironly while it is > not an definition, just use of the symbol. Correct would be to have > PREVAILING_DEF_IRONLY on the second and PREEMTED_IR on the first. > We probably should add sanity check that functions with PREVAILING_DEFs are > always analyzed and vars finalized. > > As observer by Richard, it comes from resolution file already: > abs-1.o 3 > 70 262910e5 PREEMPTED_IR main_test > main.o 3 > 76 e5772d37 PREVAILING_DEF_IRONLY main_test > should be the other way around Why would you expect to see PREEMPTED_IR? There is only one definition of main_test; I would expect RESOLVED_IR. Rather than swapped, aren't they just plain wrong? > I am quite convinced that we are seeing GNU LD bug and adding Dave Korn to CC > thus. I also think you must be seeing a bug in LD, but haven't reproduced it yet; on both x86_64-linux and i686-cygwin I get the same correct resolution file: davek@gcc10:~/binutils/obj-gcc/gcc/pr47274$ cat *.res 3 abs-1.o 2 79 7d1d28a3 PREVAILING_DEF_IRONLY main_test 93 7d1d28a3 PREVAILING_DEF_IRONLY abs_called abs-1-lib.o 2 110 4db0e4c5 RESOLVED_IR inside_main 112 4db0e4c5 RESOLVED_IR abs_called main.o 4 79 8cf841f3 PREVAILING_DEF main 85 8cf841f3 PREVAILING_DEF_IRONLY link_error 89 8cf841f3 RESOLVED_IR main_test 99 8cf841f3 PREVAILING_DEF_IRONLY inside_main What endian-ness are the ppc and hppa targets?
> What endian-ness are the ppc and hppa targets? hppa is big. I believe ppc is also big. Dave
Created attachment 23191 [details] pr47560.tar.gz (In reply to comment #24) > > What endian-ness are the ppc and hppa targets? > > hppa is big. I believe ppc is also big. > > Dave Probably the first time this code has been tested on a big endian machine. Maybe some field's being read wrong out of the symbols or something. If one of you could try the whole thing with "--save-temps -v -Wl,-v -Wl,--verbose", and attach the various .o and @ arg files (some of which still get left in /tmp) and the log of the build output, I may be able to run far enough through the link with just a cross binutils to get to the symbol resolution stage and debug it.
On Mon, 31 Jan 2011, davek at gcc dot gnu.org wrote: > If one of you could try the whole thing with "--save-temps -v -Wl,-v > -Wl,--verbose", and attach the various .o and @ arg files (some of which still > get left in /tmp) and the log of the build output, I may be able to run far > enough through the link with just a cross binutils to get to the symbol > resolution stage and debug it. Attached. Dave
On Mon, 31 Jan 2011, davek at gcc dot gnu.org wrote: > If one of you could try the whole thing with "--save-temps -v -Wl,-v > -Wl,--verbose", and attach the various .o and @ arg files (some of which still > get left in /tmp) and the log of the build output, I may be able to run far > enough through the link with just a cross binutils to get to the symbol > resolution stage and debug it. Oh, I just remembered that ld/12402 was probably introduced by the change that introduced plugin support for ld. Dave
It looks like the problem is much earlier than the linker; it looks like the IR symtabs in the input object files are being generated incorrectly. Here are the real symbol tables: $ ./obj/binutils/.libs/nm-new.exe *.o abs-1-lib.o: 00000001 C __gnu_lto_v1 U abort 00000000 T abs U abs_called U inside_main 00000024 T labs abs-1.o: 00000001 C __gnu_lto_v1 U abort U abs 00000000 B abs_called 00000000 T main_test main.o: 00000001 C __gnu_lto_v1 00000004 C inside_main 00000000 T main U main_test And here are the IR symtabs (I built a cross GCC just far enough to get the liblto_plugin): $ ./obj/binutils/.libs/nm-new.exe --plugin ./obj-xgcc/lto-plugin/.libs/cyglto_p lugin-0.dll *.o abs-1-lib.o: 00000000 T abs 00000000 T abs_called 00000000 T inside_main abs-1.o: 00000000 T abs 00000000 T abs_called 00000000 T main_test main.o: 00000000 T inside_main 00000000 T main 00000000 T main_test To confirm that the symtabs really are wrong in the object files, rather than that the plugin is misreading them, here's a binary dump from one: $ ./obj/binutils/.libs/objdump.exe -h abs-1-lib.o abs-1-lib.o: file format elf32-hppa-linux Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000058 00000000 00000000 00000034 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 1 .data 00000000 00000000 00000000 0000008c 2**0 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 0000008c 2**0 ALLOC 3 .gnu.lto_.jmpfuncs.29f392e1 00000019 00000000 00000000 0000008c 2**0 CONTENTS, READONLY, EXCLUDE 4 .gnu.lto_.pureconst.29f392e1 00000016 00000000 00000000 000000a5 2**0 CONTENTS, READONLY, EXCLUDE 5 .gnu.lto_abs.29f392e1 00000192 00000000 00000000 000000bb 2**0 CONTENTS, READONLY, EXCLUDE 6 .gnu.lto_labs.29f392e1 00000189 00000000 00000000 0000024d 2**0 CONTENTS, READONLY, EXCLUDE 7 .gnu.lto_.cgraph.29f392e1 0000003c 00000000 00000000 000003d6 2**0 CONTENTS, READONLY, EXCLUDE 8 .gnu.lto_.vars.29f392e1 00000018 00000000 00000000 00000412 2**0 CONTENTS, READONLY, EXCLUDE 9 .gnu.lto_.refs.29f392e1 0000001b 00000000 00000000 0000042a 2**0 CONTENTS, READONLY, EXCLUDE 10 .gnu.lto_.statics.29f392e1 00000014 00000000 00000000 00000445 2**0 CONTENTS, READONLY, EXCLUDE 11 .gnu.lto_.decls.29f392e1 000002ab 00000000 00000000 00000459 2**0 CONTENTS, READONLY, EXCLUDE 12 .gnu.lto_.symtab.29f392e1 00000048 00000000 00000000 00000704 2**0 CONTENTS, READONLY, EXCLUDE 13 .gnu.lto_.opts 00000012 00000000 00000000 0000074c 2**0 CONTENTS, READONLY, EXCLUDE 14 .PARISC.unwind 00000020 00000000 00000000 00000760 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 15 .comment 00000042 00000000 00000000 00000780 2**0 CONTENTS, READONLY $ ./obj/binutils/.libs/objcopy.exe -j .gnu.lto_.symtab.29f392e1 abs-1-lib.o sym s-abs-1-lib.o $ ./obj/binutils/.libs/objdump.exe -s syms-abs-1-lib.o syms-abs-1-lib.o: file format elf32-hppa-linux Contents of section .gnu.lto_.symtab.29f392e1: 0000 61627300 00000000 00000000 00000000 abs............. 0010 00004669 6e736964 655f6d61 696e0000 ..Finside_main.. 0020 00000000 00000000 00000000 00656162 .............eab 0030 735f6361 6c6c6564 00000000 00000000 s_called........ 0040 00000000 00000067 .......g The format of the IR symtab entries is: (variable-length) NUL-terminated name (variable-length) NUL-terminated comdat group (1 byte) symbol kind from LDPK_ enumeration (1 byte) symbol visibility from LDPV_ enumeration (8 bytes) 64-bit symbol size (4 bytes) 32-bits symbol aux info. As you can see, this symtab claims that abs-1-lib.o defines inside_main 0000 61627300 00000000 00000000 00000000 abs............. 0010 00004669 6e736964 655f6d61 696e0000 ..Finside_main.. \/ \/\/\/\/ \/\/\/\/ \/\/\/\/ name--------++++++++++++++++++++++++++ + comdat---------------------------------+ 0020 00000000 00000000 00000000 00656162 .............eab \/\/ kind--+ + 0 = LDPK_DEF vis-----+ 0 = LDPV_DEFAULT 0030 735f6361 6c6c6564 00000000 00000000 s_called........ 0040 00000000 00000067 .......g So the problem is that the object files are being written incorrectly in the first place, I think. Indeed, the contents of abs-1-lib.s look that way: .section .gnu.lto_.symtab.29f392e1,"",@progbits .stringz "abs" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "Finside_main" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "eabs_called" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .stringz "" .ascii "g" .text No attempt there to put anything but zeros for the symbol kind. So, LTO is streaming out symtabs that say every object file defines every symbol... no wonder the linker/plugin get confused! This now needs somebody with a full compiler for the target to debug; I've only got (cross) binutils and lto-plugin.
> And here are the IR symtabs (I built a cross GCC just far enough to get the > liblto_plugin): > > $ ./obj/binutils/.libs/nm-new.exe --plugin ./obj-xgcc/lto-plugin/.libs/cyglto_p > lugin-0.dll *.o > > abs-1-lib.o: > 00000000 T abs > 00000000 T abs_called > 00000000 T inside_main > > abs-1.o: > 00000000 T abs > 00000000 T abs_called > 00000000 T main_test > > main.o: > 00000000 T inside_main > 00000000 T main > 00000000 T main_test > Hmm, this seems like some very lowlevel bug in the streaming (endianity issue or so) since they way visibilities are derrived is actually quite target independent. I will look into it day after tomorrow unless somebody beats me. Thanks, Honza
*** Bug 47287 has been marked as a duplicate of this bug. ***
Created attachment 23217 [details] gcc46-pr47274.patch I think it is fairly obvious where the bug is (though haven't tried to reproduce it). Passing address of a 32-bit enum variable and outputting from it the first byte obviously will DTRT only on little endian hosts.
Similar (dormant) problem with slot_num.
All other calls to lto_output_data_stream use sizeof, so this should probably do as well.
Isn't the format of that section mandated by lto-plugin though?
Author: jakub Date: Thu Feb 3 10:49:06 2011 New Revision: 169785 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169785 Log: PR lto/47274 * lto-streamer-out.c (write_symbol): When writing kind and visibility, copy them into a unsigned char variable and pass address of it to lto_output_data_stream. Modified: trunk/gcc/ChangeLog trunk/gcc/lto-streamer-out.c
I guess the remaining two places could use sizeof, but the question is whether we can portably use uint32_t in lto-streamer-out.c (lto-plugin uses it, but nothing in gcc/*). So perhaps it could use unsigned int instead of uint32_t for the slot no (or int). And lto-plugin memcpy (&entry->size, p, sizeof (uint64_t)); p += 8; memcpy (&aux->slot, p, sizeof (uint32_t)); p += 4; could increment by the sizeof too. Anyway, I'm not aware of any sizeof (int) != 4 host gcc would support, so I consider this bug fixed.