Skip to content

Commit 0c3c1d1

Browse files
author
kalibera
committed
Add configure check for whether internal XDR is usable (it is not with GCC
sanitizers on Linux, but TI-RPC can be used). git-svn-id: https://svn.r-project.org/R/trunk@87450 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 261167d commit 0c3c1d1

File tree

2 files changed

+173
-0
lines changed

2 files changed

+173
-0
lines changed

configure

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52167,6 +52167,90 @@ else
5216752167
fi
5216852168

5216952169

52170+
if test "${r_xdr}" = no ; then
52171+
## check internal xdr can be used
52172+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether internal XDR can be used" >&5
52173+
printf %s "checking whether internal XDR can be used... " >&6; }
52174+
if test ${r_cv_internal_xdr_usable+y}
52175+
then :
52176+
printf %s "(cached) " >&6
52177+
else case e in #(
52178+
e) if test "${cross_compiling}" = yes; then
52179+
r_cv_internal_xdr_usable=yes
52180+
else
52181+
cat >conftestx.c <<EOF
52182+
#include <stdint.h>
52183+
#include <stdlib.h>
52184+
#include <rpc/types.h>
52185+
#include <rpc/xdr.h>
52186+
52187+
void xdrmem_create(register XDR *xdrs, caddr_t addr, u_int size,
52188+
enum xdr_op op) {
52189+
(void)xdrs; (void)addr; (void)size; (void)op;
52190+
exit(0); /* SUCCESS, internal implementation can be called */
52191+
}
52192+
EOF
52193+
cat >conftest.c <<EOF
52194+
#include <stdint.h>
52195+
#include <stdlib.h>
52196+
#include <rpc/types.h>
52197+
#include <rpc/xdr.h>
52198+
52199+
extern void xdrmem_create(register XDR *xdrs, caddr_t addr, u_int size,
52200+
enum xdr_op op);
52201+
52202+
int main(void) {
52203+
XDR xdrs;
52204+
char buf[4];
52205+
52206+
xdrmem_create(&xdrs, buf, sizeof(buf), XDR_ENCODE);
52207+
exit(1); /* FAILURE, internal implementation is not called */
52208+
}
52209+
EOF
52210+
r_save_CPPFLAGS="${CPPFLAGS}"
52211+
CPPFLAGS="${CPPFLAGS} -I${srcdir}/src/extra/xdr"
52212+
r_cv_internal_xdr_usable=no
52213+
if ${CC} ${CPPFLAGS} ${CFLAGS} -c conftestx.c \
52214+
1>&5 2>&5 && \
52215+
${CC} ${CPPFLAGS} ${CFLAGS} -c conftest.c
52216+
1>&5 2>&5 && \
52217+
${AR} ${ARFLAGS} conftestx.${libext} conftestx.${ac_objext} \
52218+
1>&5 2>&5 && \
52219+
${RANLIB} conftestx.${libext} \
52220+
1>&5 2>&5 && \
52221+
${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} ${MAIN_LDFLAGS} \
52222+
-o conftest${ac_exeext} conftest.${ac_objext} conftestx.${libext} \
52223+
1>&5 2>&5 ; then
52224+
52225+
./conftest${ac_exeext} 2>&5
52226+
if test ${?} = 0; then
52227+
r_cv_internal_xdr_usable=yes
52228+
fi
52229+
fi
52230+
rm -f conftestxi.c conftestx.c
52231+
CPPFLAGS="${r_save_CPPFLAGS}"
52232+
fi # not cross-compiling
52233+
;;
52234+
esac
52235+
fi
52236+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $r_cv_internal_xdr_usable" >&5
52237+
printf "%s\n" "$r_cv_internal_xdr_usable" >&6; }
52238+
if test "${r_cv_internal_xdr_usable}" = no ; then
52239+
case "${host_os}" in
52240+
linux*)
52241+
as_fn_error $? "Internal XDR cannot be used. Maybe install a development version of TI-RPC?" "$LINENO" 5
52242+
;;
52243+
*)
52244+
## unlikely
52245+
as_fn_error $? "Internal XDR cannot be used." "$LINENO" 5
52246+
;;
52247+
esac
52248+
elif test "${cross_compiling}" = yes; then
52249+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Assuming internal XDR works (cross-compiling)." >&5
52250+
printf "%s\n" "$as_me: WARNING: Assuming internal XDR works (cross-compiling)." >&2;}
52251+
fi
52252+
52253+
fi
5217052254

5217152255

5217252256
## zlib headers and libraries.

m4/R.m4

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,6 +3318,91 @@ fi
33183318
AC_SUBST(LAPACK_LIBS)
33193319
])# R_LAPACK_SYSTEM_LIB
33203320

3321+
## R_INTERNAL_XDR_USABLE
3322+
## ---------------------
3323+
## Check whether the internal xdr implementation can be used. It cannot be
3324+
## with GCC sanitizers (2024), which intercept also xdr calls. Linking turns
3325+
## the symbols to dynamically linked and succeeds, then the program crashes
3326+
## when invoking an xdr call.
3327+
##
3328+
## R_INTERNAL_XDR_USABLE()
3329+
## -----------------------
3330+
AC_DEFUN([R_INTERNAL_XDR_USABLE],
3331+
[AC_REQUIRE([LT_INIT])dnl
3332+
AC_REQUIRE([R_PROG_AR])dnl
3333+
AC_CACHE_CHECK([whether internal XDR can be used],
3334+
[r_cv_internal_xdr_usable],
3335+
[if test "${cross_compiling}" = yes; then
3336+
r_cv_internal_xdr_usable=yes
3337+
else
3338+
cat >conftestx.c <<EOF
3339+
#include <stdint.h>
3340+
#include <stdlib.h>
3341+
#include <rpc/types.h>
3342+
#include <rpc/xdr.h>
3343+
3344+
void xdrmem_create(register XDR *xdrs, caddr_t addr, u_int size,
3345+
enum xdr_op op) {
3346+
(void)xdrs; (void)addr; (void)size; (void)op;
3347+
exit(0); /* SUCCESS, internal implementation can be called */
3348+
}
3349+
EOF
3350+
cat >conftest.c <<EOF
3351+
#include <stdint.h>
3352+
#include <stdlib.h>
3353+
#include <rpc/types.h>
3354+
#include <rpc/xdr.h>
3355+
3356+
extern void xdrmem_create(register XDR *xdrs, caddr_t addr, u_int size,
3357+
enum xdr_op op);
3358+
3359+
int main(void) {
3360+
XDR xdrs;
3361+
char buf[[4]];
3362+
3363+
xdrmem_create(&xdrs, buf, sizeof(buf), XDR_ENCODE);
3364+
exit(1); /* FAILURE, internal implementation is not called */
3365+
}
3366+
EOF
3367+
r_save_CPPFLAGS="${CPPFLAGS}"
3368+
CPPFLAGS="${CPPFLAGS} -I${srcdir}/src/extra/xdr"
3369+
r_cv_internal_xdr_usable=no
3370+
if ${CC} ${CPPFLAGS} ${CFLAGS} -c conftestx.c \
3371+
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && \
3372+
${CC} ${CPPFLAGS} ${CFLAGS} -c conftest.c
3373+
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && \
3374+
${AR} ${ARFLAGS} conftestx.${libext} conftestx.${ac_objext} \
3375+
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && \
3376+
${RANLIB} conftestx.${libext} \
3377+
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && \
3378+
${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} ${MAIN_LDFLAGS} \
3379+
-o conftest${ac_exeext} conftest.${ac_objext} conftestx.${libext} \
3380+
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
3381+
3382+
./conftest${ac_exeext} 2>&AS_MESSAGE_LOG_FD
3383+
if test ${?} = 0; then
3384+
r_cv_internal_xdr_usable=yes
3385+
fi
3386+
fi
3387+
rm -f conftestxi.c conftestx.c
3388+
CPPFLAGS="${r_save_CPPFLAGS}"
3389+
fi # not cross-compiling
3390+
])
3391+
if test "${r_cv_internal_xdr_usable}" = no ; then
3392+
case "${host_os}" in
3393+
linux*)
3394+
AC_MSG_ERROR([Internal XDR cannot be used. Maybe install a development version of TI-RPC?])
3395+
;;
3396+
*)
3397+
## unlikely
3398+
AC_MSG_ERROR([Internal XDR cannot be used.])
3399+
;;
3400+
esac
3401+
elif test "${cross_compiling}" = yes; then
3402+
AC_MSG_WARN([Assuming internal XDR works (cross-compiling).])
3403+
fi
3404+
])# R_INTERNAL_XDR_USABLE
3405+
33213406
## R_SEARCH_XDR_LIBS
33223407
## -----------------
33233408
## Linking a test program is not enough with address sanitizer, which on
@@ -3428,6 +3513,10 @@ AC_MSG_CHECKING([for XDR support])
34283513
AC_MSG_RESULT([${r_xdr}])
34293514
AM_CONDITIONAL(BUILD_XDR, [test "x${r_xdr}" = xno])
34303515
AC_SUBST(TIRPC_CPPFLAGS)
3516+
if test "${r_xdr}" = no ; then
3517+
## check internal xdr can be used
3518+
R_INTERNAL_XDR_USABLE()
3519+
fi
34313520
])# R_XDR
34323521

34333522
## R_ZLIB

0 commit comments

Comments
 (0)