public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][gdb/build] Fix gdbserver build with -fsanitize=thread
@ 2022-06-25  9:08 Tom de Vries
  2022-06-27  5:55 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2022-06-25  9:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: gdb-patches

Hi,

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.

OK for trunk gcc?

Thanks,
- Tom

[gdb/build] Fix gdbserver build with -fsanitize=thread

---
 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][gdb/build] Fix gdbserver build with -fsanitize=thread
  2022-06-25  9:08 [PATCH][gdb/build] Fix gdbserver build with -fsanitize=thread Tom de Vries
@ 2022-06-27  5:55 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-06-27  5:55 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches, gdb-patches

On Sat, Jun 25, 2022 at 11:09 AM Tom de Vries via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
> 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.
>
> OK for trunk gcc?

OK

> Thanks,
> - Tom
>
> [gdb/build] Fix gdbserver build with -fsanitize=thread
>
> ---
>  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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-27  5:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-25  9:08 [PATCH][gdb/build] Fix gdbserver build with -fsanitize=thread Tom de Vries
2022-06-27  5:55 ` Richard Biener

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).