Re: [PATCH] Avoid link errors with "configure --disable-shared".

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

 



Jim Meyering <jim@xxxxxxxxxxxx> wrote:

> "Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:
>
>> On Wed, Feb 27, 2008 at 04:52:21PM +0100, Jim Meyering wrote:
>>> I got link errors when building with --disable-shared, and finally
>>> fixed it.  Here's most of the solution.  The patch after this one
>>> adjusts the gcov (test-coverage)-related things so that works with
>>> the new setup, too.
>>> diff --git a/src/libvirt_sym.version b/src/libvirt_sym.version
>>> index 38b631e..581f380 100644
>>> --- a/src/libvirt_sym.version
>>> +++ b/src/libvirt_sym.version
>>> @@ -32,6 +32,7 @@
>>>  	virDomainLookupByName;
>>>  	virDomainLookupByUUID;
>>>  	virDomainLookupByUUIDString;
>>> +	virDomainParseXMLDesc;
>>
>> This is not part of the public API.
>
> Good catch.
> I needed that with an earlier incarnation of this work,
> but no longer.
>
>>> @@ -184,6 +185,8 @@
>>>          __virBufferVSprintf;
>>>          __virBufferAdd;
>>>          __virBufferAddChar;
>>> +        __virErrorMsg;
>>> +        __virRaiseError;
>>
>> What uses these two symbols ? AFAIK they shoudl only ever be
>> called by internal drivers and not exported
>
> Same here.
>
> With those adjustments, the only changes to libvirt_sym.version
> are to remove some SPACE-before-TAB.

Here's the adjusted patch.
If no one objects, I'll commit these two later today.

	Subject: [PATCH] Avoid link errors with "configure --disable-shared".
	* src/Makefile.am: Create a convenience library, libvirt_test.la,
	and don't restrict access to *its* symbols.
	* tests/Makefile.am (LDADDS): Add ../src/libvirt_test.la, so that
	"configure --disable-shared" no longer provokes link errors.
	(LIBVIRT): Remove definition.
	(LDADDS): Remove use.
	($(LIBVIRT)): Remove rule.
	(LDADDS): Use the new convenience library instead.
	(CLEANFILES): Define.
	* docs/examples/index.py (dump_Makefile): Append $(COVERAGE_LDFLAGS),
	to the LDADDS definition, to avoid link error with the combination of
	--enable-test-coverage and --disable-shared.
	* docs/examples/Makefile.am: Regenerate.
	* docs/examples/index.html: Likewise.
	* qemud/Makefile.am (libvirtd_LDFLAGS): Append $(COVERAGE_LDFLAGS).
	* src/libvirt_sym.version: Remove some SP-before-TAB.

Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 docs/examples/Makefile.am |    2 +-
 docs/examples/index.html  |    2 +-
 docs/examples/index.py    |    3 ++-
 qemud/Makefile.am         |   26 ++++++++++++++++----------
 src/Makefile.am           |   19 +++++++++++++++++++
 src/libvirt_sym.version   |    8 ++++----
 tests/Makefile.am         |   13 ++-----------
 7 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am
index 9da4e21..d8e4868 100644
--- a/docs/examples/Makefile.am
+++ b/docs/examples/Makefile.am
@@ -3,7 +3,7 @@
 SUBDIRS=python
 INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include
 DEPS = $(top_builddir)/src/libvirt.la
-LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la
+LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la 	$(COVERAGE_LDFLAGS)

 rebuild: examples.xml index.html

diff --git a/docs/examples/index.py b/docs/examples/index.py
index 8f386ed..6be80c5 100755
--- a/docs/examples/index.py
+++ b/docs/examples/index.py
@@ -225,7 +225,8 @@ def dump_Makefile():
 SUBDIRS=python
 INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include
 DEPS = $(top_builddir)/src/libvirt.la
-LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la
+LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \
+	$(COVERAGE_LDFLAGS)

 rebuild: examples.xml index.html

diff --git a/qemud/Makefile.am b/qemud/Makefile.am
index 3094b18..8cbcebe 100644
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -48,18 +48,22 @@ libvirtd_SOURCES = \

 #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
 libvirtd_CFLAGS = \
-        -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
-        -I$(top_srcdir)/include -I$(top_builddir)/include \
-        $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \
-        $(POLKIT_CFLAGS) \
-        $(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
-        -DSYSCONF_DIR="\"$(sysconfdir)\"" \
+	-I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
+	-I$(top_srcdir)/include -I$(top_builddir)/include \
+	$(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \
+	$(POLKIT_CFLAGS) \
+	$(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
+	$(COVERAGE_CFLAGS) \
+	-DSYSCONF_DIR="\"$(sysconfdir)\"" \
 	-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
 	-DREMOTE_PID_FILE="\"$(REMOTE_PID_FILE)\"" \
-        -DGETTEXT_PACKAGE=\"$(PACKAGE)\"
+	-DGETTEXT_PACKAGE=\"$(PACKAGE)\"
+
+libvirtd_LDFLAGS = \
+	$(WARN_CFLAGS) $(LIBXML_LIBS) $(GNUTLS_LIBS) $(SASL_LIBS) \
+	$(COVERAGE_LDFLAGS)
+	$(POLKIT_LIBS)

-libvirtd_LDFLAGS = $(WARN_CFLAGS) $(LIBXML_LIBS) $(GNUTLS_LIBS) $(SASL_LIBS) \
-                   $(POLKIT_LIBS)
 libvirtd_DEPENDENCIES = ../src/libvirt.la
 libvirtd_LDADD = ../src/libvirt.la ../gnulib/lib/libgnu.la

@@ -145,7 +149,6 @@ libvirtd.init: libvirtd.init.in
 	chmod a+x $@-t
 	mv $@-t $@

-CLEANFILES = libvirtd.init
 else

 install-init:
@@ -154,3 +157,6 @@ uninstall-init:
 endif # DBUS_INIT_SCRIPTS_RED_HAT

 endif # WITH_LIBVIRTD
+
+CLEANFILES = libvirtd.init
+CLEANFILES += *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
diff --git a/src/Makefile.am b/src/Makefile.am
index 9c4810a..8821faa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -99,6 +99,25 @@ libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
 		    @CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
 libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT

+# Create an automake "convenience library" version of libvirt_la,
+# just for testing, since the test harness requires access to internal
+# bits and pieces that we don't want to make publicly accessible.
+noinst_LTLIBRARIES = libvirt_test.la
+
+# Convert libvirt_sym.version
+#      to libvirt_test_sym.version, and
+# remove -version-info X.Y.Z (not needed since this is a convenience library.
+test_LDFLAGS =						\
+  $$(echo '$(libvirt_la_LDFLAGS)'			\
+     |sed 's!-Wl,--v.*_sym\.version!!'			\
+     |sed 's!-version-info @LIBVIRT_VERSION_INFO@!!')
+
+# Just like the above, but with a slightly different set of public symbols.
+libvirt_test_la_SOURCES = $(libvirt_la_SOURCES)
+libvirt_test_la_LIBADD = $(libvirt_la_LIBADD)
+libvirt_test_la_LDFLAGS = $(test_LDFLAGS)
+libvirt_test_la_CFLAGS = $(COVERAGE_CFLAGS)
+
 bin_PROGRAMS = virsh

 virsh_SOURCES = virsh.c console.c console.h util-lib.c util-lib.h
diff --git a/src/libvirt_sym.version b/src/libvirt_sym.version
index 15c05dc..694e041 100644
--- a/src/libvirt_sym.version
+++ b/src/libvirt_sym.version
@@ -166,10 +166,10 @@

 	__virEventRegisterImpl;

- 	__virStateInitialize;
- 	__virStateCleanup;
- 	__virStateReload;
- 	__virStateActive;
+	__virStateInitialize;
+	__virStateCleanup;
+	__virStateReload;
+	__virStateActive;

 	__virDrvSupportsFeature;

diff --git a/tests/Makefile.am b/tests/Makefile.am
index fb9bcff..644715e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,14 +3,6 @@
 SUBDIRS = virshdata confdata sexpr2xmldata \
   xml2sexprdata xmconfigdata xencapsdata

-# Wierd libtool related juju...
-#
-# We explicitly want wildcard here instead of just linking
-# to the libvirt.a file. This ensures that when coverage
-# tests are run, all the output data ends up in the correct
-# location. ie, src/ instead of src/.libs.
-LIBVIRT = $(wildcard $(top_builddir)/src/.libs/libvirt_la-*.o)
-
 INCLUDES = \
 	-I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
 	-I$(top_builddir)/include \
@@ -34,7 +26,7 @@ LDADDS = \
         $(SASL_LIBS) \
         $(SELINUX_LIBS) \
         $(WARN_CFLAGS) \
-	$(LIBVIRT) \
+	../src/libvirt_test.la \
 	../gnulib/lib/libgnu.la \
         $(COVERAGE_LDFLAGS)

@@ -132,5 +124,4 @@ reconnect_SOURCES = \
 	reconnect.c
 reconnect_LDADD = $(LDADDS)

-$(LIBVIRT):
-	-@(cd $(top_builddir)/src && $(MAKE) MAKEFLAGS+=--silent)
+CLEANFILES = *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
--
1.5.4.3.326.g7655e3


	Rewrite test-coverage rules to accommodate multiple .o files per .c.
        * src/Makefile.am (cov): Rewrite rule to merge gcov results corresponding
        to two .o files: the libvirt_la- one, and the libvirt_test_la- one.
        (tst): Remove unused rule.
        * configure.in (LV_LIBTOOL_OBJDIR): Define and AC_SUBST.

Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 configure.in    |    7 +++++++
 src/Makefile.am |   24 ++++++++++++------------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/configure.in b/configure.in
index c2030c7..6367990 100644
--- a/configure.in
+++ b/configure.in
@@ -913,6 +913,13 @@ AC_SUBST(MINGW_EXTRA_LDFLAGS)

 AC_SYS_LARGEFILE

+# Set LV_LIBTOOL_OBJDIR to "." or $lt_cv_objdir, depending on whether
+# we're building shared libraries.  This is the name of the directory
+# in which .o files will be created.
+test "$enable_shared" = no && lt_cv_objdir=.
+LV_LIBTOOL_OBJDIR=${lt_cv_objdir-.}
+AC_SUBST(LV_LIBTOOL_OBJDIR)
+
 # very annoying
 rm -f COPYING
 cp COPYING.LIB COPYING
diff --git a/src/Makefile.am b/src/Makefile.am
index 8821faa..d7e4a91 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -137,20 +137,20 @@ else
 EXTRA_DIST += parthelper.c
 endif

-#
-# target to ease building test programs
-#
-tst: tst.c
-	$(CC) $(CFLAGS) $(INCLUDES) -I../include -o tst tst.c .libs/libvirt.a $(LIBXML_LIBS) $(VIRSH_LIBS) $(GNUTLS_LIBS) $(LIBS)
-
-COVERAGE_FILES = $(CLIENT_SOURCES:%.c=libvirt_la-%.cov)
-
-cov: clean-cov $(COVERAGE_FILES)
+cov: clean-cov
+	for i in $(CLIENT_SOURCES); do			\
+	  case $$i in *.c) ;; *) continue;; esac;	\
+	  b=$$(basename $$i .c);			\
+	  o_files=;					\
+	  for i in '' _test; do				\
+	    o="$(LV_LIBTOOL_OBJDIR)/libvirt$${i}_la-$$b.o";	\
+	    test -f "$$o"				\
+	      && o_files="$$o_files $$o";		\
+	  done;						\
+	  gcov -b -f $$o_files > $$b.cov;		\
+	done

 clean-cov:
 	rm -f *.cov *.gcov

-%.cov: .libs/%.o
-	gcov -b -f -o .libs $< > $@
-
 CLEANFILES = *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
--
1.5.4.3.326.g7655e3

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]