On Tue, Aug 13, 2013 at 09:51:22AM +0100, Daniel P. Berrange wrote:
On Mon, Aug 12, 2013 at 10:13:07PM +0200, Guido Günther wrote:
> On Mon, Aug 12, 2013 at 01:21:08PM -0600, Eric Blake wrote:
> > On 08/12/2013 01:14 PM, Guido Günther wrote:
> > > otherwise we fail like:
> > >
> > > CCLD virdbustest
> > > /usr/bin/ld: virdbustest-virdbustest.o: undefined reference to symbol
'dbus_message_unref'
> > > /lib/x86_64-linux-gnu/libdbus-1.so.3: error adding symbols: DSO
missing from command line
> > > collect2: error: ld returned 1 exit status
> > >
> > > Found by:
> > >
> > >
http://honk.sigxcpu.org:8001/job/libvirt-build-debian-sid-amd64/7/console
> > > ---
> > > tests/Makefile.am | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > ACK.
>
> I found several more places which fail to link with a strict
> --no-copy-dt-needed-entries. See my followup patch which superseeds this
> one.
Hmm, it sounds like we ought to make configure.ac automatically
add this linker flag if we can detect that it is supported.
Does this make sense:
Subject: [PATCH] Check for --no-copy-dt-needed linker flag
and use it when available
---
configure.ac | 1 +
m4/virt-linker-relro.m4 | 11 +++++++++++
src/Makefile.am | 9 +++++++++
tests/Makefile.am | 1 +
4 files changed, 22 insertions(+)
diff --git a/configure.ac b/configure.ac
index ac8cfa1..2084437 100644
--- a/configure.ac
+++ b/configure.ac
@@ -160,6 +160,7 @@ AC_MSG_RESULT([$VERSION_SCRIPT_FLAGS])
LIBVIRT_COMPILE_WARNINGS
LIBVIRT_COMPILE_PIE
LIBVIRT_LINKER_RELRO
+LIBVIRT_LINKER_NO_COPY_DT_NEEDED_ENTRIES
LIBVIRT_CHECK_APPARMOR
LIBVIRT_CHECK_ATTR
diff --git a/m4/virt-linker-relro.m4 b/m4/virt-linker-relro.m4
index 9bca90e..57b3d03 100644
--- a/m4/virt-linker-relro.m4
+++ b/m4/virt-linker-relro.m4
@@ -30,3 +30,14 @@ AC_DEFUN([LIBVIRT_LINKER_RELRO],[
AC_MSG_RESULT([$RELRO_LDFLAGS])
])
+
+AC_DEFUN([LIBVIRT_LINKER_NO_COPY_DT_NEEDED_ENTRIES],[
+ AC_MSG_CHECKING([for how to avoid indirect lib deps])
+
+ NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS=
+ `$LD --help 2>&1 | grep -- "--no-copy-dt-needed-entries"
>/dev/null` && \
+ NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS="-Wl,--no-copy-dt-needed-entries"
+ AC_SUBST([NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS])
+
+ AC_MSG_RESULT([$NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS])
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 4702cde..a04e154 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1813,6 +1813,7 @@ libvirt_la_LDFLAGS = \
$(LIBVIRT_NODELETE) \
$(AM_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(CYGWIN_EXTRA_LDFLAGS) \
$(MINGW_EXTRA_LDFLAGS) \
$(NULL)
@@ -1897,6 +1898,7 @@ libvirt_qemu_la_LDFLAGS = \
-version-info $(LIBVIRT_VERSION_INFO) \
$(AM_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(CYGWIN_EXTRA_LDFLAGS) \
$(MINGW_EXTRA_LDFLAGS) \
$(NULL)
@@ -1909,6 +1911,7 @@ libvirt_lxc_la_LDFLAGS = \
-version-info $(LIBVIRT_VERSION_INFO) \
$(AM_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(CYGWIN_EXTRA_LDFLAGS) \
$(MINGW_EXTRA_LDFLAGS) \
$(NULL)
@@ -1965,6 +1968,7 @@ virtlockd_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(CYGWIN_EXTRA_LDFLAGS) \
$(MINGW_EXTRA_LDFLAGS) \
$(NULL)
@@ -2244,6 +2248,7 @@ libvirt_iohelper_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(NULL)
libvirt_iohelper_LDADD = \
libvirt_util.la \
@@ -2267,6 +2272,7 @@ libvirt_parthelper_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(NULL)
libvirt_parthelper_LDADD = \
$(LIBPARTED_LIBS) \
@@ -2299,6 +2305,7 @@ libvirt_sanlock_helper_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(NULL)
libvirt_sanlock_helper_LDADD = libvirt.la
endif
@@ -2315,6 +2322,7 @@ libvirt_lxc_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(NULL)
libvirt_lxc_LDADD = \
$(FUSE_LIBS) \
@@ -2359,6 +2367,7 @@ virt_aa_helper_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(RELRO_LDFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(NULL)
virt_aa_helper_LDADD = \
libvirt_conf.la \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9098dec..85c91d7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -50,6 +50,7 @@ endif
LDADDS = \
$(WARN_CFLAGS) \
+ $(NO_COPY_DT_NEEDED_ENTRIES_LDFLAGS) \
$(PROBES_O) \
../src/libvirt.la \
../gnulib/lib/libgnu.la
--
1.8.4.rc1