Max*_*gan 4 compiling gcc cross-compilation
我正在使用 Arch linux,我需要 GCC 4.7.0 来上课。
目前我的系统上只安装了 GCC 6.2.1。
我正确地遵循了所有安装说明,但在运行初始make
.
$ make
.
.
In file included from /home/flounder/src/gcc-4.7.0/gcc-4.7.0/gcc/cp/except.c:987:0:
cfns.gperf: At top level:
cfns.gperf:101:1: error: ‘gnu_inline’ attribute present on ‘libc_name_p’
cfns.gperf:26:14: error: but not here
.
.
make[3]: *** [Makefile:1055: cp/except.o] Error 1
make[3]: Leaving directory '/home/flounder/src/gcc_compile/gcc'
make[2]: *** [Makefile:4101: all-stage1-gcc] Error 2
make[2]: Leaving directory '/home/flounder/src/gcc_compile'
make[1]: *** [Makefile:19342: stage1-bubble] Error 2
make[1]: Leaving directory '/home/flounder/src/gcc_compile'
make: *** [Makefile:898: all] Error 2
Run Code Online (Sandbox Code Playgroud)
我已经读过,当尝试使用现代版本构建旧版本的 GCC 时,可能会发生这种情况,因为:
GCC 会随着版本的发展增加新的错误,因此旧版本的 GCC 的源代码在新版本的 GCC 下并不总是被认为有效
那么我能做些什么来解决这个问题呢?
我认为可行的两种可能的解决方案:
第一个选项似乎更防弹。他们两个都行吗?这个比那个好吗?
编辑:
正如@Kenneth B. Jensen 在下面提到的,我尝试在--disable-werror
设置了标志的情况下运行配置,并尝试在设置了标志的情况下运行初始make
配置,-k
但我仍然遇到了麻烦。以下是错误输出:
$ make -k
.
.
.
if [ xinfo = xinfo ]; then \
makeinfo --split-size=5000000 --split-size=5000000 --split-size=5000000 --no-split -I . -I /home/flounder/src/gcc-4.7.0/gcc/doc \
-I /home/flounder/src/gcc-4.7.0/gcc/doc/include -o doc/cppinternals.info /home/flounder/src/gcc-4.7.0/gcc/doc/cppinternals.texi; \
fi
echo timestamp > gcc.pod
perl /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl /home/flounder/src/gcc-4.7.0/gcc/doc/invoke.texi > gcc.pod
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\@strong{ <-- HERE (.*)}$/ at /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl line 319.
echo timestamp > doc/gcc.1
(pod2man --center="GNU" --release="gcc-4.7.0" --date=2012-03-22 --section=1 gcc.pod > doc/gcc.1.T$$ && \
mv -f doc/gcc.1.T$$ doc/gcc.1) || \
(rm -f doc/gcc.1.T$$ && exit 1)
echo timestamp > gpl.pod
perl /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl /home/flounder/src/gcc-4.7.0/gcc/doc/include/gpl_v3.texi > gpl.pod
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\@strong{ <-- HERE (.*)}$/ at /home/flounder/src/gcc-4.7.0/gcc/../contrib/texi2pod.pl line 319.
echo timestamp > doc/gpl.7
(pod2man --center="GNU" --release="gcc-4.7.0" --date=2012-03-22 --section=7 gpl.pod > doc/gpl.7.T$$ && \
mv -f doc/gpl.7.T$$ doc/gpl.7) || \
(rm -f doc/gpl.7.T$$ && exit 1)
cp doc/gcc.1 doc/g++.1
make[3]: Target 'all' not remade because of errors.
rm gcc.pod
make[3]: Leaving directory '/home/flounder/src/gcc_compile/gcc'
make[2]: *** [Makefile:4101: all-stage1-gcc] Error 2
make[2]: Target 'all-stage1' not remade because of errors.
make[2]: Leaving directory '/home/flounder/src/gcc_compile'
make[1]: *** [Makefile:19342: stage1-bubble] Error 2
make[1]: Target 'stage3-bubble' not remade because of errors.
make[1]: Leaving directory '/home/flounder/src/gcc_compile'
make: *** [Makefile:898: all] Error 2
Run Code Online (Sandbox Code Playgroud)
小智 6
我同意使用较新的 gcc 通常不是一个好的选择。我不得不为运行 Pengutronix 的嵌入式 ARM v4 系统编写一个新程序,该系统停留在 2.6 内核和旧 glibc。因此我不得不在我的系统上编译旧的工具链。
通常较新的 GCC 版本会在源代码中发现错误,这些错误已经存在很长时间了。我建议不要关闭错误检查,而是修复源代码。
根据错误日志,函数声明和函数头不匹配
const char * libc_name_p (const char *, unsigned int);
Run Code Online (Sandbox Code Playgroud)
在包含在 except.c 中的文件 cfns.h 中
编辑 cfns.h 并更改函数声明
#ifdef __GNUC__
__inline
#endif
const char * libc_name_p (const char *, unsigned int);
Run Code Online (Sandbox Code Playgroud)
到
#ifdef __GNUC__
__inline
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const char * libc_name_p (const char *, unsigned int);
Run Code Online (Sandbox Code Playgroud)
然后编译应该工作。
您可能最终会花费大量时间在当前系统上构建 GCC 4.7,并且最终您仍然不确定结果:您学校计算机的 GCC 版本可能包含分发补丁甚至本地补丁您的版本不会有的更改。
我建议您在虚拟机中运行学校正在使用的发行版。您的学校正在使用 RHEL,您也可以:您可以从Red Hat Developers获得免费的开发人员订阅;订阅后,您可以下载任何仍受支持的 RHEL 版本的 ISO,因此您应该能够安装与学校计算机上使用的版本相同的版本。
无论如何,由于这是出于评分目的,因此您应该在提交之前在学校计算机上检查您的代码!