[Bug other/110885] New: "undefined reference" when using both "-fdebug-types-section" and "-gsplit-dwarf"

2023-08-02 Thread linh.lrd at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110885

Bug ID: 110885
   Summary: "undefined reference" when using both
"-fdebug-types-section" and "-gsplit-dwarf"
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: other
  Assignee: unassigned at gcc dot gnu.org
  Reporter: linh.lrd at gmail dot com
  Target Milestone: ---

[Bug debug/110885] "undefined reference" when using both "-fdebug-types-section" and "-gsplit-dwarf"

2023-08-03 Thread linh.lrd at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110885

--- Comment #1 from Ling Nguyen  ---
Consider this program:
struct X
{
static void foo() {}
};

struct Y
{
template
static void bar() {}
};

int main()
{
Y::bar();
return 0;
}

If it's compiled using something like: gcc -gsplit-dwarf -fdebug-types-section.
the linker will complain: undefined reference to `X::foo()'
More details here: https://godbolt.org/z/qnj56e769

[Bug debug/110885] [10/11/12/13/14 Regression] "undefined reference" when using both "-fdebug-types-section" and "-gsplit-dwarf" and inline function as a template argument

2023-08-03 Thread linh.lrd at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110885

--- Comment #3 from Ling Nguyen  ---
Thanks for quick responses.

A further look into the issue:
I believe there is bug in this piece of code:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/dwarf2out.cc;h=fa0fe4c41bbd5b13aa5fe6cad6e7d39bbd82174a;hb=HEAD#l8501

It should probably be:
if (is_template_instantiation (c))
  {
/* Instantiated templates do not need to be cloned into the
   type unit.  Just move the DIE and its children back to
   the skeleton tree (in the main CU).  */
remove_child_with_prev (c, prev);
generate_skeleton_ancestor_tree (parent);
add_child_die (parent->new_die, c);
c = prev;
  }

Don't mean to teach a fish to swim here, because I'm no expert. Just want to
help to reduce the search space.
By the way, any chance for a fix (whenever it is) to land on gcc 10.2, as we
are fixed to it?