Project:Toolchain/Glibc 2.26 porting notes/RPC implementation

From Gentoo Wiki
Jump to:navigation Jump to:search

This page provides a guideline and example code snippets to port packages away from SunRPC - necessary for everything listed in tracker bug #381391. The snippets are taken from the first package on the tracker that I encountered, net-analyzer/dsniff, from which I prepared a reference implementation in my overlay.

SunRPC is optional in glibc-2.25 and earlier (use-flag rpc) and removed in glibc-2.26 and later. Note that glibc-2.26 will go stable soon.


Two strategies are possible:

  • either switch your package already now to hard-require libtirpc,
  • or make the RPC implementation controllable via a use-flag libtirpc, as discussed in detail below.

For applications (leaf packages), a hard switch may make more sense. For libraries a controllable implementation is more useful (since things may explode when different object files linked into the same application use different implementations).

Use flag(s)

If RPC support is optional, please use a use-flag rpc to enable / disable it entirely.

For switching between implementations, please use libtirpc:

  • if unset, use glibc's SunRPC,
  • if set, pull in net-lib/libtirpc.

It makes sense to default this flag to "on", for two reasons:

  • libtirpc is the more modern and likely faster implementation
  • libtirpc works independent of the installed glibc, while SunRPC will go away with glibc-2.26.


!libtirpc? ( elibc_glibc? ( sys-libs/glibc[rpc(-)] ) )
libtirpc? ( net-libs/libtirpc )

Depending on the package you may need net-libs/rpcsvc-proto or not. It provides the rpcgen binary and some header files. If you need those, you can safely depend on net-libs/rpcsvc-proto unconditionally.

Patching the build system

Here's an example snippet for providing switchable RPC implementation:

      [AS_HELP_STRING([--with-libtirpc], [Use libtirpc as RPC implementation (instead of sunrpc)])])

AS_IF([test "x$with_libtirpc" = xyes], 
                         [RPC_CFLAGS=$TIRPC_CFLAGS; RPC_LIBS=$TIRPC_LIBS;],
                        [AC_MSG_ERROR([libtirpc requested, but library not found.])]
                      [RPC_CFLAGS=""; RPC_LIBS="";],
                      [AC_MSG_ERROR([sunrpc requested, but headers are not present.])]


And here is a corresponding example snippet:

LIBS   = @LIBS@ -L$(srcdir) @RPC_LIBS@

(When automake is used, you may want to patch instead.)


econf $(use_with libtirpc)

Nuff said.

See also