I ran into a build problem while doing a canadian cross build of GCC. I was building on linux to create a Windows (mingw) GCC that generates code for mips-mti-elf.
The mips-mti-elf target uses newlib for its system headers and libraries and the headers do not include a fenv.h header file. However, when doing a canadian cross build libstdc++ is built with the C++ compiler that runs on linux (the build system), not the C++ that was just built for Windows (the host system). The problem is that the libstdc++ configure script (in GLIBCXX_CHECK_C99_TR1) is checking for the fenv.h using C++ (not C) and the C++ compiler running on linux does have an fenv.h header because the latest libstdc++ builds always create this header for C++ regardless of whether there is one on the system or not. This results in the newly created libstdc++ library having a fenv.h header that tries to include the system fenv.h header file which does not exist and the build fails. My fix for this is to explicitly check for fenv.h and complex.h in the libstdc++ configure.ac script before calling GLIBCXX_CHECK_C99_TR1. This makes the configure script check for these headers using the C compiler instead of the C++ compiler and when GLIBCXX_CHECK_C99_TR1 is run it uses that information (saved in a autoconf variable) to correctly ascertain that fenv.h does not exist. I could put these checks in GLIBCXX_CHECK_C99_TR1 if that were considered preferable, it would just have to be done before we call 'AC_LANG_CPLUSPLUS'. Tested with both my canadian cross build and a standard cross build targetting mips-mti-elf. OK for checkin? Steve Ellcey sell...@mips.com 2013-10-30 Steve Ellcey <sell...@mips.com> * configure.ac: Add header checks for fenv.h and complex.h. * configure: Regenerate. diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index dd13b01..22fc840 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -195,6 +195,12 @@ GLIBCXX_CHECK_S_ISREG_OR_S_IFREG AC_CHECK_HEADERS(sys/uio.h) GLIBCXX_CHECK_WRITEV +# Check for fenv.h and complex.h before GLIBCXX_CHECK_C99_TR1 +# so that the check is done with the C compiler (not C++). +# Checking with C++ can break a canadian cross build if either +# file does not exist in C but does in C++. +AC_CHECK_HEADERS(fenv.h complex.h) + # For C99 support to TR1. GLIBCXX_CHECK_C99_TR1