* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
@ 2022-12-02 11:58 ` marxin at gcc dot gnu.org
2022-12-02 12:07 ` marxin at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-12-02 11:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dmalcolm at gcc dot gnu.org
Last reconfirmed| |2022-12-02
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
2022-12-02 11:58 ` [Bug bootstrap/107950] " marxin at gcc dot gnu.org
@ 2022-12-02 12:07 ` marxin at gcc dot gnu.org
2022-12-02 15:05 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-12-02 12:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Oh, the function has 2 different definitions in C and C++ FE:
gcc/c/c-objc-common.cc:range_label_for_type_mismatch::get_text (unsigned
/*range_idx*/) const
gcc/cp/error.cc:range_label_for_type_mismatch::get_text (unsigned
/*range_idx*/) const
And so that's why I see the linker error for 'lto' binary, interesting..
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
2022-12-02 11:58 ` [Bug bootstrap/107950] " marxin at gcc dot gnu.org
2022-12-02 12:07 ` marxin at gcc dot gnu.org
@ 2022-12-02 15:05 ` rguenth at gcc dot gnu.org
2022-12-02 19:08 ` marxin at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-02 15:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I wonder why the linker complains? Isn't this like
t.h
class X { foo (); bar (); baz (); };
and splitting the foo/bar/baz implementations to three TUs and then linking
two of them partially?
That is, it looks like we reference the vtable but don't emit it here or
we end up with an ODR violation because somehow LTO thinks it can
privatize some of it?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (2 preceding siblings ...)
2022-12-02 15:05 ` rguenth at gcc dot gnu.org
@ 2022-12-02 19:08 ` marxin at gcc dot gnu.org
2022-12-02 19:22 ` redi at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-12-02 19:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> I wonder why the linker complains? Isn't this like
>
> t.h
>
> class X { foo (); bar (); baz (); };
>
> and splitting the foo/bar/baz implementations to three TUs and then linking
> two of them partially?
I've just tried using -flto-partition=one and it hasn't helped me.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (3 preceding siblings ...)
2022-12-02 19:08 ` marxin at gcc dot gnu.org
@ 2022-12-02 19:22 ` redi at gcc dot gnu.org
2022-12-02 21:07 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2022-12-02 19:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The vtable will only be emitted in the TU containing the key function, which is
that get_text function defined in the front end.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (4 preceding siblings ...)
2022-12-02 19:22 ` redi at gcc dot gnu.org
@ 2022-12-02 21:07 ` pinskia at gcc dot gnu.org
2023-01-13 9:27 ` marxin at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-02 21:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It might be the case the object files were unused in the archive so they are
not linked in the LTO front-end but now with using LTO partial linking, they
are pulled in always.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (5 preceding siblings ...)
2022-12-02 21:07 ` pinskia at gcc dot gnu.org
@ 2023-01-13 9:27 ` marxin at gcc dot gnu.org
2023-01-14 21:43 ` hubicka at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-13 9:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> It might be the case the object files were unused in the archive so they are
> not linked in the LTO front-end but now with using LTO partial linking, they
> are pulled in always.
Yes, that's likely what's happening. So the question is if the issue is caused
by partial linking, or if the function definition should be provided in
libbackend.a itself?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (6 preceding siblings ...)
2023-01-13 9:27 ` marxin at gcc dot gnu.org
@ 2023-01-14 21:43 ` hubicka at gcc dot gnu.org
2023-01-16 12:35 ` marxin at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-01-14 21:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Thanks for looking into the incremental link of libbackend. I had it in my tree
for a while but never got around implementing correct way to enable it only
during bootstrap since host compiler may not support it. It would be nice to
have it in since it should reduce WPA memory use and also test this code path.
I also think it is the case where partial linking makes the symbol to be pulled
into LTO binary at the initial link time. It should be optimized away if
linker was not complaining.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (7 preceding siblings ...)
2023-01-14 21:43 ` hubicka at gcc dot gnu.org
@ 2023-01-16 12:35 ` marxin at gcc dot gnu.org
2023-01-16 19:14 ` hubicka at ucw dot cz
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-16 12:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #7)
> Thanks for looking into the incremental link of libbackend. I had it in my
> tree for a while but never got around implementing correct way to enable it
> only during bootstrap since host compiler may not support it. It would be
> nice to have it in since it should reduce WPA memory use and also test this
> code path.
Feel free to grab my initial patch in c#0 and upstream it. I tried that some
time ago in the following email thread:
https://gcc.gnu.org/pipermail/gcc/2021-May/236096.html
>
> I also think it is the case where partial linking makes the symbol to be
> pulled into LTO binary at the initial link time. It should be optimized
> away if linker was not complaining.
Optimize away during the partial linking? So you think it's a GCC issue when it
comes to partial linking?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (8 preceding siblings ...)
2023-01-16 12:35 ` marxin at gcc dot gnu.org
@ 2023-01-16 19:14 ` hubicka at ucw dot cz
2023-01-19 12:36 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hubicka at ucw dot cz @ 2023-01-16 19:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #9 from Jan Hubicka <hubicka at ucw dot cz> ---
>
> Feel free to grab my initial patch in c#0 and upstream it. I tried that some
> time ago in the following email thread:
> https://gcc.gnu.org/pipermail/gcc/2021-May/236096.html
Actually I was shooting for partial linking LTO streams just to make
individual WPAs chaper. With -flinker-output=nolto-rel we are
effectively disabling most of benefits of LTO.
My main problem was arranging the partial link only when stage1/2
compiler is used so bootstrap works with older GCCs which suports LTO
but not partial linking yet.
>
> >
> > I also think it is the case where partial linking makes the symbol to be
> > pulled into LTO binary at the initial link time. It should be optimized
> > away if linker was not complaining.
>
> Optimize away during the partial linking? So you think it's a GCC issue when it
> comes to partial linking?
No with partial linking you merge all the individual object files into
single. So if lto frontned is not using some of libbackend entry point,
you still get that code biult into it. So I think it is correct
behaviour.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (9 preceding siblings ...)
2023-01-16 19:14 ` hubicka at ucw dot cz
@ 2023-01-19 12:36 ` rguenth at gcc dot gnu.org
2023-01-20 15:16 ` dmalcolm at gcc dot gnu.org
2023-01-23 10:19 ` marxin at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-19 12:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
I suppose a fix would be to provide a dummy implementation for
range_label_for_type_mismatch::get_text in lto/, but I wonder how
for example the fortran frontend avoids this issue?
f951 has rich_location uses but no range_label_for_type_mismatch, it looks
like range_label_for_* is used only from the C family frontends, so maybe
another fix would be to move that class and implementation somewhere to
c-family/?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (10 preceding siblings ...)
2023-01-19 12:36 ` rguenth at gcc dot gnu.org
@ 2023-01-20 15:16 ` dmalcolm at gcc dot gnu.org
2023-01-23 10:19 ` marxin at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-01-20 15:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #11 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #10)
> I suppose a fix would be to provide a dummy implementation for
> range_label_for_type_mismatch::get_text in lto/, but I wonder how
> for example the fortran frontend avoids this issue?
>
> f951 has rich_location uses but no range_label_for_type_mismatch, it looks
> like range_label_for_* is used only from the C family frontends, so maybe
> another fix would be to move that class and implementation somewhere to
> c-family/?
AIUI class range_label_for_type_mismatch is only used:
* by the C and C++ frontends (directly, and by
range_label_for_format_type_mismatch), and
* by maybe_range_label_for_tree_type_mismatch::get_text in
gcc/gcc-rich-location.cc, which is used by class binary_op_rich_location in
gcc/gcc-rich-location.{h,cc}; the latter is only used by the C/C++ frontends.
So moving range_label_for_type_mismatch *and* binary_op_rich_location to
c/cp/c-family might be a fix for this; I'm not sure.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug bootstrap/107950] partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const'
2022-12-02 11:56 [Bug bootstrap/107950] New: partial LTO linking of libbackend.a: gcc/gcc-rich-location.cc:207: undefined reference to `range_label_for_type_mismatch::get_text(unsigned int) const' marxin at gcc dot gnu.org
` (11 preceding siblings ...)
2023-01-20 15:16 ` dmalcolm at gcc dot gnu.org
@ 2023-01-23 10:19 ` marxin at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-23 10:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950
--- Comment #12 from Martin Liška <marxin at gcc dot gnu.org> ---
> So moving range_label_for_type_mismatch *and* binary_op_rich_location to
> c/cp/c-family might be a fix for this; I'm not sure.
I don't think so as any other (non-C family) FE will fail to link against
libbackend.a.
^ permalink raw reply [flat|nested] 14+ messages in thread