Subject: GNU grep 3.7 fails to build on FreeBSD
From: Alexey Dokuchaev <[email-masked]>
To: [email-masked]
Date: Tue, 12 Oct 2021 09:53:00 +0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi there,

Version 3.7 does not build under FreeBSD, with the first problem of
STACK_DIRECTION macro being wrongly defined:

  ...
  ./stackvma.h:31:21: error: invalid token at start of a preprocessor expression
  #if STACK_DIRECTION < 0
                      ^

If I diff the generated grep-3.{6,7}/config.h files, I see this:

  @@ -1483,19 +1666,20 @@
      'size_t'. */
   /* #undef SIZE_T_SUFFIX */
   
  -/* If using the C implementation of alloca, define if you know the
  -   direction of stack growth for your system; otherwise it will be
  -   automatically deduced at runtime.
  -     STACK_DIRECTION > 0 => grows toward higher addresses
  -     STACK_DIRECTION < 0 => grows toward lower addresses
  -     STACK_DIRECTION = 0 => direction of growth unknown */
  -/* #undef STACK_DIRECTION */
  +/* Define on Solaris 11 and its derivates. */
  +/* #undef SOLARIS11 */
   
  +/* Define as the direction of stack growth for your system.  STACK_DIRECTION >
  +   0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward
  +   lower addresses STACK_DIRECTION = 0 => spaghetti stack. */
  +#define STACK_DIRECTION 
  +
   /* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
   /* #undef STAT_MACROS_BROKEN */

So before it was /* #undef STACK_DIRECTION */, now it's #define
STACK_DIRECTION<space>.  If I undefine it after ./configure manually, the
build still fails further down the road:

  ...
  sigsegv.c:979:29: error: no member named 'is_near_this' in 'struct vma_struct'
                      : vma.is_near_this (addr, &vma))
                        ~~~ ^

I believe the same bug affects diffutils 3.8 on FreeBSD:

    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257631

./danfe