1
1

More than 3 years have passed since last update.

CentOS8へgcc-4.1.2をインストール

Last updated at Posted at 2020-06-16

はじめに

gcc-4.1.2をCentOS8へインストールします。
結果、コンパイルは成功しインストールまで完了しました。

作業

準備:環境構築

OS: CentOS-8.1.1911_x86_64 (2020/06/15)
コンパイルに必要なツールをインストールします。

dnf config-manager --set-enabled PowerTools;  //← texinfoのため
dnf groupinstall "Development Tools";
dnf install wget bzip2 texinfo glibc-devel glibc-static glibc glibc-devel.i686 binutils vim;

準備:GCC4.4.7のインストール

gccをコンパイルするためCentOS8へCentOS7のcompat-gcc-44-4.4.7をインストール - Qiitaに書かれている通りに実行し、gcc44をインストールします。

CentOS8に同梱されているGCCでもCXXFLAGSを指定すればこの手順は不要かもしれません。
CentOS 8で様々なバージョンのGCCをビルドしてみた

gcc-4.1.2のインストール

ソースコードのダウンロード

wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2;
tar -xvf gcc-4.1.2.tar.bz2;

ソースコードのコンパイル

cd gcc-4.1.2;
./configure --prefix=/usr/local/gcc-4.1.2 --enable-languages=c,c++;
make;

今回の環境では2か所でエラーが生じています。

../.././gcc/config/i386/linux-unwind.h:58: error: 不完全型のポインタへの間接参照
make[3]: *** [libgcc.mk:519: libgcc/./unwind-dw2.o] エラー 1

もうひとつは

../.././gcc/config/i386/linux-unwind.h:141: error: field ‘info’ has incomplete type
make[3]: *** [libgcc.mk:1135: libgcc/32/unwind-dw2.o] エラー 1

これはglibcのバージョンが新しいため発生しているようです(詳しくは調べていません)。

ソースコードの修正

エラーを解消するためにコードを修正します。

gcc/config/i386/linux-unwind.h(54行目)
- struct ucontext *uc_ = context->cfa;
+ ucontext_t *uc_ = context->cfa;
gcc/config/i386/linux-unwind.h(139,141-142行目)
struct rt_sigframe {
   int sig;
-  struct siginfo *pinfo;
+  siginfo_t *pinfo;
   void *puc;
-  struct siginfo info;
-  struct ucontext uc;
+  siginfo_t info;
+  ucontext_t uc;
} *rt_ = context->cfa;

コンパイルしインストール

修正が完了したので再度コンパイル・インストールします。

make && make install;

おしまい。

次回

gcc4.1.2がCentOS5.11で使われていたglibcを使ってコンパイルするように設定する。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1