Originally from #ghc on freenode, 2018-12-16:
Most of the checks seem to actually be no-ops for cross-compilation.
E.g. checking for working strnlen
is just hardcoded to "yes" on all targets but AIX (in similar other cases, it just prints "guessing yes").
For checking size of int *
, it does a binary search as you say, and NOT invoke the compiled programs.
It does it by generating a static array with known size, like arr[1 - 2 * (sizeof(int*) <= BINARY_SEARCH_VAR)], so that the static size is either [1] or [-1]. C compilers happen to complain about arrays of negative static size, so that's how it figures that out.
See ac_fn_c_compute_int()
.
To see this, I use for compilation of GNU hello, the following added to configure.ac
:
AC_CHECK_SIZEOF([int *])
and configure with:
CC=arm-linux-gnueabihf-gcc ./configure --build i686-pc-linux-gnu --host arm-linux-gnueabihf
and then look at config.log
around checking size of int *
, which shows some of the iterations of the binary search below.
Required packages for this ARM cross-compilation are on Ubuntu 16.04:
sudo apt-get install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev