编译GCC 7:错误:C++预处理器“/ lib/cpp”未通过健全性检查

问题描述:

尝试从源代码构建GCC 7.1.0。这不是我第一次,它曾经在过去的GCC版本中工作。编译GCC 7:错误:C++预处理器“/ lib/cpp”未通过健全性检查

../configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \ 
--prefix=/c/mingw64 --with-sysroot=/c/mingw64 \ 
--with-gmp=/c/mingw64/gmp --with-mpfr=/c/mingw64/mpfr --with-mpc=/c/mingw64/mpc \ 
--with-isl=/c/mingw64/isl \ 
--disable-nls --disable-multilib --disable-libstdcxx-pch --disable-shared \ 
--disable-win32-registry --disable-libstdcxx-debug --disable-libstdcxx-verbose \ 
--with-tune=haswell --enable-lto --enable-checking=release --enable-languages=c,c++ \ 
--enable-libstdcxx-time --enable-threads=win32 --enable-libatomic --enable-fully-dynamic-string 

错误

checking how to run the C++ preprocessor... /lib/cpp 
configure: error: in `/c/mingw64/src/build/gcc': 
configure: error: C++ preprocessor "/lib/cpp" fails sanity check 
See `config.log' for more details. 
make[2]: *** [Makefile:4309: configure-stage2-gcc] Error 1 
make[2]: Leaving directory '/c/mingw64/src/build' 
make[1]: *** [Makefile:20550: stage2-bubble] Error 2 
make[1]: Leaving directory '/c/mingw64/src/build' 
make: *** [Makefile:936: all] Error 2 

完整的config.log:https://pastebin.com/raw/mEeJHCuK

注意,我从来没有/lib/cpp存在。

我做了一些谷歌搜索,想尽建议,包括:

  • CXX=/c/mingw/bin/g++(同样以CCCPP
  • /c/mingw/bin/g++替换的/lib/cpp所有出现在gcc-7.1.0/gcc/configure。这给了我:
 
    conftest.c:14:8: error: 'Syntax' does not name a type 
      Syntax error 
      ^

(^类似于Compiling on a mac: What does it mean if my compiler fails a sanity check?

有这似乎在https://gcc.gnu.org/ml/gcc-bugs/2015-10/msg00604.html相关的旧的(关键)的bug,但没有更新。

+0

同样的问题在这里。这是由'检查如何运行C++预处理器'造成的(请参阅你的config.log在'/ lib/cpp'失败之上的几行)。由于某种原因它找不到'limits.h'。 – user5434231

CPP不应该指向g++; CPP是C预处理器,所以使它指向C预处理:

CPP=/c/mingw/bin/cpp 

这是您链接到的问题中提到。

+0

使用你的解决方案,但也需要用src/gcc/configure中的“/ c/mingw/bin/cpp”替换所有出现的“/ lib/cpp”。尽管如此,您的帖子标记为答案。 –

+0

@JohnLondon:好吧听起来像配置脚本是越野车tbh –