Re: [libvirt] [PATCH 06/15] Generate libvirt.def from libvirt.syms

2010-04-08 Thread Matthias Bolte
2010/4/7 Daniel P. Berrange :
> On Mon, Mar 22, 2010 at 02:25:36AM +0100, Matthias Bolte wrote:
>> The MinGW linker needs the libvirt.def file.
>> ---
>>  configure.ac    |    5 +
>>  src/.gitignore  |    1 +
>>  src/Makefile.am |   15 +++
>>  3 files changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index bcf1d5a..6e568ee 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1733,6 +1733,7 @@ CYGWIN_EXTRA_LIBADD=
>>  CYGWIN_EXTRA_PYTHON_LIBADD=
>>  MINGW_EXTRA_LDFLAGS=
>>  WIN32_EXTRA_CFLAGS=
>> +LIBVIRT_SYMBOL_FILE=libvirt.syms
>>  case "$host" in
>>    *-*-cygwin*)
>>      CYGWIN_EXTRA_LDFLAGS="-no-undefined"
>> @@ -1752,6 +1753,9 @@ case "$host" in
>>      if test "x$enable_shared" = "xno"; then
>>        WIN32_EXTRA_CFLAGS="-DLIBVIRT_STATIC"
>>      fi
>> +    # Also set the symbol file to .def, so src/Makefile generates 
>> libvirt.def
>> +    # from libvirt.syms and passes libvirt.def instead of libvirt.syms to 
>> the linker
>> +    LIBVIRT_SYMBOL_FILE=libvirt.def
>>      ;;
>>  esac
>>  AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
>> @@ -1759,6 +1763,7 @@ AC_SUBST([CYGWIN_EXTRA_LIBADD])
>>  AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
>>  AC_SUBST([MINGW_EXTRA_LDFLAGS])
>>  AC_SUBST([WIN32_EXTRA_CFLAGS])
>> +AC_SUBST([LIBVIRT_SYMBOL_FILE])
>>
>>  dnl Look for windres to build a Windows icon resource.
>>  AC_CHECK_TOOL([WINDRES], [windres], [no])
>> diff --git a/src/.gitignore b/src/.gitignore
>> index 26b8689..a5c27a5 100644
>> --- a/src/.gitignore
>> +++ b/src/.gitignore
>> @@ -12,6 +12,7 @@ Makefile.in
>>  *.cov
>>  libvirt_parthelper
>>  libvirt_lxc
>> +libvirt.def
>>  libvirt.syms
>>  *.i
>>  *.s
>> diff --git a/src/Makefile.am b/src/Makefile.am
>> index 0aa3443..fea1bd3 100644
>> --- a/src/Makefile.am
>> +++ b/src/Makefile.am
>> @@ -828,7 +828,7 @@ EXTRA_DIST += \
>>    libvirt_macvtap.syms               \
>>    libvirt_daemon.syms
>>
>> -BUILT_SOURCES = libvirt.syms
>> +BUILT_SOURCES = libvirt.syms libvirt.def
>>
>>  libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
>>       rm -f $...@-tmp $@
>> @@ -844,18 +844,25 @@ libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
>>       chmod a-w $...@-tmp
>>       mv $...@-tmp libvirt.syms
>>
>> +libvirt.def: libvirt.syms
>> +     rm -f -- $...@-tmp $@
>> +     printf 'EXPORTS\n' > $...@-tmp
>> +     sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBVIRT_/d; 
>> s/\(.*\)\;/\1/g' $^ >> $...@-tmp
>> +     chmod a-w $...@-tmp
>> +     mv $...@-tmp libvirt.def
>> +
>>  # Empty source list - it merely links a bunch of convenience libs together
>>  libvirt_la_SOURCES =
>>  libvirt_la_LIBADD += \
>>                   $(CYGWIN_EXTRA_LIBADD) ../gnulib/lib/libgnu.la
>> -libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)libvirt.syms \
>> +libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \
>>                       -version-info $(LIBVIRT_VERSION_INFO) \
>>                      $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
>>                      $(LIBXML_LIBS) \
>>                   $(DRIVER_MODULE_LIBS) \
>>                   $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS)
>>  libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
>> -libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) libvirt.syms
>> +libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) $(LIBVIRT_SYMBOL_FILE)
>>
>>  # Create an automake "convenience library" version of libvirt_la,
>>  # just for testing, since the test harness requires access to internal
>> @@ -865,7 +872,7 @@ noinst_LTLIBRARIES += libvirt_test.la
>>  # Remove version script from convenience library
>>  test_LDFLAGS =                                               \
>>    $$(echo '$(libvirt_la_LDFLAGS)'                    \
>> -     |sed 's!$(VERSION_SCRIPT_FLAGS)libvirt.syms!!'  \
>> +     |sed 's!$(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE)!!'        \
>>       |sed 's!-version-info $(LIBVIRT_VERSION_INFO)!!')
>>
>>  # Just like the above, but with a slightly different set of public symbols.
>
> I've re-examined this now to discover why we had this regression.
>
> Originally, say in 0.7.5, everything was linking fine on Mingw32 without
> this .defs file.  I figured out that this is because Mingw32 was ignoring
> our .syms file, and using its default logic of exporting *everything* :-)
>
> Then, in
>
> commit 190aaa2627a8c6e455088f1e7801708fb5f123b1
> Author: Matthias Bolte 
> Date:   Tue Mar 16 23:54:22 2010 +0100
>
>    Fix export of virConnectAuthPtrDefault for MinGW builds
>
>    Use the __declspec(dllexport/dllimport) stuff to export the symbol,
>    otherwise accessing virConnectAuthPtrDefault triggers a segfault.
>
>
> We used declspec() on the virConnectAuthPtrDefault. This turned off the
> Mingw32 logic that exported everything & thus caused virsh link failures.
>
> Adding this .defs file as per your patch re-exports everything.
>
> It sucks that we export everything, but it is no worse than the old
> situation we had on mingw.
>
> ACK to this patch
>
> Daniel
>

Okay, I rebased and pushed 

Re: [libvirt] [PATCH 06/15] Generate libvirt.def from libvirt.syms

2010-04-07 Thread Daniel P. Berrange
On Mon, Mar 22, 2010 at 02:25:36AM +0100, Matthias Bolte wrote:
> The MinGW linker needs the libvirt.def file.
> ---
>  configure.ac|5 +
>  src/.gitignore  |1 +
>  src/Makefile.am |   15 +++
>  3 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index bcf1d5a..6e568ee 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1733,6 +1733,7 @@ CYGWIN_EXTRA_LIBADD=
>  CYGWIN_EXTRA_PYTHON_LIBADD=
>  MINGW_EXTRA_LDFLAGS=
>  WIN32_EXTRA_CFLAGS=
> +LIBVIRT_SYMBOL_FILE=libvirt.syms
>  case "$host" in
>*-*-cygwin*)
>  CYGWIN_EXTRA_LDFLAGS="-no-undefined"
> @@ -1752,6 +1753,9 @@ case "$host" in
>  if test "x$enable_shared" = "xno"; then
>WIN32_EXTRA_CFLAGS="-DLIBVIRT_STATIC"
>  fi
> +# Also set the symbol file to .def, so src/Makefile generates libvirt.def
> +# from libvirt.syms and passes libvirt.def instead of libvirt.syms to 
> the linker
> +LIBVIRT_SYMBOL_FILE=libvirt.def
>  ;;
>  esac
>  AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
> @@ -1759,6 +1763,7 @@ AC_SUBST([CYGWIN_EXTRA_LIBADD])
>  AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
>  AC_SUBST([MINGW_EXTRA_LDFLAGS])
>  AC_SUBST([WIN32_EXTRA_CFLAGS])
> +AC_SUBST([LIBVIRT_SYMBOL_FILE])
>  
>  dnl Look for windres to build a Windows icon resource.
>  AC_CHECK_TOOL([WINDRES], [windres], [no])
> diff --git a/src/.gitignore b/src/.gitignore
> index 26b8689..a5c27a5 100644
> --- a/src/.gitignore
> +++ b/src/.gitignore
> @@ -12,6 +12,7 @@ Makefile.in
>  *.cov
>  libvirt_parthelper
>  libvirt_lxc
> +libvirt.def
>  libvirt.syms
>  *.i
>  *.s
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 0aa3443..fea1bd3 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -828,7 +828,7 @@ EXTRA_DIST += \
>libvirt_macvtap.syms   \
>libvirt_daemon.syms
>  
> -BUILT_SOURCES = libvirt.syms
> +BUILT_SOURCES = libvirt.syms libvirt.def
>  
>  libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
>   rm -f $...@-tmp $@
> @@ -844,18 +844,25 @@ libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
>   chmod a-w $...@-tmp
>   mv $...@-tmp libvirt.syms
>  
> +libvirt.def: libvirt.syms
> + rm -f -- $...@-tmp $@
> + printf 'EXPORTS\n' > $...@-tmp
> + sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBVIRT_/d; s/\(.*\)\;/\1/g' 
> $^ >> $...@-tmp
> + chmod a-w $...@-tmp
> + mv $...@-tmp libvirt.def
> +
>  # Empty source list - it merely links a bunch of convenience libs together
>  libvirt_la_SOURCES =
>  libvirt_la_LIBADD += \
>   $(CYGWIN_EXTRA_LIBADD) ../gnulib/lib/libgnu.la
> -libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)libvirt.syms \
> +libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \
>   -version-info $(LIBVIRT_VERSION_INFO) \
>  $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
>  $(LIBXML_LIBS) \
>   $(DRIVER_MODULE_LIBS) \
>   $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS)
>  libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
> -libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) libvirt.syms
> +libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) $(LIBVIRT_SYMBOL_FILE)
>  
>  # Create an automake "convenience library" version of libvirt_la,
>  # just for testing, since the test harness requires access to internal
> @@ -865,7 +872,7 @@ noinst_LTLIBRARIES += libvirt_test.la
>  # Remove version script from convenience library
>  test_LDFLAGS =   \
>$$(echo '$(libvirt_la_LDFLAGS)'\
> - |sed 's!$(VERSION_SCRIPT_FLAGS)libvirt.syms!!'  \
> + |sed 's!$(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE)!!'\
>   |sed 's!-version-info $(LIBVIRT_VERSION_INFO)!!')
>  
>  # Just like the above, but with a slightly different set of public symbols.

I've re-examined this now to discover why we had this regression.

Originally, say in 0.7.5, everything was linking fine on Mingw32 without
this .defs file.  I figured out that this is because Mingw32 was ignoring
our .syms file, and using its default logic of exporting *everything* :-)

Then, in

commit 190aaa2627a8c6e455088f1e7801708fb5f123b1
Author: Matthias Bolte 
Date:   Tue Mar 16 23:54:22 2010 +0100

Fix export of virConnectAuthPtrDefault for MinGW builds

Use the __declspec(dllexport/dllimport) stuff to export the symbol,
otherwise accessing virConnectAuthPtrDefault triggers a segfault.


We used declspec() on the virConnectAuthPtrDefault. This turned off the
Mingw32 logic that exported everything & thus caused virsh link failures.

Adding this .defs file as per your patch re-exports everything.

It sucks that we export everything, but it is no worse than the old
situation we had on mingw.

ACK to this patch

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org-o

Re: [libvirt] [PATCH 06/15] Generate libvirt.def from libvirt.syms

2010-03-22 Thread Daniel P. Berrange
On Mon, Mar 22, 2010 at 02:25:36AM +0100, Matthias Bolte wrote:
> The MinGW linker needs the libvirt.def file.
> ---
>  configure.ac|5 +
>  src/.gitignore  |1 +
>  src/Makefile.am |   15 +++
>  3 files changed, 17 insertions(+), 4 deletions(-)

> diff --git a/src/Makefile.am b/src/Makefile.am
> index 0aa3443..fea1bd3 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -828,7 +828,7 @@ EXTRA_DIST += \
>libvirt_macvtap.syms   \
>libvirt_daemon.syms
>  
> -BUILT_SOURCES = libvirt.syms
> +BUILT_SOURCES = libvirt.syms libvirt.def
>  
>  libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
>   rm -f $...@-tmp $@
> @@ -844,18 +844,25 @@ libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
>   chmod a-w $...@-tmp
>   mv $...@-tmp libvirt.syms
>  
> +libvirt.def: libvirt.syms
> + rm -f -- $...@-tmp $@
> + printf 'EXPORTS\n' > $...@-tmp
> + sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBVIRT_/d; s/\(.*\)\;/\1/g' 
> $^ >> $...@-tmp
> + chmod a-w $...@-tmp
> + mv $...@-tmp libvirt.def

Hmm, this is effectively exporting all our private symbols on Win32 too :-(

I thought the GCC/LD toolchain on Mingw already knew about the current
libvirt.syms file format ?

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org-o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 06/15] Generate libvirt.def from libvirt.syms

2010-03-21 Thread Matthias Bolte
The MinGW linker needs the libvirt.def file.
---
 configure.ac|5 +
 src/.gitignore  |1 +
 src/Makefile.am |   15 +++
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index bcf1d5a..6e568ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1733,6 +1733,7 @@ CYGWIN_EXTRA_LIBADD=
 CYGWIN_EXTRA_PYTHON_LIBADD=
 MINGW_EXTRA_LDFLAGS=
 WIN32_EXTRA_CFLAGS=
+LIBVIRT_SYMBOL_FILE=libvirt.syms
 case "$host" in
   *-*-cygwin*)
 CYGWIN_EXTRA_LDFLAGS="-no-undefined"
@@ -1752,6 +1753,9 @@ case "$host" in
 if test "x$enable_shared" = "xno"; then
   WIN32_EXTRA_CFLAGS="-DLIBVIRT_STATIC"
 fi
+# Also set the symbol file to .def, so src/Makefile generates libvirt.def
+# from libvirt.syms and passes libvirt.def instead of libvirt.syms to the 
linker
+LIBVIRT_SYMBOL_FILE=libvirt.def
 ;;
 esac
 AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
@@ -1759,6 +1763,7 @@ AC_SUBST([CYGWIN_EXTRA_LIBADD])
 AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
 AC_SUBST([MINGW_EXTRA_LDFLAGS])
 AC_SUBST([WIN32_EXTRA_CFLAGS])
+AC_SUBST([LIBVIRT_SYMBOL_FILE])
 
 dnl Look for windres to build a Windows icon resource.
 AC_CHECK_TOOL([WINDRES], [windres], [no])
diff --git a/src/.gitignore b/src/.gitignore
index 26b8689..a5c27a5 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -12,6 +12,7 @@ Makefile.in
 *.cov
 libvirt_parthelper
 libvirt_lxc
+libvirt.def
 libvirt.syms
 *.i
 *.s
diff --git a/src/Makefile.am b/src/Makefile.am
index 0aa3443..fea1bd3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -828,7 +828,7 @@ EXTRA_DIST += \
   libvirt_macvtap.syms \
   libvirt_daemon.syms
 
-BUILT_SOURCES = libvirt.syms
+BUILT_SOURCES = libvirt.syms libvirt.def
 
 libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
rm -f $...@-tmp $@
@@ -844,18 +844,25 @@ libvirt.syms: libvirt_public.syms $(USED_SYM_FILES)
chmod a-w $...@-tmp
mv $...@-tmp libvirt.syms
 
+libvirt.def: libvirt.syms
+   rm -f -- $...@-tmp $@
+   printf 'EXPORTS\n' > $...@-tmp
+   sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBVIRT_/d; s/\(.*\)\;/\1/g' 
$^ >> $...@-tmp
+   chmod a-w $...@-tmp
+   mv $...@-tmp libvirt.def
+
 # Empty source list - it merely links a bunch of convenience libs together
 libvirt_la_SOURCES =
 libvirt_la_LIBADD += \
$(CYGWIN_EXTRA_LIBADD) ../gnulib/lib/libgnu.la
-libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)libvirt.syms \
+libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \
  -version-info $(LIBVIRT_VERSION_INFO) \
 $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
 $(LIBXML_LIBS) \
$(DRIVER_MODULE_LIBS) \
$(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS)
 libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
-libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) libvirt.syms
+libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) $(LIBVIRT_SYMBOL_FILE)
 
 # Create an automake "convenience library" version of libvirt_la,
 # just for testing, since the test harness requires access to internal
@@ -865,7 +872,7 @@ noinst_LTLIBRARIES += libvirt_test.la
 # Remove version script from convenience library
 test_LDFLAGS = \
   $$(echo '$(libvirt_la_LDFLAGS)'  \
- |sed 's!$(VERSION_SCRIPT_FLAGS)libvirt.syms!!'\
+ |sed 's!$(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE)!!'  \
  |sed 's!-version-info $(LIBVIRT_VERSION_INFO)!!')
 
 # Just like the above, but with a slightly different set of public symbols.
-- 
1.6.3.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list