From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7B53F3858028; Mon, 1 Aug 2022 22:22:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B53F3858028 From: "skunk at iskunk dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/106501] New: libstdc++ is built without -fPIC despite --with-pic Date: Mon, 01 Aug 2022 22:22:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: skunk at iskunk dot 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 cf_gcchost cf_gcctarget cf_gccbuild 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 22:22:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106501 Bug ID: 106501 Summary: libstdc++ is built without -fPIC despite --with-pic Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: skunk at iskunk dot org Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Build: x86_64-pc-linux-gnu I bootstrapped GCC 12.1.0 with the following options: --disable-shared --disable-nls --enable-version-specific-runtime-libs --with-pic --disable-multilib --with-arch=3Dopteron --disable-libsanitizer --disable-libcc1 --enable-languages=3Dc,c++,lto Notable is the combination of "--disable-shared --with-pic", with the inten= tion of having all the GCC support libraries be statically linkable when building executables, shared libraries, etc. Once the bootstrap was complete, I used the new GCC to build a current vers= ion of GDB. That build failed with CXXLD libinproctrace.so /usr/bin/ld: /opt/sfw/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/libstdc++.a(class_type_i= nfo.o): relocation R_X86_64_32S against `_ZTVN10__cxxabiv117__class_type_infoE' can= not be used when making a shared object; recompile with -fPIC /opt/sfw/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/libstdc++.a: could not r= ead symbols: Bad value collect2: error: ld returned 1 exit status gmake[2]: *** [Makefile:383: libinproctrace.so] Error 1 gmake[2]: Leaving directory '/tmp/gdb-12.1-build/gdbserver' gmake[1]: *** [Makefile:11743: all-gdbserver] Error 2 gmake[1]: Leaving directory '/tmp/gdb-12.1-build' gmake: *** [Makefile:1001: all] Error 2 I checked the build log for GCC. None of the compile lines for class_type_info.o include the -fPIC option (i.e. "fgrep class_type_info.o gcc12-build-log.txt | grep -c PIC" yields 0). The --with-pic option should cause all libraries to be built with -fPIC, ev= en when they are built as static archives. It is possible that libstdc++ is not the only library that was built incorrectly; it is only the one I noticed. Related: bug #66955, bug #67128=