From patchwork Sat Jun 25 09:08:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 55403 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A0A3383A327 for ; Sat, 25 Jun 2022 09:09:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A0A3383A327 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656148168; bh=93GfGpAgS7PspbZdeMvJQy5lhyQjBv8u/Mr5tNmFKRE=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QlR+Y/CppZr1MP7py21QKH/saeTy7/j+YsBZNo/WDuBSgRZUbSTVHds9uwh+9lKRU aiSVZfcIwDsYio9N11R/u+m91SinTyIJVmQqw8WrcdFOOAlCuRDrb8PRzVTKc6xt9z KFUZFXWT1QxzfD0MAyRPv9Mxk+G7Pfdjg55gAdEc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 3D8C7383D82C for ; Sat, 25 Jun 2022 09:08:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3D8C7383D82C 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 To: gcc-patches@gcc.gnu.org Subject: [PATCH][gdb/build] Fix gdbserver build with -fsanitize=thread Message-ID: <20220625090808.GA18353@delia.com> MIME-Version: 1.0 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gcc-patches From: Tom de Vries Reply-To: Tom de Vries Cc: gdb-patches@sourceware.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-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