From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C569F3858CDA; Fri, 2 Dec 2022 11:56:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C569F3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669982212; bh=Bo+wLp4EdCcduGZekNp8pywobyXYjqIp+gNOwk/Pbxo=; h=From:To:Subject:Date:From; b=iODDpsFjjOhPSDy/vYsh8B1j6jWFm5SSmLnRdKNlbNRlAk40CFb9dh0rfHtsoEjOg 0QDAoy0Zexea+ybQFzZ1BuoC7PTnY4Is8cYm/trYEuho4Qn8cztLEnzuMeVlIxhv+R 7pXt6jvTa1KOFLBpQm06NC91EgaPMlOfd1smW4Ac= From: "marxin at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107950 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) +=3D -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=3Dnolto-rel -r -o $@ -flto=3Dauto 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=20 -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc -o lto1 \ lto/lto-lang.o lto/lto.o lto/lto-object.o attribs.o lto/lto-partiti= on.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=20= =20 ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a=20 /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 refere= nce 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 refer= ence 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] Err= or 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) con= st { if (m_expr =3D=3D NULL_TREE || !EXPR_P (m_expr)) return label_text::borrow (NULL); tree expr_type =3D TREE_TYPE (m_expr); tree other_type =3D NULL_TREE; if (m_other_expr && EXPR_P (m_other_expr)) other_type =3D 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 t= he 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?=