After upgrading to mingw 4.0 (gcc 4.8.1), I can no longer compile LLVM. Here's the error:
In file included from c:/rust/src/llvm/lib/Analysis/ConstantFolding.cpp:33:0:
c:/rust/src/llvm/include/llvm/Support/FEnv.h: In function 'void llvm::sys::llvm_fenv_clearexcept()':
c:/rust/src/llvm/include/llvm/Support/FEnv.h:36:17: error: 'FE_ALL_EXCEPT' was not declared in this scope
feclearexcept(FE_ALL_EXCEPT);
^
c:/rust/src/llvm/include/llvm/Support/FEnv.h:36:30: error: 'feclearexcept' was not declared in this scope
feclearexcept(FE_ALL_EXCEPT);
^
c:/rust/src/llvm/include/llvm/Support/FEnv.h: In function 'bool llvm::sys::llvm_fenv_testexcept()':
c:/rust/src/llvm/include/llvm/Support/FEnv.h:47:20: error: 'FE_ALL_EXCEPT' was not declared in this scope
if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
^
c:/rust/src/llvm/include/llvm/Support/FEnv.h:47:37: error: 'FE_INEXACT' was not declared in this scope
if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
^
c:/rust/src/llvm/include/llvm/Support/FEnv.h:47:47: error: 'fetestexcept' was not declared in this scope
if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))
The culprit seems to be that "%mingw%\lib\gcc\mingw32\4.8.1\include\c++\fenv.h" header does not include "%mingw%\include\fenv.h" because _GLIBCXX_HAVE_FENV_H is not defined.
I figure that "_GLIBCXX_HAVE_FENV_H" should have been defined in "bits\c++config.h", but it isn't.
I'll take a look at the config.log but the issue becomes one of why the upstream system did not find fenv.h to declare the appropriate HAVE environment macro.
I'm wondering if this is maybe another search order issue, similar to what we've seen before with float.h; maybe even the float.h issue itself, in another guise?
When Danny Smith built the MinGW releases of GCC, he always arranged for the MinGW' host-specific headers to be searched BEFORE the GCC host-neutral headers; that way MinGW's float.h was included, and it pulled in GCC's with an
#include_next
. However, that's contrary to GCC's natural way of setting things up. If that search order is reversed, as it naturally is in a GCC build, then MinGW's headers such as float.h never get included, because GCC doesn't extend the#include_next
courtesy to the platform headers.Defining it at the command line below works around the issue, but Earnie is right, it would be nice for the make files to figure it out for themselves :
make CXXFLAGS=-D_GLIBCXX_HAVE_FENV_H
Also, I did notice an existing comment about Clang build not finding fenv.h as well, and a patch was made in the source. Weird.