[gs 10.03.0] [MinGW-W64 11.0.1] [gcc 10.4.0] [x86_64-w64-mingw32-gcc 13.2.0] [openSUSE Leap 15.5] I have a problem with cross-compiling on my openSUSE GNU/Linux box for Windows using mingw. `configaux.log` contains ``` #define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIMES_H 1 ``` These values are taken from the standard openSUSE compilation environment. As a consequence, the generated file `obj/gconfig_.h` file contains ``` #ifndef HAVE_SYS_TIME_H #define HAVE_SYS_TIME_H 1 #endif #ifndef HAVE_SYS_TIMES_H #define HAVE_SYS_TIMES_H 1 #endif ``` On the other hand, `config.log` only contains ``` #define HAVE_SYS_TIME_H 1 ``` During compilation of file `base/gp_stdib.c` (with the mingw cross-compiler), file `base/time_.h` gets included, which in turn includes `base/gconfig_.h`. Due to that the test ``` #if defined(HAVE_SYS_TIMES_H) && HAVE_SYS_TIMES_H == 1 # include <sys/times.h> ... ``` succeeds, causing the compilation error because mingw does not have `sys/times.h`. In both passes, the configure script uses `AC_CHECK_HEADERS[... sys/times.h ...]`, which only defines `HAVE_SYS_TIMES_H=1` if the file exists – it does nothing if `sys/times.h` doesn't exist. AFAICS, this is incorrect: it should actually define `HAVE_SYS_TIMES_H=0` if it does not exist so that `gconfig_.h` doesn't set it to an incorrect value during cross-compilation. I fixed this locally by adding `GCFLAGS=-DHAVE_SYS_TIMES_H=0"` to the configure script.
More analysis showed that some GNU/Linux distributions like Fedora or openSUSE have `/usr/include/sys/times.h`, while others like Ubuntu or Debian have `/usr/include/x86_64-linux-gnu/sys/times.h`. The problem is that `unix-aux.mak` looks hard-coded into `/usr/include` to produce `gconfig_.h`. That's wrong - not only for cross-compiling, but also for native compilation. It only becomes a problem with cross-compilation, though.