APR's configure script uses AC_TRY_RUN to detect whether the return type
of strerror_r is int. When cross-compiling this defaults to no.
This commit adds an AC_CACHE_CHECK so users who cross-compile APR may
influence the outcome with a configure variable.
Without this commit, while cross-compiling against a libc where
strerror_r returns int, a warning occurs:
misc/unix/errorcodes.c: In function 'native_strerror':
misc/unix/errorcodes.c:358:9: warning: assignment makes pointer from integer
without a cast [-Wint-conversion]
msg = strerror_r(statcode, buf, bufsize);
^
Fixes: https://bz.apache.org/bugzilla/show_bug.cgi?id=60539
Index: build/apr_common.m4
===================================================================
--- build/apr_common.m4 (revision 1873663)
+++ build/apr_common.m4 (working copy)
@@ -489,8 +489,9 @@
dnl
dnl
AC_DEFUN([APR_CHECK_STRERROR_R_RC], [
-AC_MSG_CHECKING(for type of return code from strerror_r)
-AC_TRY_RUN([
+AC_CACHE_CHECK([whether return code from strerror_r has type int],
+[ac_cv_strerror_r_rc_int],
+[AC_TRY_RUN([
#include <errno.h>
#include <string.h>
#include <stdio.h>
@@ -506,14 +507,10 @@
}], [
ac_cv_strerror_r_rc_int=yes ], [
ac_cv_strerror_r_rc_int=no ], [
- ac_cv_strerror_r_rc_int=no ] )
+ ac_cv_strerror_r_rc_int=no ] ) ] )
if test "x$ac_cv_strerror_r_rc_int" = xyes; then
AC_DEFINE(STRERROR_R_RC_INT, 1, [Define if strerror returns int])
- msg="int"
-else
- msg="pointer"
fi
-AC_MSG_RESULT([$msg])
] )
dnl