[libvirt] [PATCH] Link to virdbustest against DBus libs

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(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 4aa02dd..d6f60a1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -673,7 +673,7 @@ if WITH_DBUS virdbustest_SOURCES = \ virdbustest.c testutils.h testutils.c virdbustest_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -virdbustest_LDADD = $(LDADDS) +virdbustest_LDADD = $(LDADDS) $(DBUS_LIBS) virsystemdtest_SOURCES = \ virsystemdtest.c testutils.h testutils.c -- 1.8.4.rc1

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.
diff --git a/tests/Makefile.am b/tests/Makefile.am index 4aa02dd..d6f60a1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -673,7 +673,7 @@ if WITH_DBUS virdbustest_SOURCES = \ virdbustest.c testutils.h testutils.c virdbustest_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -virdbustest_LDADD = $(LDADDS) +virdbustest_LDADD = $(LDADDS) $(DBUS_LIBS)
virsystemdtest_SOURCES = \ virsystemdtest.c testutils.h testutils.c
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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. Cheers, -- Guido
diff --git a/tests/Makefile.am b/tests/Makefile.am index 4aa02dd..d6f60a1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -673,7 +673,7 @@ if WITH_DBUS virdbustest_SOURCES = \ virdbustest.c testutils.h testutils.c virdbustest_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -virdbustest_LDADD = $(LDADDS) +virdbustest_LDADD = $(LDADDS) $(DBUS_LIBS)
virsystemdtest_SOURCES = \ virsystemdtest.c testutils.h testutils.c
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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. 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 :|

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

On Tue, Aug 13, 2013 at 02:23:41PM +0200, Guido Günther wrote:
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]) +])
This doesn't belong in this file. Create a new virt-linker-no-indirect.m4 file for it. The variable / macro names are rather too long too - use something like NO_INDIRECT_LDFLAGS / LIBVIRT_LINKER_NO_INDIRECT respectively. 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 :|

and use it when available --- configure.ac | 1 + m4/virt-linker-no-indirect.m4 | 30 ++++++++++++++++++++++++++++++ src/Makefile.am | 9 +++++++++ tests/Makefile.am | 1 + 4 files changed, 41 insertions(+) create mode 100644 m4/virt-linker-no-indirect.m4 diff --git a/configure.ac b/configure.ac index ac8cfa1..25d91ce 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_INDIRECT LIBVIRT_CHECK_APPARMOR LIBVIRT_CHECK_ATTR diff --git a/m4/virt-linker-no-indirect.m4 b/m4/virt-linker-no-indirect.m4 new file mode 100644 index 0000000..2ccd960 --- /dev/null +++ b/m4/virt-linker-no-indirect.m4 @@ -0,0 +1,30 @@ +dnl +dnl Check for --no-copy-dt-needed-entries +dnl +dnl Copyright (C) 2013 Guido Günther <agx@sigxcpu.org> +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl <http://www.gnu.org/licenses/>. +dnl + +AC_DEFUN([LIBVIRT_LINKER_NO_INDIRECT],[ + AC_MSG_CHECKING([for how to avoid indirect lib deps]) + + NO_INDIRECT_LDFLAGS= + `$LD --help 2>&1 | grep -- "--no-copy-dt-needed-entries" >/dev/null` && \ + NO_INDIRECT_LDFLAGS="-Wl,--no-copy-dt-needed-entries" + AC_SUBST([NO_INDIRECT_LDFLAGS]) + + AC_MSG_RESULT([$NO_INDIRECT_LDFLAGS]) +]) diff --git a/src/Makefile.am b/src/Makefile.am index 4702cde..adef55a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1813,6 +1813,7 @@ libvirt_la_LDFLAGS = \ $(LIBVIRT_NODELETE) \ $(AM_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_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_INDIRECT_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_INDIRECT_LDFLAGS) \ $(CYGWIN_EXTRA_LDFLAGS) \ $(MINGW_EXTRA_LDFLAGS) \ $(NULL) @@ -1965,6 +1968,7 @@ virtlockd_LDFLAGS = \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \ $(CYGWIN_EXTRA_LDFLAGS) \ $(MINGW_EXTRA_LDFLAGS) \ $(NULL) @@ -2244,6 +2248,7 @@ libvirt_iohelper_LDFLAGS = \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \ $(NULL) libvirt_iohelper_LDADD = \ libvirt_util.la \ @@ -2267,6 +2272,7 @@ libvirt_parthelper_LDFLAGS = \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \ $(NULL) libvirt_parthelper_LDADD = \ $(LIBPARTED_LIBS) \ @@ -2299,6 +2305,7 @@ libvirt_sanlock_helper_LDFLAGS = \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \ $(NULL) libvirt_sanlock_helper_LDADD = libvirt.la endif @@ -2315,6 +2322,7 @@ libvirt_lxc_LDFLAGS = \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \ $(NULL) libvirt_lxc_LDADD = \ $(FUSE_LIBS) \ @@ -2359,6 +2367,7 @@ virt_aa_helper_LDFLAGS = \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \ $(NULL) virt_aa_helper_LDADD = \ libvirt_conf.la \ diff --git a/tests/Makefile.am b/tests/Makefile.am index 9098dec..86c3e11 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -50,6 +50,7 @@ endif LDADDS = \ $(WARN_CFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \ $(PROBES_O) \ ../src/libvirt.la \ ../gnulib/lib/libgnu.la -- 1.8.4.rc3

On 08/19/2013 11:28 AM, Guido Günther wrote:
and use it when available --- configure.ac | 1 + m4/virt-linker-no-indirect.m4 | 30 ++++++++++++++++++++++++++++++ src/Makefile.am | 9 +++++++++ tests/Makefile.am | 1 + 4 files changed, 41 insertions(+) create mode 100644 m4/virt-linker-no-indirect.m4
+AC_DEFUN([LIBVIRT_LINKER_NO_INDIRECT],[ + AC_MSG_CHECKING([for how to avoid indirect lib deps]) + + NO_INDIRECT_LDFLAGS= + `$LD --help 2>&1 | grep -- "--no-copy-dt-needed-entries" >/dev/null` && \
Doesn't do what you think (it tries to execute the output of grep - which is thankfully empty on both success and failure). Also wastes a fork on grep, compared to the simpler: case `$LD --help 2>&1` in *--no-copy-dt-needed-entries*) NO_INDIRECT_LDFLAGS=... ;; esac
+++ b/src/Makefile.am @@ -1813,6 +1813,7 @@ libvirt_la_LDFLAGS = \ $(LIBVIRT_NODELETE) \ $(AM_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \
Why aren't you building this directly into $(AM_LDFLAGS) once, rather than having to copy it into each and every library recipe? Why only src/ and tests/? What about tools/ and daemon/? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Mon, Aug 19, 2013 at 11:37:24AM -0600, Eric Blake wrote:
On 08/19/2013 11:28 AM, Guido Günther wrote:
and use it when available --- configure.ac | 1 + m4/virt-linker-no-indirect.m4 | 30 ++++++++++++++++++++++++++++++ src/Makefile.am | 9 +++++++++ tests/Makefile.am | 1 + 4 files changed, 41 insertions(+) create mode 100644 m4/virt-linker-no-indirect.m4
+AC_DEFUN([LIBVIRT_LINKER_NO_INDIRECT],[ + AC_MSG_CHECKING([for how to avoid indirect lib deps]) + + NO_INDIRECT_LDFLAGS= + `$LD --help 2>&1 | grep -- "--no-copy-dt-needed-entries" >/dev/null` && \
Doesn't do what you think (it tries to execute the output of grep - which is thankfully empty on both success and failure). Also wastes a fork on grep, compared to the simpler:
I was looking following virt-linker-relro.m4 and I'm getting the correct result since the output is always empty but for the non matching case grep exits with 1. However
case `$LD --help 2>&1` in *--no-copy-dt-needed-entries*) NO_INDIRECT_LDFLAGS=... ;; esac
this looks nicer.
+++ b/src/Makefile.am @@ -1813,6 +1813,7 @@ libvirt_la_LDFLAGS = \ $(LIBVIRT_NODELETE) \ $(AM_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \
Why aren't you building this directly into $(AM_LDFLAGS) once, rather than having to copy it into each and every library recipe?
Why only src/ and tests/? What about tools/ and daemon/?
Again following the above example. I'll come up with a v3. Cheers, -- Guido
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/19/2013 12:07 PM, Guido Günther wrote:
+ NO_INDIRECT_LDFLAGS= + `$LD --help 2>&1 | grep -- "--no-copy-dt-needed-entries" >/dev/null` && \
Doesn't do what you think (it tries to execute the output of grep - which is thankfully empty on both success and failure). Also wastes a fork on grep, compared to the simpler:
I was looking following virt-linker-relro.m4 and I'm getting the correct result since the output is always empty but for the non matching case grep exits with 1. However
case `$LD --help 2>&1` in *--no-copy-dt-needed-entries*) NO_INDIRECT_LDFLAGS=... ;; esac
this looks nicer.
Oh sure - blame copy-and-paste of bad habits :)
Why aren't you building this directly into $(AM_LDFLAGS) once, rather than having to copy it into each and every library recipe?
Why only src/ and tests/? What about tools/ and daemon/?
Again following the above example. I'll come up with a v3.
For a v3, it might be nice to have two patches - one that cleans up the bad habits of RELRO handling, and the second that extends it with the cleaner idioms. Thanks for putting up with me :) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Mon, Aug 19, 2013 at 01:36:36PM -0600, Eric Blake wrote:
On 08/19/2013 12:07 PM, Guido Günther wrote:
+ NO_INDIRECT_LDFLAGS= + `$LD --help 2>&1 | grep -- "--no-copy-dt-needed-entries" >/dev/null` && \
Doesn't do what you think (it tries to execute the output of grep - which is thankfully empty on both success and failure). Also wastes a fork on grep, compared to the simpler:
I was looking following virt-linker-relro.m4 and I'm getting the correct result since the output is always empty but for the non matching case grep exits with 1. However
case `$LD --help 2>&1` in *--no-copy-dt-needed-entries*) NO_INDIRECT_LDFLAGS=... ;; esac
this looks nicer.
Oh sure - blame copy-and-paste of bad habits :)
Not actually blaming more following current practice. We're not using AM_LDFLAGS everywhere. This should be a sperate cleanup in case this is considered useful. Which I think would be since we're misusing LDADDS in e.g. tests/Makefile.am for cflags, linkerflags and actually adding additional libraries. Cheers, -- Guido
Why aren't you building this directly into $(AM_LDFLAGS) once, rather than having to copy it into each and every library recipe?
Why only src/ and tests/? What about tools/ and daemon/?
Again following the above example. I'll come up with a v3.
For a v3, it might be nice to have two patches - one that cleans up the bad habits of RELRO handling, and the second that extends it with the cleaner idioms. Thanks for putting up with me :)
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Mon, Aug 19, 2013 at 08:07:42PM +0200, Guido Günther wrote:
On Mon, Aug 19, 2013 at 11:37:24AM -0600, Eric Blake wrote:
On 08/19/2013 11:28 AM, Guido Günther wrote:
and use it when available --- configure.ac | 1 + m4/virt-linker-no-indirect.m4 | 30 ++++++++++++++++++++++++++++++ src/Makefile.am | 9 +++++++++ tests/Makefile.am | 1 + 4 files changed, 41 insertions(+) create mode 100644 m4/virt-linker-no-indirect.m4
+AC_DEFUN([LIBVIRT_LINKER_NO_INDIRECT],[ + AC_MSG_CHECKING([for how to avoid indirect lib deps]) + + NO_INDIRECT_LDFLAGS= + `$LD --help 2>&1 | grep -- "--no-copy-dt-needed-entries" >/dev/null` && \
Doesn't do what you think (it tries to execute the output of grep - which is thankfully empty on both success and failure). Also wastes a fork on grep, compared to the simpler:
I was looking following virt-linker-relro.m4 and I'm getting the correct result since the output is always empty but for the non matching case grep exits with 1. However
case `$LD --help 2>&1` in *--no-copy-dt-needed-entries*) NO_INDIRECT_LDFLAGS=... ;; esac
this looks nicer.
+++ b/src/Makefile.am @@ -1813,6 +1813,7 @@ libvirt_la_LDFLAGS = \ $(LIBVIRT_NODELETE) \ $(AM_LDFLAGS) \ $(RELRO_LDFLAGS) \ + $(NO_INDIRECT_LDFLAGS) \
Why aren't you building this directly into $(AM_LDFLAGS) once, rather than having to copy it into each and every library recipe?
Why only src/ and tests/? What about tools/ and daemon/?
Again following the above example. I'll come up with a v3. Cheers,
Personally I prefer to see things explicitly listed rather than hide them behind AM_LDFLAGS. 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 :|

otherwise having a strict --no-copy-dt-needed-entries fails in several places like: 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 --- src/Makefile.am | 5 ++++- tests/Makefile.am | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7e24c1f..074ab18 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1119,7 +1120,8 @@ libvirt_driver_qemu_impl_la_CFLAGS = \ libvirt_driver_qemu_impl_la_LDFLAGS = $(AM_LDFLAGS) libvirt_driver_qemu_impl_la_LIBADD = $(CAPNG_LIBS) \ $(GNUTLS_LIBS) \ - $(LIBNL_LIBS) + $(LIBNL_LIBS) \ + $(LIBXML_LIBS) libvirt_driver_qemu_impl_la_SOURCES = $(QEMU_DRIVER_SOURCES) conf_DATA += qemu/qemu.conf @@ -1280,6 +1282,7 @@ libvirt_driver_network_impl_la_CFLAGS = \ -I$(top_srcdir)/src/conf \ $(AM_CFLAGS) libvirt_driver_network_impl_la_SOURCES = $(NETWORK_DRIVER_SOURCES) +libvirt_driver_network_impl_la_LIBADD = $(DBUS_LIBS) endif EXTRA_DIST += network/default.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index 6f43b09..a9bcf4c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -391,7 +391,7 @@ qemu_LDADDS += $(LDADDS) qemuxml2argvtest_SOURCES = \ qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxml2argvtest_LDADD = $(qemu_LDADDS) +qemuxml2argvtest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) qemuxml2xmltest_SOURCES = \ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \ @@ -559,7 +559,7 @@ interfacexml2xmltest_LDADD = $(LDADDS) cputest_SOURCES = \ cputest.c \ testutils.c testutils.h -cputest_LDADD = $(LDADDS) +cputest_LDADD = $(LDADDS) $(LIBXML_LIBS) virshtest_SOURCES = \ virshtest.c \ @@ -606,12 +606,12 @@ virnettlscontexttest_SOURCES = \ virnettlscontexttest.c \ virnettlshelpers.h virnettlshelpers.c \ testutils.h testutils.c -virnettlscontexttest_LDADD = $(LDADDS) +virnettlscontexttest_LDADD = $(LDADDS) $(GNUTLS_LIBS) virnettlssessiontest_SOURCES = \ virnettlssessiontest.c \ virnettlshelpers.h virnettlshelpers.c \ testutils.h testutils.c -virnettlssessiontest_LDADD = $(LDADDS) +virnettlssessiontest_LDADD = $(LDADDS) $(GNUTLS_LIBS) if HAVE_LIBTASN1 virnettlscontexttest_SOURCES += pkix_asn1_tab.c virnettlscontexttest_LDADD += -ltasn1 @@ -675,7 +675,7 @@ if WITH_DBUS virdbustest_SOURCES = \ virdbustest.c testutils.h testutils.c virdbustest_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -virdbustest_LDADD = $(LDADDS) +virdbustest_LDADD = $(LDADDS) $(DBUS_LIBS) virsystemdtest_SOURCES = \ virsystemdtest.c testutils.h testutils.c -- 1.8.4.rc1

On 08/12/2013 02:13 PM, Guido Günther wrote:
otherwise having a strict --no-copy-dt-needed-entries fails in several places like:
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 --- src/Makefile.am | 5 ++++- tests/Makefile.am | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
ACK with one nit:
diff --git a/src/Makefile.am b/src/Makefile.am index 7e24c1f..074ab18 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1119,7 +1120,8 @@ libvirt_driver_qemu_impl_la_CFLAGS = \ libvirt_driver_qemu_impl_la_LDFLAGS = $(AM_LDFLAGS) libvirt_driver_qemu_impl_la_LIBADD = $(CAPNG_LIBS) \ $(GNUTLS_LIBS) \ - $(LIBNL_LIBS) + $(LIBNL_LIBS) \ + $(LIBXML_LIBS)
If you wouldn't mind, write this one as: $(LIBNL_LIBS) \ $(LIBXML_LIBS) \ $(NULL) so that next time we touch this, we only have to add one line instead of modify an existing line. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Hi Eric, On Mon, Aug 12, 2013 at 02:15:50PM -0600, Eric Blake wrote:
On 08/12/2013 02:13 PM, Guido Günther wrote:
otherwise having a strict --no-copy-dt-needed-entries fails in several places like:
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 --- src/Makefile.am | 5 ++++- tests/Makefile.am | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
ACK with one nit:
diff --git a/src/Makefile.am b/src/Makefile.am index 7e24c1f..074ab18 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1119,7 +1120,8 @@ libvirt_driver_qemu_impl_la_CFLAGS = \ libvirt_driver_qemu_impl_la_LDFLAGS = $(AM_LDFLAGS) libvirt_driver_qemu_impl_la_LIBADD = $(CAPNG_LIBS) \ $(GNUTLS_LIBS) \ - $(LIBNL_LIBS) + $(LIBNL_LIBS) \ + $(LIBXML_LIBS)
If you wouldn't mind, write this one as:
$(LIBNL_LIBS) \ $(LIBXML_LIBS) \ $(NULL)
so that next time we touch this, we only have to add one line instead of modify an existing line.
Pushed. This brought the debian kfreebsd build back to green: http://honk.sigxcpu.org:8001/job/libvirt-build-debian-jessie-kfreebsd64/65/ Cheers, -- Guido
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Guido Günther