首页 > 解决方案 > 构建带有错误的 GCC 4.4.7(一些警告被视为错误)

问题描述

configure flags: --prefix=/nix/store/l06rvwfzdvpabvgzzad4d3zy0pk8rd45-gcc-4.4.7 --disable-multilib --with-ppl=/nix/store/qkydvl67jamj9k2538a7b7467gqx073i-ppl-1.2 --with-cloog=/nix/store/zbn4xs136ccagbjvl7ka8br3f3w9w1gj-cloog-ppl-0.15.11 --with-gmp=/nix/store/7mrq5v4nnqfkv1ka7a0kdw9mzvqs5w3c-gmp-6.1.2 --with-mpfr=/nix/store/9429azblcx1y9apas3azxxd38imcmsy0-mpfr-4.0.2 --disable-libstdcxx-pch --without-included-gettext --with-system-zlib --enable-languages=c\,c++

部分日志:

../../gcc-4.4.7/libcpp/macro.c:1730:8: error: format not a string literal and no format arguments [-Werror=format-security]
        cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
        ^~~~~~~~~
../../gcc-4.4.7/libcpp/macro.c:1743:8: error: format not a string literal and no format arguments [-Werror=format-security]
        cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
        ^~~~~~~~~

我已经尝试添加CFLAGS=-Wno-error,但对它没有影响。我还绑定了使用 sed 替换Werror=format-security,它也失败了。

标签: gcccompilation

解决方案


我的猜测是您正在使用更新版本的编译器(在 4.4.7 发布时不存在),并带有新的和加强的警告。

编写 GCC 的语言在某些时候已经从 C 更改为 C++。如果那是在 4.4 之前(不确定;将不得不检查),那么CFLAGS无效的原因很清楚 - 也尝试设置CXXFLAGS

(为了保留一些历史:我最初发布的答案建议使用 CFLAGS_FOR_TARGET,这是错误的,因为 libcpp 不是目标库,因此是用系统编译器构建的,而不是刚刚构建的)


推荐阅读