web-dev-qa-db-ja.com

GCC makeのビルド:*** [すべて]エラー2

OSDev GCC Cross-Compiler Tutuorial。 に続いて、Ubuntuでi686-elfのクロスコンパイラーをセットアップしようとしています。ただし、GCCをセットアップするためのコードは毎回ビルドに失敗します。何かをする前にSudo apt-get updateしたので、ソースが古くなっていないことはわかっています。

必要なパッケージを入手するために、次のことを行いました:

Sudo apt-get install g++
Sudo apt-get install make
Sudo apt-get install bison
Sudo apt-get install flex
Sudo apt-get install libgmp3-dev
Sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
Sudo apt-get install mpc
Sudo apt-get install texinfo
Sudo apt-get install libcloog-isl-dev

その方法は問題ないと思いますか?

次に、gcc-5.2.0およびbinutils-2.25.1 (ubuntuでは、bintuilsはその古いバージョンより上のバージョンでは機能しないようです)binutilsを問題なくインストールしました。 gccをビルドしましたが、makeと入力すると、次のエラーが発生しました。

残念ながら、30ページをコピーして貼り付けることはできませんが、これですべてのコードが終わりに近づいています:

checking command to parse nm output from gcc  -m32 object... failed
checking how to run the C preprocessor... /lib/cpp
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking for dlfcn.h... no
checking for objdir... .libs
checking if gcc  -m32 supports -fno-rtti -fno-exceptions... no
checking for gcc  -m32 option to produce PIC... -fPIC -DPIC
checking if gcc  -m32 PIC flag -fPIC -DPIC works... yes
checking if gcc  -m32 static flag -static works... no
checking if gcc  -m32 supports -c -o file.o... yes
checking if gcc  -m32 supports -c -o file.o... (cached) yes
checking whether the gcc  -m32 linker (ld -m elf_x86_64 -m elf_i386) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:9590: recipe for target 'configure-zlib' failed
make[1]: *** [configure-zlib] Error 1
make[1]: Leaving directory '/home/david/scr'
Makefile:876: recipe for target 'all' failed
make: *** [all] Error 2

そしてこれは(その直後に)本当に悪いことが起こる部分です:

checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:9590: recipe for target 'configure-zlib' failed
make[1]: *** [configure-zlib] Error 1
make[1]: Leaving directory '/home/david/scr'
Makefile:876: recipe for target 'all' failed
make: *** [all] Error 2

誰かが私が間違っていることとそれを修正する方法を教えてもらえますか?

ありがとう!

5
user5458125

問題は、mpcをソースからインストールしていなかったことです。

完成したファイルは次のとおりです(setup-gcc.sh):

####################################
echo Stage 1 - Building Dependencies
####################################

# make a working directory
cd $HOME/Documents
rm -rf Cross
mkdir Cross
cd Cross

# install or update all apt-get dependencies
Sudo apt-get update
Sudo apt-get upgrade
Sudo apt-get install gcc                   # not cross
Sudo apt-get install g++
Sudo apt-get install make
Sudo apt-get install bison
Sudo apt-get install flex
Sudo apt-get install gawk
Sudo apt-get install libgmp3-dev
Sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
Sudo apt-get install mpc
Sudo apt-get install texinfo               # optional
Sudo apt-get install libcloog-isl-dev      # optional
Sudo apt-get install build-essential
Sudo apt-get install glibc-devel
Sudo apt-get -y install gcc-multilib libc6-i386

# download and unpack necessary files
wget http://ftpmirror.gnu.org/binutils/binutils-2.25.1.tar.gz
wget http://ftpmirror.gnu.org/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz
wget http://ftpmirror.gnu.org/mpc/mpc-1.0.3.tar.gz
for f in *.tar*; do tar zvxf $f; done

# create installation directory
mkdir Install
export PREFIX="$HOME/Documents/Cross/Install"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"

################################
echo Stage 2 - Building Compiler
################################

# install mpc
mkdir build-mpc
cd build-mpc
../mpc-1.0.3/configure --prefix="$PREFIX"
make -j2
make -j2 check
make -j2 install
cd ..

# install binutils
mkdir build-binutils
cd build-binutils
../binutils-2.25.1/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make -j2
make -j2 install
cd ..

# install gcc
mkdir build-gcc
cd build-gcc
../gcc-5.3.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers --with-mpc="$PREFIX"
make -j2 all-gcc
make -j2 all-target-libgcc
make -j2 install-gcc
make -j2 install-target-libgcc

インストールしたら、次のコマンドで実行できます。

export PREFIX="$HOME/Documents/Cross/Install"
export TARGET=i686-elf
$PREFIX/bin/$TARGET-gcc --version

残念ながら、エイリアスまたはbashスクリプト内でこれを行うと、正しく起動されないようです。したがって、これが修正されない限り、スクリプトをテキストファイルに保存し、再起動するたびにターミナルにコピーアンドペーストする必要があります。 。

クロスコンパイラをアンインストールするには、$HOME/Documents/Cross directory.を削除するだけです。

最後に、インストールディレクトリまたはターゲットの変更は、$PREFIXまたは$TARGETの値を変更するのと同じくらい簡単ですが、他の予期しない問題が発生する可能性があるため、お勧めしません。

2
user5458125

--with-system-zlibに加えて、--disable-multilibオプションを使用すると機能しました。

1
Yazhss