public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [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'
Date: Fri, 02 Dec 2022 11:56:51 +0000	[thread overview]
Message-ID: <bug-107950-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107950

            Bug ID: 107950
           Summary: 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'
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: bootstrap
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

If I use the patch candidate for PR107944 and do:

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 615a07089ee..e95390169cf 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2122,13 +2122,15 @@ selftest: $(SELFTEST_TARGETS)
 # This is used only if the user explicitly asks for it.
 compilations: $(BACKEND)

+$(foreach file,$(OBJS),$(eval CFLAGS-$(file) += -flto))
+
 # This archive is strictly for the host.
 libbackend.a: $(OBJS)
        -rm -rf libbackend.a
        @# Build libbackend.a as a thin archive if possible, as doing so
        @# significantly reduces build times.
 ifeq ($(USE_THIN_ARCHIVES),yes)
-       $(AR) $(AR_FLAGS)T libbackend.a $(OBJS)
+       -$(LINKER) $^ -flinker-output=nolto-rel -r -o $@ -flto=auto
 else
        $(AR) $(AR_FLAGS) libbackend.a $(OBJS)
        -$(RANLIB) $(RANLIB_FLAGS) libbackend.a

I get the following linker error:

$ make lto
g++ -no-pie   -g       -DIN_GCC     -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common 
-DHAVE_CONFIG_H -static-libstdc++ -static-libgcc   -o lto1 \
        lto/lto-lang.o lto/lto.o lto/lto-object.o attribs.o lto/lto-partition.o
lto/lto-symtab.o lto/lto-common.o libbackend.a main.o libcommon-target.a
libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a  -lmpc -lmpfr
-lgmp -rdynamic  -L./../zlib -lz -lzstd  libcommon.a ../libcpp/libcpp.a  
../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a
../libdecnumber/libdecnumber.a 
/usr/bin/ld: libbackend.a: in function
`range_label_for_type_mismatch::range_label_for_type_mismatch(tree_node*,
tree_node*)':
/home/marxin/Programming/gcc2/gcc/gcc-rich-location.h:158: undefined reference
to `vtable for range_label_for_type_mismatch'
/usr/bin/ld: libbackend.a: in function
`maybe_range_label_for_tree_type_mismatch::get_text(unsigned int) const':
/home/marxin/Programming/gcc2/gcc/gcc-rich-location.cc:207: undefined reference
to `range_label_for_type_mismatch::get_text(unsigned int) const'
collect2: error: ld returned 1 exit status
make: *** [/home/marxin/Programming/gcc2/gcc/lto/Make-lang.in:96: lto1] Error 1

The error comes from gcc/gcc-rich-location.cc where we have:

label_text
maybe_range_label_for_tree_type_mismatch::get_text (unsigned range_idx) const
{
  if (m_expr == NULL_TREE
      || !EXPR_P (m_expr))
    return label_text::borrow (NULL);
  tree expr_type = TREE_TYPE (m_expr);

  tree other_type = NULL_TREE;
  if (m_other_expr && EXPR_P (m_other_expr))
    other_type = TREE_TYPE (m_other_expr);

  range_label_for_type_mismatch inner (expr_type, other_type);
  return inner.get_text (range_idx);
}

and yes, both symbols are undefined:

nm libbackend.a | grep range_label_for_type_mismatch
                 U _ZNK29range_label_for_type_mismatch8get_textEj
                 U _ZTV29range_label_for_type_mismatch

What's strange that also a normal build (non-LTO, no partial linking) has the
same definitions:

nm libbackend.a | grep range_label_for_type_mismatch
                 U _ZNK29range_label_for_type_mismatch8get_textEj
                 U _ZTV29range_label_for_type_mismatch

So any guess what can be bad?

             reply	other threads:[~2022-12-02 11:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 11:56 marxin at gcc dot gnu.org [this message]
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
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
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
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107950-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).