Subject: bug#51144: GNU grep 3.7 fails to build on FreeBSD

From: Paul Eggert <[email-masked]>
Date: Thu, 14 Oct 2021 10:34:55 -0700

On 10/14/21 7:02 AM, Alexey Dokuchaev wrote:

> All we do is
> use our pre-built templates for config.{guess,site,sub} and pass the
> --build=amd64-portbld-freebsd$(version) argument to configure scripts
> if they are generated by GNU autotools.

Surely this doesn't work if there's a configure.ac or m4/*.m4 file that 
does something like this:

   if "$host_os" = x86_64; then
     ...
   fi

and I see examples of this in gnulib/m4's float_h.m4, host-cpu-c-abi.m4, 
lib-prefix.m4, multiarch.m4, printf.m4, stack-direction.m4. In general 
don't you need to also edit these files and re-run Autoconf?

> I can't remember when was the last time I've been
> bitten by this. :-)

Often Gnulib code will guess the right value anyway. Not always, though. 
You ran into a case where Gnulib didn't guess and aborted. Some other 
times, the guess may differ from what it would be if you did a plain 
'configure; make' from a tarball. You might want to test for that, given 
the above list of potential problem files.

There may well be similar problems in configure.ac or *.m4 files 
maintained in GNU projects other than Gnulib. Autoconf itself has 
"x86_64" hardwired into AC_C_BIGENDIAN; I don't know whether this 
affects FreeBSD compilers.

> would you also consider
> adding "amd64" as a synonym to "x86_64" in that switch/case check?

Yes I suppose we could do that. Bruno, what do you think? You wrote most 
of those "x86_64"s.

>> Otherwise "result: unknown" should result in STACK_DIRECTION being 0,
>> which gnulib/lib/stackvma.h does not support (perhaps it should?).
> 
> Are you sure "result: unknown" should result in 0, not empty value as
> in my first email?

Not at this point, no.