Re: [spice-gtk] build-sys:tests: Error out unless --enable-static is used

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 13, 2015 at 10:56:00AM +0200, Christophe Fergeau wrote:
> The binaries in tests/ need a static build of spice-gtk libraries in
> order to be built, but by default, we disable static libraries at
> LT_INIT() time.
> As the compile failure can be quite cryptic when someone
> tries to manually run 'make -C tests', this commit adds an explicit
> error message when trying to build the tests without --enable-static.
> ---
>  tests/Makefile.am | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 19c02b6..144bc38 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -1,3 +1,6 @@
> +if !BUILD_TESTS
> +$(error Building tests requires using --enable-static)
> +endif
>  NULL =

IIUC, the problem you have is that the tests try to link to the
libspice-client-glib-2.0.la, but when that is a share library
the symbols you need to use are hidden due to the linker script
whitelist.

One way to get around that is to build the sources you need into
a parallel convenience library and use that instead when running
tests. The main downside of this approach is that everything
ends up being compiled twice.

You would do something like this:

diff --git a/src/Makefile.am b/src/Makefile.am
index 0c40c48..9245bce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -381,6 +381,17 @@ endif
 libspice_client_glib_2_0_la_LIBADD += -lws2_32 -lgdi32
 endif
 
+# Remove version script from convenience library
+test_LDFLAGS =                                         \
+  $$(echo '$(libspice_client_glib_2_0_la_LDFLAGS)'                      \
+     |sed 's!$(GLIB_SYMBOLS_LDFLAGS)!!')
+
+noinst_LTLIBRARIES = libspice-client-glib-test.la
+libspice_client_glib_test_la_SOURCES = $(libspice_client_glib_2_0_la_SOURCES)
+libspice_client_glib_test_la_LIBADD = $(libspice_client_glib_2_0_la_LIBADD)
+libspice_client_glib_test_la_LDFLAGS = $(test_LDFLAGS) $(AM_LDFLAGS)
+libspice_client_glib_test_la_CFLAGS = $(AM_CFLAGS)
+
 spicy_SOURCES =                                        \
        spicy.c                                 \
        spicy-connect.h                         \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 19c02b6..1049ea3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,10 +19,10 @@ AM_CPPFLAGS =                                       \
        -DG_LOG_DOMAIN=\"GSpice\"               \
        $(NULL)
 
-AM_LDFLAGS = $(GIO_LIBS) -static
+AM_LDFLAGS = $(GIO_LIBS)
 
 LDADD =                                                        \
-       $(top_builddir)/src/libspice-client-glib-2.0.la \
+       $(top_builddir)/src/libspice-client-glib-test.la        \
        $(NULL)
 
 util_SOURCES = util.c


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]