public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org>
To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org
Subject: [binutils-gdb] [gdb/build] Fix gdbserver build with -fsanitize=thread
Date: Mon, 27 Jun 2022 10:47:32 +0000 (GMT)	[thread overview]
Message-ID: <20220627104732.83358386F0D6@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a08bdb159bb7401f266836ded2899a9015828c25

commit a08bdb159bb7401f266836ded2899a9015828c25
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Jun 27 12:47:26 2022 +0200

    [gdb/build] Fix gdbserver build with -fsanitize=thread
    
    [ Copied from gcc commit 153689603fd ("[gdb/build] Fix gdbserver build with
    -fsanitize=thread"). ]
    
    When building gdbserver with -fsanitize=thread (added to CFLAGS/CXXFLAGS) we
    run into:
    ...
    ld: ../libiberty/libiberty.a(safe-ctype.o): warning: relocation against \
      `__tsan_init' in read-only section `.text'
    ld: ../libiberty/libiberty.a(safe-ctype.o): relocation R_X86_64_PC32 \
      against symbol `__tsan_init' can not be used when making a shared object; \
      recompile with -fPIC
    ld: final link failed: bad value
    collect2: error: ld returned 1 exit status
    make[1]: *** [libinproctrace.so] Error 1
    ...
    which looks similar to what is described in commit 78e49486944 ("[gdb/build]
    Fix gdbserver build with -fsanitize=address").
    
    The gdbserver component builds a shared library libinproctrace.so, which uses
    libiberty and therefore requires the pic variant.  The gdbserver Makefile is
    setup to use this variant, if available, but it's not there.
    
    Fix this by listing gdbserver in the toplevel configure alongside libcc1, as a
    component that needs the libiberty pic variant, setting:
    ...
    extra_host_libiberty_configure_flags=--enable-shared
    ...
    
    Tested on x86_64-linux.
    
    ChangeLog:
    
    2022-06-27  Tom de Vries  <tdevries@suse.de>
    
            * configure.ac: Build libiberty pic variant for gdbserver.
            * configure: Regenerate.

Diff:
---
 configure    | 2 +-
 configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 1badcb314f8..aac80b88d70 100755
--- a/configure
+++ b/configure
@@ -6964,7 +6964,7 @@ fi
 extra_host_libiberty_configure_flags=
 extra_host_zlib_configure_flags=
 case " $configdirs " in
-  *" lto-plugin "* | *" libcc1 "*)
+  *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
     # When these are to be built as shared libraries, the same applies to
     # libiberty.
     extra_host_libiberty_configure_flags=--enable-shared
diff --git a/configure.ac b/configure.ac
index 5b6e2048514..29f74d10b5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2344,7 +2344,7 @@ fi
 extra_host_libiberty_configure_flags=
 extra_host_zlib_configure_flags=
 case " $configdirs " in
-  *" lto-plugin "* | *" libcc1 "*)
+  *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
     # When these are to be built as shared libraries, the same applies to
     # libiberty.
     extra_host_libiberty_configure_flags=--enable-shared


                 reply	other threads:[~2022-06-27 10:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220627104732.83358386F0D6@sourceware.org \
    --to=vries@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    --cc=gdb-cvs@sourceware.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).