Search code examples
windowsgcccygwincross-compilingglibc

Building glibc for cross compiler fails on Cygwin


I'm trying to build a cross-compiler toolchain under Cygwin on Windows so that I (or rather someone I'm helping out - I'd use Linux but Windows is much easier for many people) can compile sources targeting the MIPS architecture.

I have a script which successfully builds a cross-compiler toolchain for MIPS under x86_64 on Linux using the following code:

https://github.com/UoMCS/mips-cross-compile/tree/glibc

However, when I run the script under Cygwin, it fails during the glibc install-headers phase with the following error:

gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /home/Cygwin/xc/mips-linux/tmp/build-glibc/config.h rpc_main.c \
        -o /home/Cygwin/xc/mips-linux/tmp/build-glibc/sunrpc/cross-rpc_main.o -MMD -MP -MF /home/Cygwin/xc/mips-linux/tmp/build-glibc/sunrpc/cross-rpc_main.o.dt -MT /home/Cygwin/xc/mips-linux/tmp/build-glibc/sunrpc/cross-rpc_main.o -c
rpc_main.c: In function ‘find_cpp’:
rpc_main.c:329:17: error: storage size of ‘buf’ isn’t known
   struct stat64 buf;
                 ^
rpc_main.c: In function ‘checkfiles’:
rpc_main.c:1117:17: error: storage size of ‘buf’ isn’t known
   struct stat64 buf;
                 ^
Makefile:163: recipe for target '/home/Cygwin/xc/mips-linux/tmp/build-glibc/sunrpc/cross-rpc_main.o' failed
make[2]: *** [/home/Cygwin/xc/mips-linux/tmp/build-glibc/sunrpc/cross-rpc_main.o] Error 1
make[2]: Leaving directory '/home/Cygwin/xc/mips-linux/tmp/glibc-2.21/sunrpc'
Makefile:213: recipe for target 'sunrpc/install-headers' failed
make[1]: *** [sunrpc/install-headers] Error 2
make[1]: Leaving directory '/home/Cygwin/xc/mips-linux/tmp/glibc-2.21'
Makefile:9: recipe for target 'install-headers' failed
make: *** [install-headers] Error 2

I'm not sure why I'm getting this error under Cygwin but not Linux, given that the source files for binutils, GCC, glibc and the kernel are identical (all downloaded automatically by the build script). I can't find any useful hints through searching for the same error message. Can anyone suggest what might be the problem?

I'm using the following software on the host environment:

  • Windows 7 64 bit
  • Cygwin 2.0.0 (64 bit)
  • GCC 4.9.2

Solution

  • As explained on the Cygwin's FAQ. Cygwin does not use stat64. Could try to replace the stat64 by stat manually or by a define maybe.