On Linux/x86-64, revision 191825 configured with --prefix=/usr/local --enable-clocale=gnu --with-system-zlib --enable-shared --with-demangler-in-ld --with-build-config=bootstrap-lto --with-fpmath=sse --enable-languages=c,c++,fortran,java,lto,objc failed to profiledbootstrap: /tmp/ccFJkgbJ.s: Assembler messages: /tmp/ccFJkgbJ.s:752755: Error: invalid character (0x83) in mnemonic make[7]: *** [/tmp/ccSxjzh4.ltrans14.ltrans.o] Error 1 It happens at random.
(In reply to comment #0) > It happens at random. Maybe --enable-checking=valgrind can help here?
(In reply to comment #1) > (In reply to comment #0) > > > It happens at random. > > Maybe --enable-checking=valgrind can help here? I will give it a try.
(In reply to comment #1) > (In reply to comment #0) > > > It happens at random. > > Maybe --enable-checking=valgrind can help here? It could if it would build, see Bug 54691.
Revision 193543 gave: lto1: internal compiler error: Segmentation fault 0xb37547 crash_signal ../../src-trunk/gcc/toplev.c:334 0x6c0763 resolve_addr_in_expr ../../src-trunk/gcc/dwarf2out.c:22440 0x6eb6e2 resolve_addr ../../src-trunk/gcc/dwarf2out.c:22636 0x6eb77b resolve_addr ../../src-trunk/gcc/dwarf2out.c:22687 0x6eb77b resolve_addr ../../src-trunk/gcc/dwarf2out.c:22687 0x6eb77b resolve_addr ../../src-trunk/gcc/dwarf2out.c:22687 0x6eb77b resolve_addr ../../src-trunk/gcc/dwarf2out.c:22687 0x6eb77b resolve_addr ../../src-trunk/gcc/dwarf2out.c:22687 0x6eb77b resolve_addr ../../src-trunk/gcc/dwarf2out.c:22687 0x6eb77b resolve_addr ../../src-trunk/gcc/dwarf2out.c:22687 0x6ec76b dwarf2out_finish ../../src-trunk/gcc/dwarf2out.c:23309 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. make[7]: *** [/tmp/ccAUJBBj.ltrans24.ltrans.o] Error 1 make[7]: *** Waiting for unfinished jobs.... lto-wrapper: make returned 2 exit status /usr/local/x86_64-unknown-linux-gnu/bin/ld: lto-wrapper failed collect2: error: ld returned 1 exit status make[6]: *** [cc1plus] Error 1
I'm not sure if it's related, but with gcc built with clang's -fsanitize=address I get: markus@x4 ~ % /var/tmp/gcc_sani_clang/usr/local/bin/g++ -flto t.cpp 2>&1 | asan_symbolize.py | c++filt ================================================================= ==15267== ERROR: AddressSanitizer: global-buffer-overflow on address 0x000002d16424 at pc 0x12ca07a bp 0x7fff5db28190 sp 0x7fff5db28188 READ of size 4 at 0x000002d16424 thread T0 #0 0x12ca079 in lto_write_options() /home/markus/gcc/gcc/lto-opts.c:97 #1 0x12c076a in produce_asm_for_decls() /home/markus/gcc/gcc/lto-streamer-out.c:1407 #2 0x135a74f in ipa_write_summaries_2(opt_pass*, lto_out_decl_state*) /home/markus/gcc/gcc/passes.c:2430 0x000002d16424 is located 28 bytes to the left of global variable '.str2184 (options.c)' (0x2d16440) of size 4 '.str2184 (options.c)' is ascii string 'gnu' 0x000002d16424 is located 25 bytes to the right of global variable '.str2183 (options.c)' (0x2d16400) of size 11 '.str2183 (options.c)' is ascii string 'local-exec' Shadow byte and word: 0x1000005a2c84: f9 0x1000005a2c80: 00 03 f9 f9 f9 f9 f9 f9 More shadow bytes: 0x1000005a2c60: 00 00 00 02 f9 f9 f9 f9 0x1000005a2c68: 00 07 f9 f9 f9 f9 f9 f9 0x1000005a2c70: 00 05 f9 f9 f9 f9 f9 f9 0x1000005a2c78: 00 06 f9 f9 f9 f9 f9 f9 =>0x1000005a2c80: 00 03 f9 f9 f9 f9 f9 f9 0x1000005a2c88: 04 f9 f9 f9 f9 f9 f9 f9 0x1000005a2c90: 05 f9 f9 f9 f9 f9 f9 f9 0x1000005a2c98: 00 f9 f9 f9 f9 f9 f9 f9 0x1000005a2ca0: 07 f9 f9 f9 f9 f9 f9 f9 Stats: 3M malloced (2M for red zones) by 3820 calls Stats: 0M realloced by 288 calls Stats: 2M freed by 1635 calls Stats: 0M really freed by 0 calls Stats: 9M (2317 full pages) mmaped in 18 calls mmaps by size class: 7:4095; 8:2047; 9:1023; 10:511; 11:255; 12:384; 13:64; 14:32; 15:16; 16:8; 17:20; 18:2; mallocs by size class: 7:2233; 8:820; 9:69; 10:96; 11:228; 12:297; 13:49; 14:1; 15:5; 16:1; 17:20; 18:1; frees by size class: 7:523; 8:492; 9:47; 10:80; 11:156; 12:291; 13:21; 14:1; 15:4; 17:20; rfrees by size class: Stats: malloc large: 27 small slow: 88 ==15267== ABORTING markus@x4 ~ % cat t.cpp int main () {}
[hjl@gnu-mic-2 gcc]$ cat /tmp/x.c int main () { } [hjl@gnu-mic-2 gcc]$ ./xgcc -B./ -c -flto /tmp/x.c ==17373== Invalid read of size 8 ==17373== at 0x8E3FE6: streamer_pack_tree_bitfields(output_block*, bitpack_d*, tree_node*) (tree-streamer-out.c:263) ==17373== by 0x71FA5F: lto_output_tree(output_block*, tree_node*, bool, bool) (lto-streamer-out.c:316) ==17373== by 0x71F06B: write_global_stream(output_block*, lto_tree_ref_encoder*) (lto-streamer-out.c:1057) ==17373== by 0x721798: produce_asm_for_decls() (lto-streamer-out.c:1101) ==17373== by 0x74A477: ipa_write_summaries_2(opt_pass*, lto_out_decl_state*) (passes.c:2430) ==17373== by 0x74B34D: ipa_write_summaries() (passes.c:2460) ==17373== by 0x5ACA9B: compile() (cgraphunit.c:1908) ==17373== by 0x5ACBA9: finalize_compilation_unit() (cgraphunit.c:2122) ==17373== by 0x4E47DF: c_write_global_declarations() (c-decl.c:10128) ==17373== by 0x7D7F4C: compile_file() (toplev.c:559) ==17373== by 0x7D9AA7: toplev_main(int, char**) (toplev.c:1881) ==17373== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17373== Address 0xb57c9da is not stack'd, malloc'd or (recently) free'd ==17373== ==17373== Invalid read of size 8 ==17373== at 0x8E4103: streamer_pack_tree_bitfields(output_block*, bitpack_d*, tree_node*) (tree-streamer-out.c:271) ==17373== by 0x71FA5F: lto_output_tree(output_block*, tree_node*, bool, bool) (lto-streamer-out.c:316) ==17373== by 0x71F06B: write_global_stream(output_block*, lto_tree_ref_encoder*) (lto-streamer-out.c:1057) ==17373== by 0x721798: produce_asm_for_decls() (lto-streamer-out.c:1101) ==17373== by 0x74A477: ipa_write_summaries_2(opt_pass*, lto_out_decl_state*) (passes.c:2430) ==17373== by 0x74B34D: ipa_write_summaries() (passes.c:2460) ==17373== by 0x5ACA9B: compile() (cgraphunit.c:1908) ==17373== by 0x5ACBA9: finalize_compilation_unit() (cgraphunit.c:2122) ==17373== by 0x4E47DF: c_write_global_declarations() (c-decl.c:10128) ==17373== by 0x7D7F4C: compile_file() (toplev.c:559) ==17373== by 0x7D9AA7: toplev_main(int, char**) (toplev.c:1881) ==17373== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17373== Address 0xb57c9db is not stack'd, malloc'd or (recently) free'd ==17373== [hjl@gnu-mic-2 gcc]$
When I add --db-attach=yes, valgrind doesn't report any error.
==17631== Invalid read of size 8 ==17631== at 0x6B2522: output_symtab() (lto-cgraph.c:589) ==17631== by 0x6B87B5: lto_output() (lto-streamer-out.c:1000) ==17631== by 0x6E2307: ipa_write_optimization_summaries_1(opt_pass*, lto_out_decl_state*) (passes.c:2542) ==17631== by 0x6E3257: ipa_write_optimization_summaries(lto_symtab_encoder_d*) (passes.c:2589) ==17631== by 0x4EA5AA: lto_main() (lto.c:2693) ==17631== by 0x76FC45: compile_file() (toplev.c:545) ==17631== by 0x7717E7: toplev_main(int, char**) (toplev.c:1881) ==17631== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17631== Address 0xb5caccc is not stack'd, malloc'd or (recently) free'd ==17631== ==17631== Invalid read of size 8 ==17631== at 0x87BDA6: streamer_pack_tree_bitfields(output_block*, bitpack_d*, tree_node*) (tree-streamer-out.c:263) ==17631== by 0x6B779F: lto_output_tree(output_block*, tree_node*, bool, bool) (lto-streamer-out.c:316) ==17631== by 0x6B6DAB: write_global_stream(output_block*, lto_tree_ref_encoder*) (lto-streamer-out.c:1057) ==17631== by 0x6B94D8: produce_asm_for_decls() (lto-streamer-out.c:1101) ==17631== by 0x6E2307: ipa_write_optimization_summaries_1(opt_pass*, lto_out_decl_state*) (passes.c:2542) ==17631== by 0x6E3257: ipa_write_optimization_summaries(lto_symtab_encoder_d*) (passes.c:2589) ==17631== by 0x4EA5AA: lto_main() (lto.c:2693) ==17631== by 0x76FC45: compile_file() (toplev.c:545) ==17631== by 0x7717E7: toplev_main(int, char**) (toplev.c:1881) ==17631== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17631== Address 0xb5afeda is not stack'd, malloc'd or (recently) free'd ==17631== ==17631== Invalid read of size 8 ==17631== at 0x87BEC3: streamer_pack_tree_bitfields(output_block*, bitpack_d*, tree_node*) (tree-streamer-out.c:271) ==17631== by 0x6B779F: lto_output_tree(output_block*, tree_node*, bool, bool) (lto-streamer-out.c:316) ==17631== by 0x6B6DAB: write_global_stream(output_block*, lto_tree_ref_encoder*) (lto-streamer-out.c:1057) ==17631== by 0x6B94D8: produce_asm_for_decls() (lto-streamer-out.c:1101) ==17631== by 0x6E2307: ipa_write_optimization_summaries_1(opt_pass*, lto_out_decl_state*) (passes.c:2542) ==17631== by 0x6E3257: ipa_write_optimization_summaries(lto_symtab_encoder_d*) (passes.c:2589) ==17631== by 0x4EA5AA: lto_main() (lto.c:2693) ==17631== by 0x76FC45: compile_file() (toplev.c:545) ==17631== by 0x7717E7: toplev_main(int, char**) (toplev.c:1881) ==17631== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17631== Address 0xb5afedb is not stack'd, malloc'd or (recently) free'd ==17631== ==17631== Invalid read of size 8 ==17631== at 0x87BFFE: streamer_pack_tree_bitfields(output_block*, bitpack_d*, tree_node*) (tree-streamer-out.c:230) ==17631== by 0x6B779F: lto_output_tree(output_block*, tree_node*, bool, bool) (lto-streamer-out.c:316) ==17631== by 0x6B6DAB: write_global_stream(output_block*, lto_tree_ref_encoder*) (lto-streamer-out.c:1057) ==17631== by 0x6B94D8: produce_asm_for_decls() (lto-streamer-out.c:1101) ==17631== by 0x6E2307: ipa_write_optimization_summaries_1(opt_pass*, lto_out_decl_state*) (passes.c:2542) ==17631== by 0x6E3257: ipa_write_optimization_summaries(lto_symtab_encoder_d*) (passes.c:2589) ==17631== by 0x4EA5AA: lto_main() (lto.c:2693) ==17631== by 0x76FC45: compile_file() (toplev.c:545) ==17631== by 0x7717E7: toplev_main(int, char**) (toplev.c:1881) ==17631== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17631== Address 0xb5c8f69 is not stack'd, malloc'd or (recently) free'd ==17631== ==17631== Invalid read of size 8 ==17631== at 0x87BDA6: streamer_pack_tree_bitfields(output_block*, bitpack_d*, tree_node*) (tree-streamer-out.c:263) ==17631== by 0x6B779F: lto_output_tree(output_block*, tree_node*, bool, bool) (lto-streamer-out.c:316) ==17631== by 0x6B6DAB: write_global_stream(output_block*, lto_tree_ref_encoder*) (lto-streamer-out.c:1057) ==17631== by 0x6B951F: produce_asm_for_decls() (lto-streamer-out.c:1101) ==17631== by 0x6E2307: ipa_write_optimization_summaries_1(opt_pass*, lto_out_decl_state*) (passes.c:2542) ==17631== by 0x6E3257: ipa_write_optimization_summaries(lto_symtab_encoder_d*) (passes.c:2589) ==17631== by 0x4EA5AA: lto_main() (lto.c:2693) ==17631== by 0x76FC45: compile_file() (toplev.c:545) ==17631== by 0x7717E7: toplev_main(int, char**) (toplev.c:1881) ==17631== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17631== Address 0xb5c55da is not stack'd, malloc'd or (recently) free'd ==17631== ==17631== Invalid read of size 8 ==17631== at 0x87BEC3: streamer_pack_tree_bitfields(output_block*, bitpack_d*, tree_node*) (tree-streamer-out.c:271) ==17631== by 0x6B779F: lto_output_tree(output_block*, tree_node*, bool, bool) (lto-streamer-out.c:316) ==17631== by 0x6B6DAB: write_global_stream(output_block*, lto_tree_ref_encoder*) (lto-streamer-out.c:1057) ==17631== by 0x6B951F: produce_asm_for_decls() (lto-streamer-out.c:1101) ==17631== by 0x6E2307: ipa_write_optimization_summaries_1(opt_pass*, lto_out_decl_state*) (passes.c:2542) ==17631== by 0x6E3257: ipa_write_optimization_summaries(lto_symtab_encoder_d*) (passes.c:2589) ==17631== by 0x4EA5AA: lto_main() (lto.c:2693) ==17631== by 0x76FC45: compile_file() (toplev.c:545) ==17631== by 0x7717E7: toplev_main(int, char**) (toplev.c:1881) ==17631== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17631== Address 0xb5c55db is not stack'd, malloc'd or (recently) free'd ==17631==
==17715== Invalid read of size 8 ==17715== at 0x6B2522: output_symtab() (lto-cgraph.c:589) ==17715== by 0x6B87B5: lto_output() (lto-streamer-out.c:1000) ==17715== by 0x6E2307: ipa_write_optimization_summaries_1(opt_pass*, lto_out_decl_state*) (passes.c:2542) ==17715== by 0x6E3257: ipa_write_optimization_summaries(lto_symtab_encoder_d*) (passes.c:2589) ==17715== by 0x4EA5AA: lto_main() (lto.c:2693) ==17715== by 0x76FC45: compile_file() (toplev.c:545) ==17715== by 0x7717E7: toplev_main(int, char**) (toplev.c:1881) ==17715== by 0x38F3A21674: (below main) (in /usr/lib64/libc-2.15.so) ==17715== Address 0xb5caccc is not stack'd, malloc'd or (recently) free'd 588 bp = bitpack_create (ob->main_stream); 589 bp_pack_value (&bp, ref->use, 2); 590 streamer_write_bitpack (&bp); 591 nref = lto_symtab_encoder_lookup (encoder, ref->referred); 592 gcc_assert (nref != LCC_NOT_FOUND); 593 streamer_write_hwi_stream (ob->main_stream, nref); (gdb) p ref $1 = (ipa_ref *) 0xb5cacb0 (gdb) p ref->use $2 = IPA_REF_LOAD (gdb) p &ref->use $3 = (ipa_ref_use *) 0xb5caccc (gdb)
There is a bad memory access in LTO.
It can be reproduced with LTO bootstrap on hjl/valgrind branch at http://gcc.gnu.org/git/?p=gcc.git;a=summary with --enable-checking=valgrind.
I got /tmp/cc5sWfOD.s: Assembler messages: /tmp/cc5sWfOD.s:824391: Error: invalid character (0xf7) in mnemonic make[7]: *** [/tmp/ccpgVF41.ltrans24.ltrans.o] Error 1 lto-wrapper: make returned 2 exit status /usr/local/bin/ld: lto-wrapper failed collect2: error: ld returned 1 exit status make[6]: *** [cc1] Error 1 make[6]: *** Waiting for unfinished jobs.... In .section .debug_info,"",@progbits, there are 824390 .byte 0x30 824391 ÷ÿÿè^H¨=: 824392 .uleb128 0x7
On hjl/asan branch, I got (gdb) r Starting program: /export/build/gnu/gcc-lto-asan/build-x86_64-linux/prev-gcc/cc1 -fpreprocessed /tmp/x.i -quiet -dumpbase x.i -mtune=generic -march=x86-64 -auxbase x -version -flto -o x.s [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". GNU C (GCC) version 4.8.0 20121117 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20121117 (experimental), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C (GCC) version 4.8.0 20121117 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20121117 (experimental), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 0e1eacd90672aa3f29692f9d3d99b1be ================================================================= Breakpoint 5, __asan_report_error (pc=25644090, bp=140737488345632, sp=140737488345624, addr=34167900, is_write=<optimized out>, access_size=4) at /export/gnu/import/git/gcc/libsanitizer/asan/asan_report.cc:464 464 bug_descr, (void*)addr, pc, bp, sp); (gdb) bt #0 __asan_report_error (pc=25644090, bp=140737488345632, sp=140737488345624, addr=34167900, is_write=<optimized out>, access_size=4) at /export/gnu/import/git/gcc/libsanitizer/asan/asan_report.cc:464 #1 0x0000000001f6bc04 in __asan::__asan_report_load4 (addr=<optimized out>) at /export/gnu/import/git/gcc/libsanitizer/asan/asan_rtl.cc:194 #2 0x0000000001874c3a in lto_write_options () at /export/gnu/import/git/gcc/gcc/lto-opts.c:92 #3 0x000000000135e932 in produce_asm_for_decls () at /export/gnu/import/git/gcc/gcc/lto-streamer-out.c:1407 #4 0x00000000012a3458 in ipa_write_summaries_2(opt_pass*, lto_out_decl_state*) [clone .565573] (pass=0x2689880 <pass_ipa_lto_finish_out>, state=0x7ffff18cce40) at /export/gnu/import/git/gcc/gcc/passes.c:2430 #5 0x000000000135b2a0 in ipa_write_summaries_1 (encoder=0x7ffff7d6c5c0) at /export/gnu/import/git/gcc/gcc/passes.c:2460 #6 ipa_write_summaries () at /export/gnu/import/git/gcc/gcc/passes.c:2514 #7 0x0000000000b16399 in ipa_passes () at /export/gnu/import/git/gcc/gcc/cgraphunit.c:1908 #8 compile () at /export/gnu/import/git/gcc/gcc/cgraphunit.c:1994 #9 0x0000000000b16d2a in finalize_compilation_unit () at /export/gnu/import/git/gcc/gcc/cgraphunit.c:2122 #10 0x0000000000b17271 in c_write_global_declarations () at /export/gnu/import/git/gcc/gcc/c/c-decl.c:10128 #11 0x0000000000b2c258 in compile_file () ---Type <return> to continue, or q <return> to quit--- at /export/gnu/import/git/gcc/gcc/toplev.c:559 #12 0x0000000000b2e4b0 in do_compile () at /export/gnu/import/git/gcc/gcc/toplev.c:1881 #13 toplev_main (argc=14, argv=0x7fffffffe108) at /export/gnu/import/git/gcc/gcc/toplev.c:1957 #14 0x00000038f3a21675 in __libc_start_main () from /lib64/libc.so.6 #15 0x000000000056df51 in _start () (gdb) c Continuing. ==1834== ERROR: AddressSanitizer global-buffer-overflow on address 0x000002095c5c at pc 0x1874c3a bp 0x7fffffffda20 sp 0x7fffffffda18 READ of size 4 at 0x000002095c5c thread T0 #0 0x1874c39 (/export/build/gnu/gcc-lto-asan/build-x86_64-linux/prev-gcc/cc1+0x1874c39) 0x000002095c5c is located 4 bytes to the left of global variable '__FUNCTION__ (/tmp/ccHvMX0o.ltrans5.o)' (0x2095c60) of size 22 '__FUNCTION__ (/tmp/ccHvMX0o.ltrans5.o)' is ascii string 'c_parser_if_statement' 0x000002095c5c is located 30 bytes to the right of global variable '__FUNCTION__ (/tmp/ccHvMX0o.ltrans5.o)' (0x2095c20) of size 30 '__FUNCTION__ (/tmp/ccHvMX0o.ltrans5.o)' is ascii string 'c_parser_declaration_or_fndef' Shadow byte and word: 0x100000412b8b: f9 0x100000412b88: f9 f9 f9 f9 00 00 06 f9 More shadow bytes: 0x100000412b68: f9 f9 f9 f9 00 00 03 f9 0x100000412b70: f9 f9 f9 f9 00 00 06 f9 0x100000412b78: f9 f9 f9 f9 00 00 03 f9 0x100000412b80: f9 f9 f9 f9 00 00 00 06 =>0x100000412b88: f9 f9 f9 f9 00 00 06 f9 0x100000412b90: f9 f9 f9 f9 00 00 00 02 0x100000412b98: f9 f9 f9 f9 00 00 00 01 0x100000412ba0: f9 f9 f9 f9 00 00 06 f9 0x100000412ba8: f9 f9 f9 f9 00 00 04 f9 Stats: 2M malloced (2M for red zones) by 3332 calls Stats: 0M realloced by 285 calls Stats: 1M freed by 1187 calls Stats: 0M really freed by 0 calls Stats: 8M (2059 full pages) mmaped in 16 calls mmaps by size class: 7:4095; 8:2047; 9:1023; 10:511; 11:255; 12:128; 13:64; 14:32; 15:16; 16:8; 17:20; 18:2; mallocs by size class: 7:2075; 8:747; 9:65; 10:95; 11:226; 12:52; 13:44; 14:1; 15:5; 16:1; 17:20; 18:1; frees by size class: 7:457; 8:359; 9:46; 10:80; 11:154; 12:46; 13:20; 14:1; 15:4; 17:20; rfrees by size class: Stats: malloc large: 27 small slow: 54 ==1834== ABORTING [Inferior 1 (process 1834) exited with code 01] (gdb)
LTO gets miscompiled. If I configure with: ~/gcc/configure --disable-bootstrap --disable-werror --disable-multilib --enable-languages=c,c++ --enable-checking=yes,valgrind and build with gcc-4.7, then the bad memory access in LTO vanishes. This could be a dup of Bug 55430 (LRA miscompilation issue).
I still got the same failure as in comment #13 with revision 193763.
The issue from comment 5 onward started with: Author: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu Nov 3 14:46:26 2011 +0000 2011-11-03 Richard Guenther <rguenther@suse.de> PR lto/44965 * lto-opts.c: Re-implement. * lto-streamer.h (lto_register_user_option): Remove. (lto_read_file_options): Likewise. (lto_reissue_options): Likewise. (lto_clear_user_options): Likewise. (lto_clear_file_options): Likewise. * opts-global.c (post_handling_callback): Remove. (set_default_handlers): Do not set post_handling_callback. (decode_options): Remove LTO specific code. * lto-wrapper.c (merge_and_complain): New function. (run_gcc): Read all input file options and prepend a merged set before the linker driver options. * gcc.c (driver_post_handling_callback): Remove. (set_option_handlers): Do not set post_handling_callback. * opts-common.c (handle_option): Do not call post_handling_callback. * opts.h (struct cl_option_handlers): Remove post_handling_callback. lto/ * lto-lang.c (lto_post_options): Do not read file options. * lto.c (lto_read_all_file_options): Remove. (lto_init): Call lto_set_in_hooks here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180827 138bc75d-0d04-0410-961f-82ee72b054a4
LTO miscompiled: /* Skip frontend and driver specific options here. */ if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO))) continue; with extern const struct cl_option cl_options[]; Stage 1 GCC shows Starting program: /export/build/gnu/gcc-lto-asan/build-x86_64-linux/stage1-gcc/cc1 -fpreprocessed /tmp/x.i -quiet -dumpbase x.i -mtune=generic -march=x86-64 -auxbase x -version -flto -o x.s Breakpoint 6, main (argc=14, argv=0x7fffffffe0f8) at /export/gnu/import/git/gcc/gcc/main.c:36 36 return toplev_main (argc, argv); (gdb) p cl_options_count $6 = 1246 (gdb) p ((struct cl_option *) cl_options)[0] $7 = {opt_text = 0x13ef100 "-###", help = 0x0, missing_argument_error = 0x0, warn_message = 0x0, alias_arg = 0x0, neg_alias_arg = 0x0, alias_target = 1246, back_chain = 1246, opt_len = 3 '\003', neg_index = -1, flags = 524288, cl_disabled = 0, cl_separate_nargs = 0, cl_separate_alias = 0, cl_negative_alias = 0, cl_no_driver_arg = 0, cl_reject_driver = 0, cl_reject_negative = 0, cl_missing_ok = 0, cl_uinteger = 0, cl_host_wide_int = 0, cl_tolower = 0, cl_report = 0, flag_var_offset = 65535, var_enum = 0, var_type = CLVC_BOOLEAN, var_value = 0} (gdb) p cl_options[0] $8 = {opt_text = 0x13ef100 "-###", help = 0x0, missing_argument_error = 0x0, warn_message = 0x0, alias_arg = 0x0, neg_alias_arg = 0x0, alias_target = 1246, back_chain = 1246, opt_len = 3 '\003', neg_index = -1, flags = 524288, cl_disabled = 0, cl_separate_nargs = 0, cl_separate_alias = 0, cl_negative_alias = 0, cl_no_driver_arg = 0, cl_reject_driver = 0, cl_reject_negative = 0, cl_missing_ok = 0, cl_uinteger = 0, cl_host_wide_int = 0, cl_tolower = 0, cl_report = 0, flag_var_offset = 65535, var_enum = 0, var_type = CLVC_BOOLEAN, var_value = 0} (gdb) Stage 2 GCC shows Starting program: /export/build/gnu/gcc-lto-asan/build-x86_64-linux/prev-gcc/cc1 -fpreprocessed /tmp/x.i -quiet -dumpbase x.i -mtune=generic -march=x86-64 -auxbase x -version -flto -o x.s [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Breakpoint 6, main (argc=14, argv=0x7fffffffe108) at /export/gnu/import/git/gcc/gcc/main.c:36 36 return toplev_main (argc, argv); (gdb) p ((struct cl_option *) cl_options)[0] $24 = { opt_text = 0x432d2d002323232d <Address 0x432d2d002323232d out of bounds>, help = 0x485441505353414c <Address 0x485441505353414c out of bounds>, missing_argument_error = 0x772d6c6c612d2d00 <Address 0x772d6c6c612d2d00 out of bounds>, warn_message = 0x73676e696e7261 <Address 0x73676e696e7261 out of bounds>, alias_arg = 0x2d0069736e612d2d <Address 0x2d0069736e612d2d out of bounds>, neg_alias_arg = 0x6c626d657373612d <Address 0x6c626d657373612d out of bounds>, alias_target = 101, back_chain = 11565, opt_len = 97 'a', neg_index = 1627419762, flags = 1919251315, cl_disabled = 0, cl_separate_nargs = 2, cl_separate_alias = 0, cl_negative_alias = 1, cl_no_driver_arg = 1, cl_reject_driver = 1, cl_reject_negative = 0, cl_missing_ok = 1, cl_uinteger = 0, cl_host_wide_int = 0, cl_tolower = 1, cl_report = 0, flag_var_offset = 28271, var_enum = 27936, var_type = 1735289203, var_value = 3242718661498139237} (gdb)
I think LTO is confused extern const struct cl_option cl_options[]; with extern const struct cl_option cl_options*;
The same issue can be reproduced with this patch: diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c index a235f41..cd3730b 100644 --- a/gcc/lto-opts.c +++ b/gcc/lto-opts.c @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ +#define BAD_LTO #include "config.h" #include "system.h" #include "coretypes.h" diff --git a/gcc/opts.h b/gcc/opts.h index b6a4361..14a31e4 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -122,7 +122,11 @@ struct cl_option_state { char ch; }; +#ifdef BAD_LTO +extern const struct cl_option *cl_options; +#else extern const struct cl_option cl_options[]; +#endif extern const unsigned int cl_options_count; extern const char *const lang_names[]; extern const unsigned int cl_lang_count;
With: diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c index a235f41..1c05534 100644 --- a/gcc/lto-opts.c +++ b/gcc/lto-opts.c @@ -93,6 +93,8 @@ lto_write_options (void) { struct cl_decoded_option *option = &save_decoded_options[i]; + gcc_assert (option->opt_index < cl_options_count); + /* Skip frontend and driver specific options here. */ if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO))) continue; I get: markus@x4 gcc_build_dir % ./gcc/xgcc -B/var/tmp/gcc_build_dir/./gcc/ -c -flto /home/markus/t.c /home/markus/t.c:1:1: internal compiler error: in lto_write_options, at lto-opts.c:96
This was introduced between revision 191465 and revision 191714.
This is caused by revision 191466: http://gcc.gnu.org/ml/gcc-cvs/2012-09/msg00623.html
Another problem with revision 191466 is we lost debug info on cl_options. With revision 191465, I got (gdb) whatis cl_options type = const struct cl_option [1221] (gdb) After revision 191466, I got (gdb) whatis cl_option type = cl_option (gdb)
(In reply to comment #23) > Another problem with revision 191466 is we lost > debug info on cl_options. With revision 191465, > I got > > (gdb) whatis cl_options > type = const struct cl_option [1221] > (gdb) > > After revision 191466, I got > > (gdb) whatis cl_option > type = cl_option > (gdb) It was (gdb) whatis cl_options type = <data variable, no debug info> (gdb) whatis cl_enums type = <data variable, no debug info> (gdb) whatis cl_enums_count type = <data variable, no debug info> (gdb)
(In reply to comment #23) > Another problem with revision 191466 is we lost > debug info on cl_options. With revision 191465, > I got > > (gdb) whatis cl_options > type = const struct cl_option [1221] > (gdb) > > After revision 191466, I got > > (gdb) whatis cl_option > type = cl_option > (gdb) This means that somewhere there is a cl_option definition that may prevail that has size 1. lto_symtab_resolve_symbols is supposed to pick the largest one. The cl_options definition that matters is in options.c, created const struct cl_option cl_options[] = { ... } maybe it's size isn't finished? Also || (DECL_SIZE (prevailing->symbol.decl) == DECL_SIZE (e->symbol.decl) is fragile - use tree_int_cst_eq. I suppose we don't have anything like a testcase?
(In reply to comment #25) > This means that somewhere there is a cl_option definition that may prevail > that has size 1. lto_symtab_resolve_symbols is supposed to pick the > largest one. The cl_options definition that matters is in options.c, > created > > const struct cl_option cl_options[] = { ... } > > maybe it's size isn't finished? Isn't just we lost debug info on arrays. We lost debug info on all data variables. You can pick one and verify it. > Also > > || (DECL_SIZE (prevailing->symbol.decl) == DECL_SIZE (e->symbol.decl) > > is fragile - use tree_int_cst_eq. I suppose we don't have anything > like a testcase? I don't have a testcase, except for GCC itself.
Author: hjl Date: Tue Nov 27 13:56:31 2012 New Revision: 193848 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193848 Log: Handle OPT_SPECIAL_XXX in LTO PR lto/54795 * lto-opts.c (lto_write_options): Also handle OPT_SPECIAL_unknown, OPT_SPECIAL_ignore and OPT_SPECIAL_program_name. PR lto/55474 * lto-wrapper.c (merge_and_complain): Handle OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and OPT_SPECIAL_input_file. Modified: trunk/gcc/ChangeLog trunk/gcc/lto-opts.c trunk/gcc/lto-wrapper.c
Author: hjl Date: Wed Nov 28 14:38:40 2012 New Revision: 193893 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193893 Log: Handle OPT_SPECIAL_XXX in LTO Backported from mainline PR lto/54795 * lto-opts.c (lto_write_options): Also handle OPT_SPECIAL_unknown, OPT_SPECIAL_ignore and OPT_SPECIAL_program_name. PR lto/55474 * lto-wrapper.c (merge_and_complain): Handle OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and OPT_SPECIAL_input_file. Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/lto-opts.c branches/gcc-4_7-branch/gcc/lto-wrapper.c
Fixed for 4.7.3 and 4.8.