Skip to content

Commit

Permalink
[R] configure backtrace and fopen64 (#11025)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastistician authored Nov 29, 2024
1 parent 325fe41 commit 7d8da41
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 17 deletions.
108 changes: 96 additions & 12 deletions R-package/configure
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ ac_header_cxx_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
BACKTRACE_LIB
DMLC_DEFS
ENDIAN_FLAG
OPENMP_LIB
OPENMP_CXXFLAGS
Expand Down Expand Up @@ -1504,6 +1505,68 @@ fi
} # ac_fn_cxx_try_link
# ac_fn_cxx_check_func LINENO FUNC VAR
# ------------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_cxx_check_func ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
printf %s "checking for $2... " >&6; }
if eval test \${$3+y}
then :
printf %s "(cached) " >&6
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $2 innocuous_$2
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $2 (); below. */
#include <limits.h>
#undef $2
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif
int
main (void)
{
return $2 ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"
then :
eval "$3=yes"
else $as_nop
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno

} # ac_fn_cxx_check_func

# ac_fn_cxx_try_run LINENO
# ------------------------
# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that
Expand Down Expand Up @@ -2192,11 +2255,10 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu


### Check whether backtrace() is part of libc or the external lib libexecinfo
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Backtrace lib" >&5
printf %s "checking Backtrace lib... " >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5
printf "%s\n" "" >&6; }
DMLC_DEFS=""

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking if/where backtrace is available" >&5
printf "%s\n" "$as_me: Checking if/where backtrace is available" >&6;}



Expand Down Expand Up @@ -2732,11 +2794,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
printf %s "checking for $CXX option to enable C++11 features... " >&6; }
if test ${ac_cv_prog_cxx_cxx11+y}
if test ${ac_cv_prog_cxx_11+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_cxx11=no
ac_cv_prog_cxx_11=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -2778,11 +2840,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
printf %s "checking for $CXX option to enable C++98 features... " >&6; }
if test ${ac_cv_prog_cxx_cxx98+y}
if test ${ac_cv_prog_cxx_98+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_cxx98=no
ac_cv_prog_cxx_98=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -2869,8 +2931,31 @@ else $as_nop
BACKTRACE_LIB=''
fi

if test -z "${BACKTRACE_LIB}"
then :
ac_fn_cxx_check_func "$LINENO" "backtrace" "ac_cv_func_backtrace"
if test "x$ac_cv_func_backtrace" = xyes
then :

else $as_nop
DMLC_DEFS="$DMLC_DEFS -DDMLC_LOG_STACK_TRACE=0"
fi

### Endian detection
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking whether fopen64 is available" >&5
printf "%s\n" "$as_me: Checking whether fopen64 is available" >&6;}
ac_fn_cxx_check_func "$LINENO" "fopen64" "ac_cv_func_fopen64"
if test "x$ac_cv_func_fopen64" = xyes
then :

else $as_nop
DMLC_DEFS="$DMLC_DEFS -DDMLC_USE_FOPEN64=0"
fi


{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Endian detection" >&5
printf "%s\n" "$as_me: Endian detection" >&6;}

ac_header= ac_cache=
for ac_item in $ac_header_cxx_list
Expand Down Expand Up @@ -2906,8 +2991,6 @@ then :

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking system endianness as USE_LITTLE_ENDIAN is unset" >&5
printf "%s\n" "$as_me: Checking system endianness as USE_LITTLE_ENDIAN is unset" >&6;}
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking system endianness" >&5
printf %s "checking system endianness... " >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
printf %s "checking whether byte ordering is bigendian... " >&6; }
if test ${ac_cv_c_bigendian+y}
Expand Down Expand Up @@ -3205,6 +3288,7 @@ fi




ac_config_files="$ac_config_files src/Makevars"

ac_config_headers="$ac_config_headers config.h"
Expand Down
16 changes: 11 additions & 5 deletions R-package/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS`
AC_LANG(C++)

### Check whether backtrace() is part of libc or the external lib libexecinfo
AC_MSG_CHECKING([Backtrace lib])
AC_MSG_RESULT([])
DMLC_DEFS=""

AC_MSG_NOTICE([Checking if/where backtrace is available])
AC_CHECK_LIB([execinfo], [backtrace], [BACKTRACE_LIB=-lexecinfo], [BACKTRACE_LIB=''])
AS_IF([test -z "${BACKTRACE_LIB}"],
dnl backtrace() might be unavailable (e.g., in musl libc)
[AC_CHECK_FUNC(backtrace, [], [DMLC_DEFS="$DMLC_DEFS -DDMLC_LOG_STACK_TRACE=0"])])

AC_MSG_NOTICE([Checking whether fopen64 is available])
AC_CHECK_FUNC(fopen64, [], [DMLC_DEFS="$DMLC_DEFS -DDMLC_USE_FOPEN64=0"])

### Endian detection
AC_MSG_NOTICE([Endian detection])
AC_ARG_VAR(USE_LITTLE_ENDIAN, "Whether to build with little endian (checks at compile time if unset)")
AS_IF([test -z "${USE_LITTLE_ENDIAN+x}"], [
AC_MSG_NOTICE([Checking system endianness as USE_LITTLE_ENDIAN is unset])
AC_MSG_CHECKING([system endianness])
AC_C_BIGENDIAN(
[AC_MSG_RESULT([using big endian])
ENDIAN_FLAG="-DDMLC_CMAKE_LITTLE_ENDIAN=0"],
Expand Down Expand Up @@ -82,6 +87,7 @@ fi
AC_SUBST(OPENMP_CXXFLAGS)
AC_SUBST(OPENMP_LIB)
AC_SUBST(ENDIAN_FLAG)
AC_SUBST(DMLC_DEFS)
AC_SUBST(BACKTRACE_LIB)
AC_CONFIG_FILES([src/Makevars])
AC_CONFIG_HEADERS([config.h])
Expand Down
1 change: 1 addition & 0 deletions R-package/src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ENABLE_STD_THREAD=1
CXX_STD = CXX17

XGB_RFLAGS = \
@DMLC_DEFS@ \
-DXGBOOST_STRICT_R_MODE=1 \
-DDMLC_LOG_BEFORE_THROW=0 \
-DDMLC_ENABLE_STD_THREAD=$(ENABLE_STD_THREAD) \
Expand Down

0 comments on commit 7d8da41

Please sign in to comment.