[libvirt] [PATCH] fix xdr detection and use with recent glibc

glibc 2.13.90 has obsoleted its rpc implementation in favour of the one provided by the TI-RPC library:
* The RPC implementation in libc is obsoleted. Old programs keep working but new programs cannot be linked with the routines in libc anymore. Programs in need of RPC functionality must be linked against TI-RPC. The TI-RPC implemtation is IPv6 enabled and there are other benefits.
Visible changes of this change include (obviously) the inability to link programs using RPC functions without referencing the TI-RPC library, the removal of the RPC headers from the glibc headers, and the lack of symbols defined in <rpc/netdb.h> when <netdb.h> is installed. Implemented by Ulrich Drepper. (from glibc NEWS)
Thus with recent glibc, we need to try linking with -ltirpc when looking for the XDR functions. The daemon also needs to use XDR_CFLAGS to be able to find the XDR headers stored in /usr/include/tirpc. When using TI-RPC, there are some warnings about redundant declarations, but the fix probably belongs in other modules: /usr/include/tirpc/rpc/rpcent.h:68:13: warning: redundant redeclaration of 'setrpcent' [-Wredundant-decls] /usr/include/rpc/netdb.h:53:13: note: previous declaration of 'setrpcent' was here /usr/include/tirpc/rpc/rpcent.h:69:13: warning: redundant redeclaration of 'endrpcent' [-Wredundant-decls] /usr/include/rpc/netdb.h:54:13: note: previous declaration of 'endrpcent' was here /usr/include/tirpc/rpc/rpc.h:84:12: warning: redundant redeclaration of 'bindresvport' [-Wredundant-decls] /usr/include/netinet/in.h:440:12: note: previous declaration of 'bindresvport' was here --- configure.ac | 6 +++--- daemon/Makefile.am | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index dcec371..db1c0e6 100644 --- a/configure.ac +++ b/configure.ac @@ -366,16 +366,16 @@ if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then dnl Where are the XDR functions? dnl If portablexdr is installed, prefer that. dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW), -lnsl (Solaris) - dnl or none (most Unix) + dnl -ltirpc (glibc 2.13.90 or newer) or none (most Unix) AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[ - AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl],[], + AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl tirpc],[], [AC_MSG_ERROR([Cannot find a XDR library])]) ]) dnl check for cygwin's variation in xdr function names AC_CHECK_FUNCS([xdr_u_int64_t],[],[],[#include <rpc/xdr.h>]) - dnl Cygwin requires -I/usr/include/tirpc for <rpc/rpc.h> + dnl Cygwin/recent glibc requires -I/usr/include/tirpc for <rpc/rpc.h> old_CFLAGS=$CFLAGS AC_CACHE_CHECK([where to find <rpc/rpc.h>], [lv_cv_xdr_cflags], [ for add_CFLAGS in '' '-I/usr/include/tirpc' 'missing'; do diff --git a/daemon/Makefile.am b/daemon/Makefile.am index af71188..ef1804b 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -80,7 +80,7 @@ libvirtd_CFLAGS = \ -I$(top_srcdir)/src/conf \ -I$(top_srcdir)/src/remote \ $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \ - $(POLKIT_CFLAGS) \ + $(XDR_CFLAGS) $(POLKIT_CFLAGS) \ $(WARN_CFLAGS) \ $(COVERAGE_CFLAGS) \ -DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \ -- 1.7.5.1

On Tue, May 10, 2011 at 05:42:06PM +0200, Christophe Fergeau wrote:
glibc 2.13.90 has obsoleted its rpc implementation in favour of the one provided by the TI-RPC library:
* The RPC implementation in libc is obsoleted. Old programs keep working but new programs cannot be linked with the routines in libc anymore. Programs in need of RPC functionality must be linked against TI-RPC. The TI-RPC implemtation is IPv6 enabled and there are other benefits.
Visible changes of this change include (obviously) the inability to link programs using RPC functions without referencing the TI-RPC library, the removal of the RPC headers from the glibc headers, and the lack of symbols defined in <rpc/netdb.h> when <netdb.h> is installed. Implemented by Ulrich Drepper. (from glibc NEWS)
Thus with recent glibc, we need to try linking with -ltirpc when looking for the XDR functions. The daemon also needs to use XDR_CFLAGS to be able to find the XDR headers stored in /usr/include/tirpc.
When using TI-RPC, there are some warnings about redundant declarations, but the fix probably belongs in other modules:
/usr/include/tirpc/rpc/rpcent.h:68:13: warning: redundant redeclaration of 'setrpcent' [-Wredundant-decls] /usr/include/rpc/netdb.h:53:13: note: previous declaration of 'setrpcent' was here
/usr/include/tirpc/rpc/rpcent.h:69:13: warning: redundant redeclaration of 'endrpcent' [-Wredundant-decls] /usr/include/rpc/netdb.h:54:13: note: previous declaration of 'endrpcent' was here
/usr/include/tirpc/rpc/rpc.h:84:12: warning: redundant redeclaration of 'bindresvport' [-Wredundant-decls] /usr/include/netinet/in.h:440:12: note: previous declaration of 'bindresvport' was here
Hmm, those smell like a bug in either glibc or tirpc. Only one of them should provide those decls.
--- configure.ac | 6 +++--- daemon/Makefile.am | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac index dcec371..db1c0e6 100644 --- a/configure.ac +++ b/configure.ac @@ -366,16 +366,16 @@ if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then dnl Where are the XDR functions? dnl If portablexdr is installed, prefer that. dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW), -lnsl (Solaris) - dnl or none (most Unix) + dnl -ltirpc (glibc 2.13.90 or newer) or none (most Unix) AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[ - AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl],[], + AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl tirpc],[], [AC_MSG_ERROR([Cannot find a XDR library])]) ])
dnl check for cygwin's variation in xdr function names AC_CHECK_FUNCS([xdr_u_int64_t],[],[],[#include <rpc/xdr.h>])
- dnl Cygwin requires -I/usr/include/tirpc for <rpc/rpc.h> + dnl Cygwin/recent glibc requires -I/usr/include/tirpc for <rpc/rpc.h> old_CFLAGS=$CFLAGS AC_CACHE_CHECK([where to find <rpc/rpc.h>], [lv_cv_xdr_cflags], [ for add_CFLAGS in '' '-I/usr/include/tirpc' 'missing'; do diff --git a/daemon/Makefile.am b/daemon/Makefile.am index af71188..ef1804b 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -80,7 +80,7 @@ libvirtd_CFLAGS = \ -I$(top_srcdir)/src/conf \ -I$(top_srcdir)/src/remote \ $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \ - $(POLKIT_CFLAGS) \ + $(XDR_CFLAGS) $(POLKIT_CFLAGS) \ $(WARN_CFLAGS) \ $(COVERAGE_CFLAGS) \ -DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
ACK, but someone should file a BZ about the duplicated definitions to get them fixed, because we need to be able to build with -Werror enabled 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 05/10/2011 10:13 AM, Daniel P. Berrange wrote:
ACK, but someone should file a BZ about the duplicated definitions to get them fixed, because we need to be able to build with -Werror enabled
Cygwin is facing the same problem with duplicate definitions - solve it for one platform, and you'll be solving it for both. My bets are on the tirpc headers not properly guarding definitions. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Tue, May 10, 2011 at 10:22:47AM -0600, Eric Blake wrote:
On 05/10/2011 10:13 AM, Daniel P. Berrange wrote:
ACK, but someone should file a BZ about the duplicated definitions to get them fixed, because we need to be able to build with -Werror enabled
Cygwin is facing the same problem with duplicate definitions - solve it for one platform, and you'll be solving it for both. My bets are on the tirpc headers not properly guarding definitions.
Any idea where to report tirpc bugs? Should I just file that against the fedora package and leave the maintainer handle it? Christophe

On Wed, May 11, 2011 at 09:40:01AM +0200, Christophe Fergeau wrote:
Any idea where to report tirpc bugs? Should I just file that against the fedora package and leave the maintainer handle it?
Never mind, I found upstream bugtracker and filed https://sourceforge.net/tracker/?func=detail&aid=3300354&group_id=183075&atid=903784 Christophe

On 05/10/2011 10:13 AM, Daniel P. Berrange wrote:
On Tue, May 10, 2011 at 05:42:06PM +0200, Christophe Fergeau wrote:
glibc 2.13.90 has obsoleted its rpc implementation in favour of the one provided by the TI-RPC library:
* The RPC implementation in libc is obsoleted. Old programs keep working but new programs cannot be linked with the routines in libc anymore. Programs in need of RPC functionality must be linked against TI-RPC. The TI-RPC implemtation is IPv6 enabled and there are other benefits.
ACK, but someone should file a BZ about the duplicated definitions to get them fixed, because we need to be able to build with -Werror enabled
I've gone ahead and applied this patch; libvirt's fix is independent of whether tirpc headers get fixed in the near future. (Actually, depending on how long things take on the tirpc, I may still come up with a hack that silences the tirpc warnings as a separate libvirt patch). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (3)
-
Christophe Fergeau
-
Daniel P. Berrange
-
Eric Blake