public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "skunk at iskunk dot org" <gcc-bugzilla@gcc.gnu.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	[thread overview]
Message-ID: <bug-106501-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            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=opteron
    --disable-libsanitizer
    --disable-libcc1
    --enable-languages=c,c++,lto

Notable is the combination of "--disable-shared --with-pic", with the intention
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 version
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_info.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 read
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, even
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

             reply	other threads:[~2022-08-01 22:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 22:22 skunk at iskunk dot org [this message]
2022-08-01 22:27 ` [Bug libstdc++/106501] " pinskia 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-106501-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).