[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] aclocal.m4: Fix BASH_FUNC_SBRK when cross-compiling for Free
From: |
Jessica Clarke |
Subject: |
[PATCH 2/3] aclocal.m4: Fix BASH_FUNC_SBRK when cross-compiling for FreeBSD/RISC-V |
Date: |
Sat, 27 Jun 2020 21:06:30 +0100 |
FreeBSD unconditionally provides a prototype for sbrk(2), but on recent
ports (AArch64 and RISC-V) it does not provide the deprecated symbol.
This means that, when cross-compiling, we currently only get to use
AC_CHECK_FUNCS_ONCE, and so believe sbrk(2) to be available. Instead,
use AC_TRY_LINK so we can detect this case when cross-compiling. Also,
only define HAVE_SBRK when our tests pass, since xmalloc.c checks
whether it's defined, not its value. This likely meant the case where
sbrk(2) was available but broken did not in fact do the right thing.
---
aclocal.m4 | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index c4a54f27..c785e197 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -4196,7 +4196,12 @@ AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET],
[$bash_cv_wexitstatus_offset], [Offset
AC_DEFUN([BASH_FUNC_SBRK],
[
- AC_CHECK_FUNCS_ONCE([sbrk])
+ AC_MSG_CHECKING([for sbrk])
+ AC_CACHE_VAL(ac_cv_func_sbrk,
+ [AC_TRY_LINK([#include <unistd.h>],
+ [ void *x = sbrk (4096); ],
+ ac_cv_func_sbrk=yes, ac_cv_func_sbrk=no)])
+ AC_MSG_RESULT($ac_cv_func_sbrk)
if test X$ac_cv_func_sbrk = Xyes; then
AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk],
[AC_TRY_RUN([
@@ -4219,8 +4224,8 @@ main(int c, char **v)
ac_cv_func_sbrk=no
fi
fi
- if test $ac_cv_func_sbrk = no; then
- AC_DEFINE(HAVE_SBRK, 0,
+ if test $ac_cv_func_sbrk = yes; then
+ AC_DEFINE(HAVE_SBRK, 1,
[Define if you have a working sbrk function.])
fi
])
--
2.20.1