From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id ADE7C383D831 for ; Sat, 25 Jun 2022 09:08:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ADE7C383D831 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DD0781FD4E; Sat, 25 Jun 2022 09:08:25 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CA69B13456; Sat, 25 Jun 2022 09:08:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wFqxMobQtmIWWwAAMHmgww (envelope-from ); Sat, 25 Jun 2022 09:08:22 +0000 Date: Sat, 25 Jun 2022 11:08:18 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: gdb-patches@sourceware.org Subject: [PATCH][gdb/build] Fix gdbserver build with -fsanitize=thread Message-ID: <20220625090808.GA18353@delia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2022 09:08:32 -0000 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