我收到此错误:
>/usr/local/contrib/gcc-9.1.0/libbacktrace/pecoff.c: In function ‘coff_add’:
/usr/local/contrib/gcc-9.1.0/libbacktrace/pecoff.c:656:37: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
656 | memcpy (&fhdr, fhdr_view.data + 4, sizeof fhdr);
| ^
/usr/local/contrib/gcc-9.1.0/libbacktrace/pecoff.c:690:22: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
690 | (sects_view.data + fhdr.size_of_optional_header);
| ^
/usr/local/contrib/gcc-9.1.0/libbacktrace/pecoff.c:730:45: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
730 | str_size = coff_read4 (syms_view.data + syms_size);
| ^
cc1: all warnings being treated as errors
make[3]: *** [Makefile:1190: pecoff.lo] Error 1
make[3]: Leaving directory '/usr/local/contrib/gcc_build/x86_64-pc-cygwin/libbacktrace'
make[2]: *** [Makefile:973: all] Error 2
make[2]: Leaving directory '/usr/local/contrib/gcc_build/x86_64-pc-cygwin/libbacktrace'
make[1]: *** [Makefile:19155: all-target-libbacktrace] Error 2
make[1]: Leaving directory '/usr/local/contrib/gcc_build'
make: *** [Makefile:996: all] Error 2
当 make 执行以下操作时:
libtool: compile: /usr/local/contrib/gcc_build/./gcc/xgcc -B/usr/local/contrib/gcc_build/./gcc/ -B/usr/local/x86_64-pc-cygwin/bin/ -B/usr/local/x86_64-pc-cygwin/lib/ -isystem /usr/local/x86_64-pc-cygwin/include -isystem /usr/local/x86_64-pc-cygwin/sys-include -DHAVE_CONFIG_H -I. -I/usr/local/contrib/gcc-9.1.0/libbacktrace -I /usr/local/contrib/gcc-9.1.0/libbacktrace/../include -I /usr/local/contrib/gcc-9.1.0/libbacktrace/../libgcc -I ../libgcc -funwind-tables -frandom-seed=pecoff.lo -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -Werror -g -O2 -pedantic -fomit-frame-pointer -m64 -mtune=sandybridge -march=sandybridge -c /usr/local/contrib/gcc-9.1.0/libbacktrace/pecoff.c -o pecoff.o
我的 make 版本是适用于 x86_64-unknown-cygwin 的 GNU Make 4.2.1,我当前的 GCC 是 7.4.0
我在源代码中输入了如下配置程序,
bash
/usr/local/contrib/gcc-9.1.0/configure --enable-static --disable-shared --with-mpfr-include=/usr/local/include/ --with-mpfr-lib=/usr/local/lib/ --with-mpc-include=/usr/local/include/ --with-mpc-lib=/usr/local/lib/ --with-gmp-include=/usr/local/include/ --with-gmp-lib=/usr/local/lib/ CC=gcc CFLAGS="-O2 -pedantic -fomit-frame-pointer -m64 -mtune=sandybridge -march=sandybridge"
为了与我为依赖项 mpfr、mpc 和 gmp 所做的其他配置兼容,它们都共享相同的编译选项。--enable-static 和 --disable-shared 用于配置不查找共享库,而是选择静态库,否则我会在构建依赖项时遇到错误,因为 gmp 是建立在静态库上的
fossies 网站上的项目:gcc-9.1.0 源代码和配置文件:配置步骤
经过一些测试后,我意识到我需要一些更明确的方法来禁用编译器的指针算术错误。我遇到的问题是因为 Makefile 上有很多宏和变量的重写,还有许多需要更改的候选,顺便说一句,我还不完全理解它们定义的逻辑。我在它说它给出错误的行、Makefile 和一些变量上测试了更改,例如:
RECURSE_FLAGS_TO_PASS TFLAGS TARGET_FLAGS_TO_PASS RECURSE_FLAGS_TO_PASS
并在终端上使用 BUILD_CONFIG 和 EXTRA_BUILD_FLAGS
尝试禁用警告,有时我也会使用 CXX_FLAGS 或 CFLAGS,通常使用 CFLAGS,因为安装文档对它有很多引用
我可以让 make 命令打印:
[ -f stage_final ] || echo stage3 > stage_final
RECURSE_FLAGS_TO_PASS+=CFLAGS+=-W
TFLAGS+=CFLAGS+=-W
TARGET_FLAGS_TO_PASS+=CFLAGS+=-W
RECURSE_FLAGS_TO_PASS+=CFLAGS=-W
我认为这可能是一些进展
答案1
使用
AM_MAKEFLAGS+=CFLAGS+=-Wno-error=pointer-arith
解决了问题,在 make 命令之后附加了 AM_MAKEFLAGS 宏,并使用 Wno-error 来告知应忽略特定错误,就我而言,由于我应该只使用 GCC 进行编译,因此显示的错误毫无用处,因为它的功能是避免无法在其他编译器上运行的代码,而这几乎就是全部