diff --git a/rapid/plugin/group_replication/libmysqlgcs/CMakeLists.txt b/rapid/plugin/group_replication/libmysqlgcs/CMakeLists.txt
index e9f51ca8fc9..42a9575e008 100644
--- a/rapid/plugin/group_replication/libmysqlgcs/CMakeLists.txt
+++ b/rapid/plugin/group_replication/libmysqlgcs/CMakeLists.txt
@@ -139,8 +139,13 @@ IF(MSVC)
# This disables signed/unsigned mismatch warnings
# Compiler warning C4018.
- ADD_COMPILE_FLAGS(${XCOM_SUN_RPCS} ${XCOM_RPCGEN_SOURCES}
- COMPILE_FLAGS "/wd4018")
+ IF(WIN32_CLANG)
+ ADD_COMPILE_FLAGS(${XCOM_SUN_RPCS} ${XCOM_RPCGEN_SOURCES}
+ COMPILE_FLAGS "-Wno-sign-compare")
+ ELSE()
+ ADD_COMPILE_FLAGS(${XCOM_SUN_RPCS} ${XCOM_RPCGEN_SOURCES}
+ COMPILE_FLAGS "/wd4018")
+ ENDIF()
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
ADD_COMPILE_FLAGS(${XCOM_SOURCES} ${XCOM_SUN_RPCS} ${XCOM_RPCGEN_SOURCES}
@@ -153,5 +158,9 @@ ADD_COMPILE_FLAGS(${GCS_SOURCES} COMPILE_FLAGS "-DMYSQL_DYNAMIC_PLUGIN")
ADD_CONVENIENCE_LIBRARY(${GCS_LIBRARY} ${XCOM_SOURCES} ${GCS_SOURCES})
+IF(TIRPC_LIBRARY)
+ TARGET_LINK_LIBRARIES(${GCS_LIBRARY} ${TIRPC_LIBRARY})
+ENDIF()
+
# convenience target
ADD_CUSTOM_TARGET(lib${GCS_LIBRARY} DEPENDS ${GCS_LIBRARY})
diff --git a/rapid/plugin/group_replication/libmysqlgcs/configure.cmake b/rapid/plugin/group_replication/libmysqlgcs/configure.cmake
index b4519371579..5653d9a3d16 100644
--- a/rapid/plugin/group_replication/libmysqlgcs/configure.cmake
+++ b/rapid/plugin/group_replication/libmysqlgcs/configure.cmake
@@ -54,8 +54,17 @@ IF (WIN32)
ENDIF()
IF (NOT WIN32)
+ # First look for tirpc, then the old Sun RPC
+ FIND_PATH(RPC_INCLUDE_DIR
+ NAMES rpc/rpc.h
+ HINTS /usr/include/tirpc
+ NO_DEFAULT_PATH
+ )
+ FIND_PATH(RPC_INCLUDE_DIR NAMES rpc/rpc.h)
+
SET (CMAKE_REQUIRED_FLAGS_BACKUP ${CMAKE_REQUIRED_FLAGS})
SET (CMAKE_REQUIRED_FLAGS "-Wno-error")
+ SET (CMAKE_REQUIRED_INCLUDES ${RPC_INCLUDE_DIR})
ENDIF()
#
diff --git a/rapid/plugin/group_replication/libmysqlgcs/rpcgen.cmake b/rapid/plugin/group_replication/libmysqlgcs/rpcgen.cmake
index e26ae09ecb9..9b14b2e77e4 100644
--- a/rapid/plugin/group_replication/libmysqlgcs/rpcgen.cmake
+++ b/rapid/plugin/group_replication/libmysqlgcs/rpcgen.cmake
@@ -94,6 +94,23 @@ FOREACH(X xcom_vp)
${XCOM_BASEDIR}/xcom_proto_enum.h
${XCOM_BASEDIR}/xcom_limits.h)
ELSE()
+ FIND_PROGRAM(RPCGEN_EXECUTABLE rpcgen DOC "path to the rpcgen executable")
+ MARK_AS_ADVANCED(RPCGEN_EXECUTABLE)
+ IF(NOT RPCGEN_EXECUTABLE)
+ MESSAGE(FATAL_ERROR "Could not find rpcgen")
+ ENDIF()
+
+ IF(NOT RPC_INCLUDE_DIR)
+ MESSAGE(FATAL_ERROR
+ "Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc")
+ ENDIF()
+ MESSAGE(STATUS "RPC_INCLUDE_DIR ${RPC_INCLUDE_DIR}")
+ IF(RPC_INCLUDE_DIR STREQUAL "/usr/include/tirpc")
+ INCLUDE_DIRECTORIES(SYSTEM /usr/include/tirpc)
+ ADD_DEFINITIONS(-DHAVE_TIRPC)
+ SET(TIRPC_LIBRARY tirpc)
+ ENDIF()
+
# on unix systems try to generate them if needed
ADD_CUSTOM_COMMAND(OUTPUT ${x_gen_h} ${x_gen_c} ${x_tmp_plat_h}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
@@ -110,10 +127,10 @@ FOREACH(X xcom_vp)
# generate the sources
COMMAND ${CMAKE_COMMAND} -E remove -f ${x_gen_h}
- COMMAND rpcgen -C -h -o
+ COMMAND ${RPCGEN_EXECUTABLE} -C -h -o
${x_gen_h} ${x_tmp_x_canonical_name}
COMMAND ${CMAKE_COMMAND} -E remove -f ${x_gen_c}
- COMMAND rpcgen -C -c -o
+ COMMAND ${RPCGEN_EXECUTABLE} -C -c -o
${x_gen_c} ${x_tmp_x_canonical_name}
WORKING_DIRECTORY ${gen_xdr_dir}
DEPENDS
diff --git a/rapid/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_transport.c b/rapid/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_transport.c
index ad892aa56ae..bc04b597d49 100644
--- a/rapid/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_transport.c
+++ b/rapid/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_transport.c
@@ -342,13 +345,9 @@ static void dump_header(char *buf) {
void dbg_app_data(app_data_ptr a);
-#ifdef HAVE___CONST
-#define const __const
-#else
#ifdef OLD_XDR
#define const
#endif
-#endif
/* ARGSUSED */
static bool_t x_putlong(XDR *xdrs,
@@ -380,9 +379,8 @@ static bool_t x_putbytes(XDR *xdrs, const char *bp MY_ATTRIBUTE((unused)),
#endif
static u_int
-#if defined(__APPLE__) || defined(__FreeBSD__) || \
- defined(X_GETPOSTN_NOT_USE_CONST)
-x_getpostn(__const XDR *xdrs)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(HAVE_TIRPC)
+x_getpostn(XDR *xdrs)
#else
x_getpostn(const XDR *xdrs)
#endif