qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: James Clarke <jrtc27@jrtc27.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Michael Tokarev <mjt@tls.msk.ru>,
	QEMU Developers <qemu-devel@nongnu.org>,
	QEMU Trivial <qemu-trivial@nongnu.org>
Subject: [Qemu-devel] [PATCH v3] Fix linking relocatable objects on Sparc
Date: Mon, 6 Jun 2016 12:12:24 +0100	[thread overview]
Message-ID: <20160606111224.GA45022@Jamess-MacBook.local> (raw)
In-Reply-To: <CAFEAcA8kPTVPjVYHyismDb4vvZVBmK8kGdCEVrvoVontSW91+A@mail.gmail.com>

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 <jrtc27@jrtc27.com>
---
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)$@")
-- 
2.8.3

      reply	other threads:[~2016-06-06 11:12 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-05  7:42 [Qemu-devel] [PULL 00/52] Trivial patches for 2016-06-05 Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 01/52] s390x/virtio-ccw: fix spelling Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 02/52] hw/ipmi: " Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 03/52] docs: "specify" spell fix Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 04/52] qga: spelling fix Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 05/52] fsdev: " Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 06/52] target-moxie: Remove unused struct elements Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 07/52] po/Makefile: call rm -f directly Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 08/52] gdbstub: set listen backlog to 1 Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 09/52] scripts: add muldiv64() checking coccinelle scripts Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 10/52] The only 64bit parameter of muldiv64() is the first one Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 11/52] remove useless muldiv64() Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 12/52] replace muldiv64(a, b, c) by (uint64_t)a * b / c Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 13/52] ppc: Remove a potential overflow in muldiv64() Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 14/52] Fix linking relocatable objects on Sparc Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 15/52] qemu-options.hx: Specify the units for -machine kvm_shadow_mem Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 16/52] configure: Use $(..) instead of deprecated `..` Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 17/52] scripts: " Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 18/52] ICH9: fix typo Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 19/52] monitor: Typo fix Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 20/52] qdev: Clean up around properties Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 21/52] fw_cfg: follow CODING_STYLE Michael Tokarev
2016-06-05  7:42 ` [Qemu-devel] [PULL 22/52] replay: Clean up includes Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 23/52] hw: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 24/52] docs: Fix a couple of typos in throttle.txt Michael Tokarev
2016-06-08  9:00   ` Alberto Garcia
2016-06-08  9:44     ` Michael Tokarev
2016-06-08 10:23       ` Alberto Garcia
2016-06-05  7:43 ` [Qemu-devel] [PULL 25/52] Fix configure test for PBKDF2 in nettle Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 26/52] e1000: Removing unnecessary if statement Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 27/52] pc: cleanup unused struct PcRomPciInfo Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 28/52] clean-includes: Add glib.h to list of unneeded includes Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 29/52] tests: Remove unnecessary glib.h includes Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 30/52] qga: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 31/52] all: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 32/52] docs/multi-thread-compression: Fix wrong command string Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 33/52] host-utils: Prefer 'false' for bool type Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 34/52] qemu-common.h: Drop WORDS_ALIGNED define Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 35/52] thunk: Drop unused NO_THUNK_TYPE_SIZE guards Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 36/52] thunk: Rename args and fields in host-target bitmask conversion code Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 37/52] coccinelle: use macro DIV_ROUND_UP instead of (((n) + (d) - 1) /(d)) Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 38/52] parallels: Use DIV_ROUND_UP Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 39/52] qcow/qcow2: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 40/52] qed: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 41/52] block: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 42/52] crypto: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 43/52] xen: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 44/52] audio: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 45/52] SPICE: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 46/52] rocker: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 47/52] usb: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 48/52] slirp: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 49/52] linux-user: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 50/52] pc-bios/s390-ccw: " Michael Tokarev
2016-06-06 13:17   ` Laurent Vivier
2016-06-07 15:07     ` Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 51/52] qemu-timer: " Michael Tokarev
2016-06-05  7:43 ` [Qemu-devel] [PULL 52/52] hbitmap: " Michael Tokarev
2016-06-06  9:16 ` [Qemu-devel] [PULL 00/52] Trivial patches for 2016-06-05 Peter Maydell
2016-06-06 11:12   ` James Clarke [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160606111224.GA45022@Jamess-MacBook.local \
    --to=jrtc27@jrtc27.com \
    --cc=mjt@tls.msk.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).