Richard W.M. Jones
2017-Mar-07 12:56 UTC
[Libguestfs] [PATCH v2] lib: Prefer tirpc for XDR, and rationalise how we search for alternatives.
v1 -> v2: - No functional changes to the patch, just fixes a few bugs. Rich.
Richard W.M. Jones
2017-Mar-07 12:56 UTC
[Libguestfs] [PATCH v2] lib: Prefer tirpc for XDR, and rationalise how we search for alternatives.
glibc in Fedora is currently configured with `--enable-obsolete-rpc', so I guess we can see which way the wind is blowing. (1) This changes our configure script to prefer libtirpc if it is available. If libtirpc is _not_ available then: (a) Headers must be located in <rpc/xdr.h>, or the user must supply the right CFLAGS. (b) XDR functions must be located in one of -lportablexdr, -lrpc, -lxdr, -lnsl or no library at all (ie. -lc), and the user must set LDFLAGS if needed. (2) We no longer add these paths automatically to $(CFLAGS)/$(LIBS). Any part of libguestfs which needs <rpc/*.h> or the xdr_* functions must use $(RPC_CFLAGS)/$(RPC_LIBS) explicitly. (3) Previously Mac OS X had a workaround for the broken 64 bit support in the supplied rpcgen. This workaround "activates" all the time if you use tirpc, so breaking Linux after the above changes. tirpc is supported on OS X, so I think it's just better to use that rather than the broken rpcgen. For that reason I removed the workaround completely. Thanks: Roy Keene --- common/protocol/Makefile.am | 12 ++---------- daemon/Makefile.am | 4 +++- docs/guestfs-building.pod | 13 +++++++++++-- fish/Makefile.am | 14 ++++---------- generator/XDR.ml | 15 --------------- lib/Makefile.am | 4 +++- m4/guestfs_libraries.m4 | 33 +++++++++++++++++++-------------- 7 files changed, 42 insertions(+), 53 deletions(-) diff --git a/common/protocol/Makefile.am b/common/protocol/Makefile.am index c426f26..cfac2d8 100644 --- a/common/protocol/Makefile.am +++ b/common/protocol/Makefile.am @@ -37,24 +37,16 @@ libprotocol_la_CFLAGS = \ -Wall -Wno-unused -fno-strict-aliasing $(GCC_VISIBILITY_HIDDEN) if HAVE_RPCGEN -RPCGEN_DEFS -if HAVE_XDR_U_INT64_T -RPCGEN_DEFS += -DHAVE_XDR_U_INT64_T=1 -else -if HAVE_XDR_UINT64_T -RPCGEN_DEFS += -DHAVE_XDR_UINT64_T=1 -endif -endif guestfs_protocol.c: guestfs_protocol.x rm -f $@-t $@-t2 - $(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $< + $(RPCGEN) -c -o $@-t $< $(SED) 's,\.\./\(\.\./\)*lib,.,' < $@-t > $@-t2 rm $@-t mv $@-t2 $@ guestfs_protocol.h: guestfs_protocol.x rm -f $@-t - $(RPCGEN) $(RPCGEN_DEFS) -h -o $@-t $< + $(RPCGEN) -h -o $@-t $< mv $@-t $@ endif diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 5c4ae8e..e3ad053 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -186,7 +186,8 @@ guestfsd_LDADD = \ $(LIBINTL) \ $(SERVENT_LIB) \ $(PCRE_LIBS) \ - $(TSK_LIBS) + $(TSK_LIBS) \ + $(RPC_LIBS) guestfsd_CPPFLAGS = \ -I$(top_srcdir)/gnulib/lib \ @@ -199,6 +200,7 @@ guestfsd_CPPFLAGS = \ -I$(top_builddir)/common/protocol guestfsd_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ + $(RPC_CFLAGS) \ $(AUGEAS_CFLAGS) \ $(HIVEX_CFLAGS) \ $(SD_JOURNAL_CFLAGS) \ diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod index 53a4d94..11ffe5f 100644 --- a/docs/guestfs-building.pod +++ b/docs/guestfs-building.pod @@ -87,8 +87,17 @@ below. =item glibc -I<Required>. We use various glibc-isms, and glibc also provides XDR -libraries and the C<rpcgen> tool. +I<Required>. We use the custom printf formatters extension of +glibc (see L<guestfs-hacking(1)/DAEMON CUSTOM PRINTF FORMATTERS>). + +=item XDR (tirpc, glibc or other) + +I<Required>. We use the XDR implementation from +C<E<lt>rpc/xdr.hE<gt>>, which may come from glibc, tirpc or another +library. + +The C<rpcgen> tool is optional, except if you want to compile from git +and/or patch libguestfs with new APIs. =item Gcc or Clang diff --git a/fish/Makefile.am b/fish/Makefile.am index 44c6ccd..9c07761 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -133,6 +133,7 @@ guestfish_CPPFLAGS = \ guestfish_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ + $(RPC_CFLAGS) \ $(LIBCONFIG_CFLAGS) \ $(LIBXML2_CFLAGS) @@ -147,6 +148,7 @@ guestfish_LDADD = \ $(LIBREADLINE) \ $(LIBTINFO_LIBS) \ $(LTLIBINTL) \ + $(RPC_LIBS) \ -lm # Make guestfish use the convenience libraries. @@ -154,25 +156,17 @@ noinst_LTLIBRARIES = libcmds.la librc_protocol.la guestfish_LDADD += libcmds.la librc_protocol.la ../gnulib/lib/libgnu.la if HAVE_RPCGEN -RPCGEN_DEFS -if HAVE_XDR_U_INT64_T -RPCGEN_DEFS += -DHAVE_XDR_U_INT64_T=1 -else -if HAVE_XDR_UINT64_T -RPCGEN_DEFS += -DHAVE_XDR_UINT64_T=1 -endif -endif rc_protocol.c: rc_protocol.x rm -f $@-t $@-t2 - $(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $< + $(RPCGEN) -c -o $@-t $< $(SED) 's,\.\./\(\.\./\)*fish,.,' < $@-t > $@-t2 rm $@-t mv $@-t2 $@ rc_protocol.h: rc_protocol.x rm -f $@-t - $(RPCGEN) $(RPCGEN_DEFS) -h -o $@-t $< + $(RPCGEN) -h -o $@-t $< mv $@-t $@ endif diff --git a/generator/XDR.ml b/generator/XDR.ml index 575be46..634a4f3 100644 --- a/generator/XDR.ml +++ b/generator/XDR.ml @@ -51,21 +51,6 @@ let generate_xdr () pr "%%#include <config.h>\n"; pr "\n"; - pr "/* This has to be defined to get around a limitation in Mac OS X's rpcgen. */\n"; - pr "#if HAVE_XDR_U_INT64_T\n"; - pr "#define uint64_t u_int64_t\n"; - pr "%%#if HAVE_XDR_UINT64_T\n"; - pr "%%#define xdr_u_int64_t xdr_uint64_t\n"; - pr "%%#define u_int64_t uint64_t\n"; - pr "%%#endif\n"; - pr "#else\n"; - pr "%%#if HAVE_XDR_U_INT64_T\n"; - pr "%%#define xdr_uint64_t xdr_u_int64_t\n"; - pr "%%#define uint64_t u_int64_t\n"; - pr "%%#endif\n"; - pr "#endif\n"; - pr "\n"; - pr "/* This has to be defined to get around a limitation in Sun's rpcgen. */\n"; pr "typedef string guestfs_str<>;\n"; pr "\n"; diff --git a/lib/Makefile.am b/lib/Makefile.am index 774274b..063706f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -141,6 +141,7 @@ libguestfs_la_CPPFLAGS = \ libguestfs_la_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ + $(RPC_CFLAGS) \ $(GCC_VISIBILITY_HIDDEN) \ $(PCRE_CFLAGS) \ $(LIBVIRT_CFLAGS) \ @@ -164,7 +165,8 @@ libguestfs_la_LIBADD = \ $(LTLIBINTL) \ $(LTLIBTHREAD) \ $(LTLIBICONV) \ - $(SERVENT_LIB) + $(SERVENT_LIB) \ + $(RPC_LIBS) # Force libtool to name the library 'libguestfs.so.0.$(MAX_PROC_NR).0'. # Include the version script to limit which symbols are exported. diff --git a/m4/guestfs_libraries.m4 b/m4/guestfs_libraries.m4 index c265b29..60f89d4 100644 --- a/m4/guestfs_libraries.m4 +++ b/m4/guestfs_libraries.m4 @@ -171,22 +171,27 @@ AC_CHECK_HEADERS([dlfcn.h],[have_dlfcn=yes],[have_dlfcn=no]) AM_CONDITIONAL([HAVE_LIBDL], [test "x$have_libdl" = "xyes" && test "x$have_dlfcn" = "xyes"]) -dnl Check for rpcgen and XDR library. rpcgen is optional. +dnl Check for an XDR library (required) and rpcgen binary (optional). +PKG_CHECK_MODULES([RPC], [libtirpc], [], [ + # If we don't have libtirpc, then we must have <rpc/xdr.h> and + # some library to link to in libdir. + RPC_CFLAGS="" + AC_CHECK_HEADER([rpc/xdr.h],[],[ + AC_MSG_ERROR([XDR header files are required]) + ]) + + old_LIBS="$LIBS" + LIBS="" + AC_SEARCH_LIBS([xdrmem_create],[portablexdr rpc xdr nsl]) + RPC_LIBS="$LIBS" + LIBS="$old_LIBS" + + AC_SUBST([RPC_CFLAGS]) + AC_SUBST([RPC_LIBS]) +]) + AC_CHECK_PROG([RPCGEN],[rpcgen],[rpcgen],[no]) AM_CONDITIONAL([HAVE_RPCGEN],[test "x$RPCGEN" != "xno"]) -AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[ - AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl]) -]) -AC_SEARCH_LIBS([xdr_u_int64_t],[portablexdr rpc xdr nsl],[ - AC_DEFINE([HAVE_XDR_U_INT64_T],[1],[Define to 1 if xdr_u_int64_t() exists.]) -]) -AC_SEARCH_LIBS([xdr_uint64_t],[portablexdr rpc xdr nsl],[ - AC_DEFINE([HAVE_XDR_UINT64_T],[1],[Define to 1 if xdr_uint64_t() exists.]) -]) -AM_CONDITIONAL([HAVE_XDR_U_INT64_T], - [test "x$ac_cv_search_xdr_u_int64_t" != "xno"]) -AM_CONDITIONAL([HAVE_XDR_UINT64_T], - [test "x$ac_cv_search_xdr_uint64_t" != "xno"]) dnl Check for libselinux (optional). AC_CHECK_HEADERS([selinux/selinux.h]) -- 2.9.3
Maybe Matching Threads
- [PATCH] lib: Prefer tirpc for XDR, and rationlise how we search for alternatives.
- [PATCH 01/12] configure: Add -nographic command line option to qemu.
- [PATCH] Mac OS X: Fixed combination of running autogen.sh on Linux and building on Mac OS X
- [PATCH 1/2] perl: Fix install target for separated builds.
- [PATCH 00/16] Refactoring of configure.ac and guestfs.pod