diff --git a/NEWS b/NEWS index 2c93494a4..aaea7af4a 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ application code. ** `guile-config link' now prints `-L$libdir' before `-lguile' ** Fix build issue on Tru64 and ia64-hp-hpux11.23 (`SCM_UNPACK' macro) +** Fix build issue on mips, mipsel, powerpc and ia64 (stack direction) Changes in 1.8.5 (since 1.8.4) diff --git a/configure.in b/configure.in index 6e2b6d823..d5d226415 100644 --- a/configure.in +++ b/configure.in @@ -1118,15 +1118,44 @@ GUILE_STRUCT_UTIMBUF # # Which way does the stack grow? # +# Following code comes from Autoconf 2.61's internal _AC_LIBOBJ_ALLOCA +# macro (/usr/share/autoconf/autoconf/functions.m4). Gnulib has +# very similar code, so in future we could look at using that. +# +# An important detail is that the code involves find_stack_direction +# calling _itself_ - which means that find_stack_direction (or at +# least the second find_stack_direction() call) cannot be inlined. +# If the code could be inlined, that might cause the test to give +# an incorrect answer. #-------------------------------------------------------------------- SCM_I_GSC_STACK_GROWS_UP=0 -AC_RUN_IFELSE([AC_LANG_SOURCE([[aux (l) unsigned long l; - { int x; exit (l >= ((unsigned long)&x)); } - main () { int q; aux((unsigned long)&q); }]])], - [SCM_I_GSC_STACK_GROWS_UP=1], - [], - [AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h)]) +AC_CACHE_CHECK([stack direction], + [SCM_I_GSC_STACK_GROWS_UP], +[AC_RUN_IFELSE([AC_LANG_SOURCE( +[AC_INCLUDES_DEFAULT +int +find_stack_direction () +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; +} + +int +main () +{ + return find_stack_direction () < 0; +}])], + [SCM_I_GSC_STACK_GROWS_UP=1], + [], + [AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h)])]) AC_CHECK_SIZEOF(float) if test "$ac_cv_sizeof_float" -le "$ac_cv_sizeof_long"; then