qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] configure: Always build with -fno-common
@ 2014-02-26 21:53 Peter Maydell
  2014-02-28 17:19 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2014-02-26 21:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Färber, Markus Armbruster, patches

MacOSX doesn't pull .o files from .a archives if the symbol that it
requires is one which the .o file defines as a common symbol.
(Common symbols are those declared without "extern"; the linker
will merge together common symbols with the same name, so
redeclaring the same variable in two compilation units results in
them referring to the same symbol rather than a compilation error).

This MacOSX difference from traditional linker behaviour means that
"make check" produces link errors:

Undefined symbols for architecture x86_64:
  "_cur_mon", referenced from:
      _error_vprintf in libqemuutil.a(qemu-error.o)
      _error_printf in libqemuutil.a(qemu-error.o)
      _error_printf_unless_qmp in libqemuutil.a(qemu-error.o)
      _error_print_loc in libqemuutil.a(qemu-error.o)
      _error_report in libqemuutil.a(qemu-error.o)
ld: symbol(s) not found for architecture x86_64

in this case because "cur_mon" is a common symbol in
libqemustub.a(mon-set-error.o).

In QEMU we don't make any use at all of the common symbol
functionality, so we can avoid this problem entirely simply
by compiling with -fno-common. Enable this option for all
builds, not just MacOSX, so that if we ever inadvertently
introduce multiple definitions of some variable that will
be immediately spotted as a build error rather than only
breaking the MacOSX build.

Suggested-by:  Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Thanks to Markus for pointing out that -fno-common was the
simple solution to this problem. make check now works on MacOSX,
although due to a race condition in the version of glib I'm stuck
on (2.22.4) I have to periodically use "killall -CHLD gtester"
to unwedge it...

 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 423f435..ff438e4 100755
--- a/configure
+++ b/configure
@@ -369,7 +369,7 @@ sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
 ARFLAGS="${ARFLAGS-rv}"
 
 # default flags for all hosts
-QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
+QEMU_CFLAGS="-fno-strict-aliasing -fno-common $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
-- 
1.8.5.4

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

* Re: [Qemu-devel] [PATCH] configure: Always build with -fno-common
  2014-02-26 21:53 [Qemu-devel] [PATCH] configure: Always build with -fno-common Peter Maydell
@ 2014-02-28 17:19 ` Richard Henderson
  2014-03-06 21:42   ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2014-02-28 17:19 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Andreas Färber, Markus Armbruster, patches

On 02/26/2014 01:53 PM, Peter Maydell wrote:
> In QEMU we don't make any use at all of the common symbol
> functionality, so we can avoid this problem entirely simply
> by compiling with -fno-common. Enable this option for all
> builds, not just MacOSX, so that if we ever inadvertently
> introduce multiple definitions of some variable that will
> be immediately spotted as a build error rather than only
> breaking the MacOSX build.
> 
> Suggested-by:  Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

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

* Re: [Qemu-devel] [PATCH] configure: Always build with -fno-common
  2014-02-28 17:19 ` Richard Henderson
@ 2014-03-06 21:42   ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2014-03-06 21:42 UTC (permalink / raw)
  To: Richard Henderson
  Cc: Andreas Färber, Patch Tracking, QEMU Developers,
	Markus Armbruster

On 28 February 2014 17:19, Richard Henderson <rth@twiddle.net> wrote:
> On 02/26/2014 01:53 PM, Peter Maydell wrote:
>> In QEMU we don't make any use at all of the common symbol
>> functionality, so we can avoid this problem entirely simply
>> by compiling with -fno-common. Enable this option for all
>> builds, not just MacOSX, so that if we ever inadvertently
>> introduce multiple definitions of some variable that will
>> be immediately spotted as a build error rather than only
>> breaking the MacOSX build.
>>
>> Suggested-by:  Markus Armbruster <armbru@redhat.com>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
> Reviewed-by: Richard Henderson <rth@twiddle.net>

Thanks. Applied to master as a MacOSX buildfix.

-- PMM

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

end of thread, other threads:[~2014-03-06 21:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-26 21:53 [Qemu-devel] [PATCH] configure: Always build with -fno-common Peter Maydell
2014-02-28 17:19 ` Richard Henderson
2014-03-06 21:42   ` Peter Maydell

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