From patchwork Mon Jun 6 11:12:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Clarke X-Patchwork-Id: 9157877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4194660572 for ; Mon, 6 Jun 2016 11:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30B9426490 for ; Mon, 6 Jun 2016 11:13:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2330226E82; Mon, 6 Jun 2016 11:13:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0E3026490 for ; Mon, 6 Jun 2016 11:13:01 +0000 (UTC) Received: from localhost ([::1]:41377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9sSq-0007xa-Rw for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 07:13:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9sSQ-0007uX-Qr for qemu-devel@nongnu.org; Mon, 06 Jun 2016 07:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9sSJ-0008VP-5V for qemu-devel@nongnu.org; Mon, 06 Jun 2016 07:12:33 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:36315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9sSI-0008VC-UZ for qemu-devel@nongnu.org; Mon, 06 Jun 2016 07:12:27 -0400 Received: by mail-wm0-x243.google.com with SMTP id m124so14486880wme.3 for ; Mon, 06 Jun 2016 04:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :in-reply-to:user-agent; bh=9DKiVB/xCt1xWB/NR8YblGqYOvaU+I6cRoKld48V9sY=; b=X/Ay4tT8ppREDwRhapLu4ktmVo2roR+G+bHf6QbouTwVsZilSnBZFdmH77Oc2wEy0y U7Aht1w5SsYuTiRjLzDUIh61ZkvQQl12VlZwCf8bvSsME8k/aEpfy3VwN8C0PPIgczFn Z5m+4IqaDsG0bhfRCY3vHmYuEv5x6yqSXoHeI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:in-reply-to:user-agent; bh=9DKiVB/xCt1xWB/NR8YblGqYOvaU+I6cRoKld48V9sY=; b=E6wBJQ0BZWFpniVls82tj5SdiqMYPrlH8x7jrrdmzCvbH6fxPOJaCFKZz4FBFkV8AD +UaNx75iKPvRMK2DB2CAHpTWdvNQCxnveLVpqEBHl7Go4EqsDXYYxAjyIUo2J5g/sApA A2s966oF0qW/T2Y3K1/uqLb9WaPpGr637UzquuG+oQDR/GQ5sqEqH3DlPEjV9o9aXCKq Pz+UAKPPeH+zcDVhNJc+XhgP/7K20SfmLSGGpa9n7Cyy28uSaqZIlnrajqdhcY80W9jC 4FFmxC62EtovoDRRMU4pLjSI+AeQRJuANbsc3QStSLb+DxRfnGmfroRMB0CRmz+Vy4G3 2kmQ== X-Gm-Message-State: ALyK8tKLbWEDDAfqAPuP/RGwSqqPEBD8pErhO6YZM1RQT47EIx4K0Iep+D96Fix2kD9rag== X-Received: by 10.28.129.20 with SMTP id c20mr12157755wmd.46.1465211546157; Mon, 06 Jun 2016 04:12:26 -0700 (PDT) Received: from Jamess-MacBook.local (global-184-8.nat-1.net.cam.ac.uk. [131.111.184.8]) by smtp.gmail.com with ESMTPSA id dl5sm4966605wjd.32.2016.06.06.04.12.24 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 06 Jun 2016 04:12:25 -0700 (PDT) Received: by Jamess-MacBook.local (Postfix, from userid 501) id 85C7139083D4; Mon, 6 Jun 2016 12:12:24 +0100 (BST) Date: Mon, 6 Jun 2016 12:12:24 +0100 From: James Clarke To: Peter Maydell Message-ID: <20160606111224.GA45022@Jamess-MacBook.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v3] Fix linking relocatable objects on Sparc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Trivial , Michael Tokarev , QEMU Developers Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Sparc, gcc implicitly passes --relax to the linker, but -r is incompatible with this. Therefore, if --no-relax is supported, it should be passed to the linker. Signed-off-by: James Clarke --- Hi Peter, Sorry about that, I wasn't building in a git repository, so werror was set to no (I was unaware of the configure script doing so). I have now tested it with werror enabled, and it works (and could reproduce the error with the previous version). I reworked the test slightly to mirror what the Makefile rules actually do, as trying to combine the compilation and ld -r steps doesn't work when CLFAGS contains -pie, which was leading to x86_64 believing that --no-relax was not a valid option. I also accidentally included a whitespace change in v2; sorry for the noise. Regards, James configure | 21 +++++++++++++++++++++ rules.mak | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/configure b/configure index b5aab72..70237b0 100755 --- a/configure +++ b/configure @@ -31,6 +31,7 @@ TMPCXX="${TMPDIR1}/${TMPB}.cxx" TMPL="${TMPDIR1}/${TMPB}.lo" TMPA="${TMPDIR1}/lib${TMPB}.la" TMPE="${TMPDIR1}/${TMPB}.exe" +TMPMO="${TMPDIR1}/${TMPB}.mo" rm -f config.log @@ -4526,6 +4527,25 @@ if compile_prog "" "" ; then have_fsxattr=yes fi +################################################# +# Sparc implicitly links with --relax, which is +# incompatible with -r, so --no-relax should be +# given. It does no harm to give it on other +# platforms too. + +# Note: the prototype is needed since QEMU_CFLAGS +# contains -Wmissing-prototypes +cat > $TMPC << EOF +extern int foo(void); +int foo(void) { return 0; } +EOF +if ! compile_object ""; then + error_exit "Failed to compile object file for LD_REL_FLAGS test" +fi +if do_cc -nostdlib -Wl,-r -Wl,--no-relax -o $TMPMO $TMPO; then + LD_REL_FLAGS="-Wl,--no-relax" +fi + ########################################## # End of CC checks # After here, no more $cc or $ld runs @@ -5529,6 +5549,7 @@ else fi echo "LDFLAGS=$LDFLAGS" >> $config_host_mak echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak +echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak echo "LIBS+=$LIBS" >> $config_host_mak echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak echo "EXESUF=$EXESUF" >> $config_host_mak diff --git a/rules.mak b/rules.mak index 4a8f464..dca5718 100644 --- a/rules.mak +++ b/rules.mak @@ -95,7 +95,7 @@ module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS) $(if $(findstring /,$@),$(call quiet-command,cp $@ $(subst /,-,$@), " CP $(subst /,-,$@)")) -LD_REL := $(CC) -nostdlib -Wl,-r +LD_REL := $(CC) -nostdlib -Wl,-r $(LD_REL_FLAGS) %.mo: $(call quiet-command,$(LD_REL) -o $@ $^," LD -r $(TARGET_DIR)$@")