This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][2/2] early LTO debug, main part
On Tue, 22 Aug 2017, Szabolcs Nagy wrote:
> On 04/08/17 13:21, Richard Biener wrote:
> > On Thu, 3 Aug 2017, Jason Merrill wrote:
> >> OK if testing passes.
> >
> > Thanks. Meanwhile testing passed.
> >
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, LTO bootstrapped
> > on x86_64-unknown-linux-gnu (both all languages). I've successfully
> > built SPEC CPU 2006 with -flto -g (provides reasonable Fortran coverage).
> > I've successfully ran the GCC testsuite with -flto -g which shows lots
> > of FAILs but doesn't regress in any unexpected ways compared to before
> > the patches.
> >
> > I'll ping Ian about the simple-object part again and will apply
> > earliest at Aug 14th.
> >
> > Richard.
> >
>
> on aarch64_be-none-elf i see
>
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O3 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O3 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O3 (test for excess errors)
> PASS->FAIL: gcc.dg/lto/20090914-1 c_lto_20090914-1_0.o-c_lto_20090914-1_0.o link, -flto
> PASS->FAIL: gcc.dg/lto/20100426 c_lto_20100426_0.o-c_lto_20100426_0.o link, -r -nostdlib -flto -g
> PASS->FAIL: gcc.dg/lto/20111207-2 c_lto_20111207-2_0.o-c_lto_20111207-2_0.o link, -g -O -flto
> PASS->FAIL: gcc.dg/lto/20111213-1 c_lto_20111213-1_0.o-c_lto_20111213-1_0.o link, -flto -g
> PASS->FAIL: gcc.dg/lto/pr51572-1 c_lto_pr51572-1_0.o-c_lto_pr51572-1_0.o link, -flto -g
> PASS->FAIL: gcc.dg/lto/pr53470 c_lto_pr53470_0.o-c_lto_pr53470_0.o link, -flto -g
> PASS->FAIL: gcc.dg/lto/pr59323 c_lto_pr59323_0.o-c_lto_pr59323_0.o link, -O2 -g -flto
> PASS->FAIL: gcc.dg/lto/pr59323-2 c_lto_pr59323-2_0.o-c_lto_pr59323-2_0.o link, -O2 -g -flto
> PASS->FAIL: gcc.dg/pr43557-1.c (test for excess errors)
>
> linking seems to fail with
>
> /tmp/ccqAb1Wfdebugobjtem: file not recognized: Bad value
> collect2: error: ld returned 1 exit status
> lto-wrapper: fatal error: B/gcc/xgcc returned 1 exit status
> compilation terminated.
> P/aarch64_be-none-elf/bin/ld: error: lto-wrapper failed
> collect2: error: ld returned 1 exit status
> compiler exited with status 1
Can you file a bugreport please? Can you investigate a bit, I suspect
a simple int main() {} and ./xgcc -B. -flto -g t.c fails the same way.
With -save-temps -v you should be able to inspect the generated
debugobj with readelf.
Is this a native compiler or a cross-compiler? [I suspect endianess
issues somewhere?]
Thanks,
Richard.
> similar regressions on g++ tests:
>
> PASS->FAIL: g++.dg/lto/20101010-4 cp_lto_20101010-4_0.o-cp_lto_20101010-4_0.o link, -std=c++0x -flto -g -r
> -nostdlib
> PASS->FAIL: g++.dg/lto/20101015-2 cp_lto_20101015-2_0.o-cp_lto_20101015-2_0.o link, -g -flto
> PASS->FAIL: g++.dg/lto/pr42987 cp_lto_pr42987_0.o-cp_lto_pr42987_1.o link, -flto -flto-partition=none -g
> PASS->FAIL: g++.dg/lto/pr42987 cp_lto_pr42987_0.o-cp_lto_pr42987_1.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr48207 cp_lto_pr48207_0.o-cp_lto_pr48207_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr48207-2 cp_lto_pr48207-2_0.o-cp_lto_pr48207-2_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr48207-3 cp_lto_pr48207-3_0.o-cp_lto_pr48207-3_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr48354-1 cp_lto_pr48354-1_0.o-cp_lto_pr48354-1_0.o link, -g -flto
> PASS->FAIL: g++.dg/lto/pr48508-1 cp_lto_pr48508-1_0.o-cp_lto_pr48508-1_1.o link, -g -O2 -flto
> -flto-partition=none
> PASS->FAIL: g++.dg/lto/pr51564-1 cp_lto_pr51564-1_0.o-cp_lto_pr51564-1_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr51567-1 cp_lto_pr51567-1_0.o-cp_lto_pr51567-1_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr51572-2 cp_lto_pr51572-2_0.o-cp_lto_pr51572-2_0.o link, -g -flto
> PASS->FAIL: g++.dg/lto/pr51573-1 cp_lto_pr51573-1_0.o-cp_lto_pr51573-1_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr51650-1 cp_lto_pr51650-1_0.o-cp_lto_pr51650-1_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr51650-2 cp_lto_pr51650-2_0.o-cp_lto_pr51650-2_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr51650-3 cp_lto_pr51650-3_0.o-cp_lto_pr51650-3_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr52605 cp_lto_pr52605_0.o-cp_lto_pr52605_0.o link, -flto -g
> PASS->FAIL: g++.dg/lto/pr53470 cp_lto_pr53470_0.o-cp_lto_pr53470_0.o link, -g -flto
> PASS->FAIL: g++.dg/lto/pr65193 cp_lto_pr65193_0.o-cp_lto_pr65193_0.o link, -fPIC -r -nostdlib -flto -O2 -g
> PASS->FAIL: g++.dg/lto/pr65316 cp_lto_pr65316_0.o-cp_lto_pr65316_1.o link, -flto -std=c++11 -g2
> -fno-lto-odr-type-merging -O2
> PASS->FAIL: g++.dg/lto/pr65549 cp_lto_pr65549_0.o-cp_lto_pr65549_0.o link, -std=gnu++14 -flto -g
> PASS->FAIL: g++.dg/lto/pr65549 cp_lto_pr65549_0.o-cp_lto_pr65549_0.o link, -std=gnu++14 -flto -g -O2
> -fno-inline -flto-partition=max
> PASS->FAIL: g++.dg/lto/pr69077 cp_lto_pr69077_0.o-cp_lto_pr69077_1.o link, -O3 -g -flto
> PASS->FAIL: g++.dg/lto/pr69137 cp_lto_pr69137_0.o-cp_lto_pr69137_0.o link, -std=c++11 -g -flto
> PASS->FAIL: g++.dg/lto/pr79000 cp_lto_pr79000_0.o-cp_lto_pr79000_1.o link, -flto -g
> NA->FAIL: g++.dg/template/pr81899.C -std=c++98 (test for excess errors)
>
> > 2017-08-04 Richard Biener <rguenther@suse.de>
> >
> > * debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
> > register_external_die hooks.
> > (debug_false_tree_charstarstar_uhwistar): Declare.
> > (debug_nothing_tree_charstar_uhwi): Likewise.
> > * debug.c (do_nothing_debug_hooks): Adjust.
> > (debug_false_tree_charstarstar_uhwistar): New do nothing.
> > (debug_nothing_tree_charstar_uhwi): Likewise.
> > * dbxout.c (dbx_debug_hooks): Adjust.
> > (xcoff_debug_hooks): Likewise.
> > * sdbout.c (sdb_debug_hooks): Likewise.
> > * vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
> >
> > * dwarf2out.c (macinfo_label_base): New global.
> > (dwarf2out_register_external_die): New function for the
> > register_external_die hook.
> > (dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
> > (dwarf2_debug_hooks): Use them.
> > (dwarf2_lineno_debug_hooks): Adjust.
> > (struct die_struct): Add with_offset flag.
> > (DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
> > DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
> > DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
> > DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
> > DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
> > DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
> > defining section names for the early LTO debug variants.
> > (reset_indirect_string): New helper.
> > (add_AT_external_die_ref): Helper for dwarf2out_register_external_die.
> > (print_dw_val): Add support for offsetted symbol references.
> > (get_ultimate_context): Split out from is_cxx.
> > (is_cxx): Use get_ultimate_context.
> > (is_fortran): Add decl overload.
> > (compute_comp_unit_symbol): Split out worker from
> > compute_section_prefix.
> > (compute_section_prefix): Call compute_comp_unit_symbol and
> > set comdat_type_p here.
> > (output_die): Skip DIE symbol output for the LTO added one.
> > Handle DIE symbol references with offset.
> > (output_comp_unit): Guard section name mangling properly.
> > For LTO debug sections emit a symbol at the section beginning
> > which we use to refer to its DIEs.
> > (add_abstract_origin_attribute): For DIEs registered via
> > dwarf2out_register_external_die directly refer to the early
> > DIE rather than indirectly through the shadow one we created.
> > Remove obsolete call to dwarf2out_abstract_function for
> > non-function/block origins.
> > (gen_array_type_die): When generating early LTO debug do
> > not emit DW_AT_string_length.
> > (gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
> > late when in LTO. As suggested place a gcc_unreachable for
> > the DECL_ABSTRACT_P case.
> > (gen_subprogram_die): Avoid another specification DIE
> > for early built declarations/definitions for the late LTO case.
> > (gen_variable_die): Add type references for late duplicated VLA dies
> > when in late LTO.
> > (gen_inlined_subroutine_die): Do not call dwarf2out_abstract_function,
> > we have the abstract instance already.
> > (process_scope_var): Adjust decl DIE contexts in LTO which
> > first puts them in limbo.
> > (gen_decl_die): Do not generate type DIEs late apart from
> > types for VLAs or for decls we do not yet have a DIE. Do not
> > call dwarf2out_abstract_function late.
> > (dwarf2out_early_global_decl): Make sure to create DIEs
> > for abstract instances of a decl first.
> > (dwarf2out_late_global_decl): Adjust comment.
> > (output_macinfo_op): With multiple macro sections use
> > macinfo_label_base to distinguish labels.
> > (output_macinfo): Likewise. Update macinfo_label_base.
> > Pass in the line info label.
> > (note_variable_value_in_expr): When generating LTO resolve
> > all variable values here by generating DIEs as needed.
> > (init_sections_and_labels): Add early LTO debug flag parameter
> > and generate different sections and names if set. Add generation
> > counter for the labels so we can have multiple of them.
> > (reset_dies): Helper to allow DIEs to be output multiple times.
> > (dwarf2out_finish): When outputting DIEs to the fat part of an
> > LTO object first reset DIEs.
> > (dwarf2out_early_finish): Output early DIEs when generating LTO.
> >
> > Cleanups we can do (and need) when removing the "old" LTO path and add
> > the early LTO path.
> >
> > (set_decl_abstract_flags): Remove.
> > (set_block_abstract_flags): Likewise.
> > (dwarf2out_abstract_function): Treat the early generated DIEs
> > as the abstract copy and only add DW_AT_inline and
> > DW_AT_artificial here and call set_decl_origin_self.
> > If the DIE has an abstract origin don't do anything.
> >
> > * tree.c (free_lang_data): Build a dummy TRANSLATION_UNIT_DECL
> > if we have none yet (Go fails to build one, PR78628).
> > * lto-streamer-in.c: Include debug.h.
> > (dref_queue): New global.
> > (lto_read_tree_1): Stream in DIE references.
> > (lto_input_tree): Register DIE references.
> > (input_function): Stream DECL_DEBUG_ARGS.
> > * lto-streamer-out.c: Include debug.h.
> > (lto_write_tree_1): Output DIE references.
> > (DFS::DFS_write_tree_body): Follow DECL_ABSTRACT_ORIGIN.
> > Force a TRANSLATION_UNIT_DECL DECL_CONTEXT for file-scope decls.
> > (output_function): Stream DECL_DEBUG_ARGS.
> > * tree-streamer-in.c (lto_input_ts_decl_common_tree_pointers):
> > Stream DECL_ABSTRACT_ORIGIN.
> > * tree-streamer-out.c (write_ts_decl_common_tree_pointers): Likewise.
> > (write_ts_decl_minimal_tree_pointers): Force a TRANSLATION_UNIT_DECL
> > DECL_CONTEXT for file-scope decls.
> > * lto-streamer.h (struct dref_entry): Declare.
> > (dref_queue): Likewise.
> > * cfgexpand.c (pass_expand::execute): Do not call the
> > outlining_inline_function hook here.
> >
> > * lto-wrapper.c (debug_obj): New global.
> > (tool_cleanup): Unlink it if required.
> > (debug_objcopy): New function.
> > (run_gcc): Handle early debug sections in the IL files by
> > extracting them to separate files, partially linkin them and
> > feeding the result back as result to the linker.
> >
> > * config/darwin.h (DEBUG_LTO_INFO_SECTION, DEBUG_LTO_ABBREV_SECTION,
> > DEBUG_LTO_MACINFO_SECTION, DEBUG_LTO_LINE_SECTION,
> > DEBUG_STR_LTO_SECTION, DEBUG_LTO_MACRO_SECTION): Put early debug
> > sections into a separate segment.
> > * config/darwin.c (darwin_asm_named_section): Handle __GNU_DWARF_LTO
> > segments.
> > (darwin_asm_dwarf_section): Likewise.
> > (darwin_asm_output_dwarf_offset): Likewise.
> >
> > * config/i386/i386.c (make_resolver_func): Set DECL_IGNORED_P.
> >
> > lto/
> > * lto.c (unify_scc): Truncate DIE reference queue for dropped SCCs.
> > (lto_read_decls): Process TRANSLATION_UNIT_DECLs. Remove
> > TYPE_DECL debug processing, register DIE references from
> > prevailing SCCs with the debug machinery.
> > (lto_section_with_id): Handle LTO debug sections.
> >
> > libstdc++/
> > * testsuite/libstdc++-prettyprinters/prettyprinters.exp: Run all
> > tests with -flto as well if supported.
> >
> > * c-c++-common/asan/global-overflow-1.c: Adjust diagnostic location
> > regex to handle the LTO case.
> > * c-c++-common/asan/heap-overflow-1.c: Likewise.
> > * c-c++-common/asan/misalign-1.c: Likewise.
> > * c-c++-common/asan/misalign-2.c: Likewise.
> > * c-c++-common/asan/null-deref-1.c: Likewise.
> > * c-c++-common/asan/stack-overflow-1.c: Likewise.
> > * c-c++-common/asan/strncpy-overflow-1.c: Likewise.
> > * c-c++-common/asan/use-after-free-1.c: Likewise.
> > * c-c++-common/asan/alloca_big_alignment.c: Likewise.
> > * c-c++-common/asan/alloca_detect_custom_size.c: Likewise.
> > * c-c++-common/asan/alloca_overflow_partial.c: Likewise.
> > * c-c++-common/asan/alloca_overflow_right.c: Likewise.
> > * c-c++-common/asan/alloca_underflow_left.c: Likewise.
> > * g++.dg/asan/large-func-test-1.C: Likewise.
> > * gfortran.dg/save_6.f90: Add -flto -g variant of save_5.f90.
> >
> ...
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)