]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add missing 'extern' for VIR_EXPORT_VAR macro
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 20 Sep 2016 11:51:07 +0000 (12:51 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 20 Sep 2016 11:55:28 +0000 (12:55 +0100)
The recent update to gnulib

  commit 9d7a37ecb2ab516c19164a57b8aeb32016a99d2c
  Author: Eric Blake <eblake@redhat.com>
  Date:   Thu Sep 15 15:12:52 2016 -0500

    build: update to latest gnulib

Pulled in a change that adds -fno-common to the default compiler
flags

  commit bf8e658ffadb95d444f56d222d04c9af955af765
  Author: Jim Meyering <meyering@fb.com>
  Date:   Fri Sep 2 09:16:16 2016 -0700

    manywarnings: add -fno-common

This caused libvirt Mingw build to break with the compiler
reporting 100's of definitions of virConnectAuthPtrDefault

./.libs/libvirt_util.a(libvirt_util_la-virarch.o):virarch.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):viralloc.c:(.bss+0x0): first defined here
./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):viratomic.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-viraudit.o):viraudit.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-virauth.o):virauth.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-virauthconfig.o):virauthconfig.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
...snip...

The cause is our VIR_EXPORT_VAR macro which has some
magic on win to add dllexport/dllimport to the variable
declaration. Unfortunately the dllexport branch missed
off the 'extern' keyword, so the header file was in
fact declaring an instance of the variable in every
source file.

Previously the linker would merge all these definitions
into one, but that no longer happens due to -fno-common

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
include/libvirt/libvirt-common.h.in

index 79bfe90850f9aec59f9b8a6b722522394fa59b96..0e8ada45526b634d0f26e293e2ee39a68ed7ad4d 100644 (file)
@@ -49,7 +49,7 @@ extern "C" {
 #   define VIR_EXPORT_VAR extern
 #  else
 #   ifdef IN_LIBVIRT
-#    define VIR_EXPORT_VAR __declspec(dllexport)
+#    define VIR_EXPORT_VAR __declspec(dllexport) extern
 #   else
 #    define VIR_EXPORT_VAR __declspec(dllimport) extern
 #   endif