Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16462

[PATCH 2/3] aclocal.m4: Fix BASH_FUNC_SBRK when cross-compiling for FreeBSD/RISC-V

From Jessica Clarke <jrtc27@jrtc27.com>
Newsgroups gnu.bash.bug
Subject [PATCH 2/3] aclocal.m4: Fix BASH_FUNC_SBRK when cross-compiling for FreeBSD/RISC-V
Date 2020-06-27 21:06 +0100
Message-ID <mailman.529.1593295309.2574.bug-bash@gnu.org> (permalink)
References <20200627200631.38456-1-jrtc27@jrtc27.com> <20200627200631.38456-3-jrtc27@jrtc27.com>

Show all headers | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

[PATCH 2/3] aclocal.m4: Fix BASH_FUNC_SBRK when cross-compiling for FreeBSD/RISC-V Jessica Clarke <jrtc27@jrtc27.com> - 2020-06-27 21:06 +0100

csiph-web