gcc-3.0/gcc/aclocal.m4 AC_FUNC_MMAP_ANYWHERE braindamage

David Gordon Hogan dhog@plan9.bell-labs.com
Tue Jul 3 13:00:00 GMT 2001


In the definition of AC_FUNC_MMAP_ANYWHERE, in gcc-3.0/gcc/aclocal.m4,
we see:

AC_CACHE_CHECK(for working mmap from /dev/zero,
  ac_cv_func_mmap_dev_zero,
[AC_TRY_RUN(
 [#include "ct-mmap.inc"],
 ac_cv_func_mmap_dev_zero=yes,
 [if test $? -lt 4
 then ac_cv_func_mmap_dev_zero=no
 else ac_cv_func_mmap_dev_zero=buggy
 fi],
 # If this is not cygwin, and /dev/zero is a character device, it's probably
 # safe to assume it works.
 [case "$host_os" in
   cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
   * ) if test -c /dev/zero
       then ac_cv_func_mmap_dev_zero=yes
       else ac_cv_func_mmap_dev_zero=no
       fi ;;
  esac])
])
if test $ac_cv_func_mmap_dev_zero = yes; then
  AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
	    [Define if mmap can get us zeroed pages from /dev/zero.])
fi


So if we're cross compiling, and the BUILD machine has /dev/zero,
we assume that the TARGET machine has both mmap() and /dev/zero
(and that they work together)!

This is just horribly wrong.  Where is the test for whether mmap() exists at
all?  It just so happens that I am cross compiling to an architecture which
doesn't have it.  In any case, the test for /dev/zero on the build host is quite
ludicrous.  The cross compiling case should be just "ac_cv_func_mmap_dev_zero=no".



More information about the Gcc-bugs mailing list