From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 83358386F0D6; Mon, 27 Jun 2022 10:47:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83358386F0D6 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/build] Fix gdbserver build with -fsanitize=thread X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: ed1c7ad8e31a2cfca1d8c8c898ee7cde6ae340ca X-Git-Newrev: a08bdb159bb7401f266836ded2899a9015828c25 Message-Id: <20220627104732.83358386F0D6@sourceware.org> Date: Mon, 27 Jun 2022 10:47:32 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2022 10:47:32 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da08bdb159bb7= 401f266836ded2899a9015828c25 commit a08bdb159bb7401f266836ded2899a9015828c25 Author: Tom de Vries Date: Mon Jun 27 12:47:26 2022 +0200 [gdb/build] Fix gdbserver build with -fsanitize=3Dthread =20 [ Copied from gcc commit 153689603fd ("[gdb/build] Fix gdbserver build = with -fsanitize=3Dthread"). ] =20 When building gdbserver with -fsanitize=3Dthread (added to CFLAGS/CXXFL= AGS) 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 obj= ect; \ 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/b= uild] Fix gdbserver build with -fsanitize=3Daddress"). =20 The gdbserver component builds a shared library libinproctrace.so, whic= h uses libiberty and therefore requires the pic variant. The gdbserver Makefi= le is setup to use this variant, if available, but it's not there. =20 Fix this by listing gdbserver in the toplevel configure alongside libcc= 1, as a component that needs the libiberty pic variant, setting: ... extra_host_libiberty_configure_flags=3D--enable-shared ... =20 Tested on x86_64-linux. =20 ChangeLog: =20 2022-06-27 Tom de Vries =20 * 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=3D extra_host_zlib_configure_flags=3D 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=3D--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=3D extra_host_zlib_configure_flags=3D 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=3D--enable-shared