GCC 6.2.1を使用してGCC 4.7.0をコンパイルするときにエラーを処理する方法

GCC 6.2.1を使用してGCC 4.7.0をコンパイルするときにエラーを処理する方法

私は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

私は、次のような理由で、以前のバージョンのGCCを最新バージョンに構築しようとすると、これが起こる可能性があることを読んでいます。

リリースが続くにつれて、GCCに新しいバグが追加されるため、古いバージョンのGCCソースコードは、最新バージョンのGCCで常に有効と見なされるわけではありません。

私は読んだここここここ

だからこの問題を解決するにはどうすればよいですか?

私は2つの可能な解決策を考えています。

  1. 学校のLinuxシステムを使用して、私のシステム用にGCC 4.7.0をクロスコンパイルします(GCC 4.7.0もありますが32ビットで、私は64ビットOSを使用します)。
  2. まず、私のコンピュータでGCC 6.2.1を使用してGCC 5.4.xをコンパイルし、次にGCC 5.4.xを使用してGCC 4.7.0をコンパイルしました。

最初のオプションはより安全なようです。両方とも仕事できますか?それよりもこれは良いですか?

編集する:

以下の@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

ベストアンサー1

私は最新のgccを使用することが一般的に良い選択ではないことに同意します。 Pengutronixを実行する組み込みARM v4システム用の新しいプログラムを作成する必要があります。これは2.6カーネルと古いglibcに固定されています。だから私のシステムで既存のツールチェーンをコンパイルする必要があります。

最新のGCCバージョンでは、かなり長い間存在していたソースコードのバグを見つけることがよくあります。エラーチェックをオフにするのではなく、ソースコードを修正することをお勧めします。

エラーログによると、関数宣言と関数ヘッダーが一致しません。

const char * libc_name_p (const char *, unsigned int);

Except.cに含まれるcfns.hファイルから

cfns.h を編集し、関数宣言を変更します。

#ifdef __GNUC__
__inline
#endif
const char * libc_name_p (const char *, unsigned int);

到着

#ifdef __GNUC__
__inline
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const char * libc_name_p (const char *, unsigned int);

これでコンパイルが機能します。

おすすめ記事