This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc build second pass : C compiler cannot create executables
- From: Mo Jia <life dot 130815 at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 8 Apr 2014 20:13:21 +0800
- Subject: gcc build second pass : C compiler cannot create executables
- Authentication-results: sourceware.org; auth=none
Try to make a gcc cross compiler ,
0 perpare vars in env
export HOST=x86_64-pc-linux-gnu
export BUILD=$HOST
export TARGET=x86_64-none-linux-gnu
export CROSS_TOOL=/vita/cross-tool
export CROSS_GCC_TMP=/vita/cross-gcc-tmp
export SYSROOT=/vita/sysroot
PATH=$CROSS_TOOL/bin:$CROSS_GCC_TMP/bin:/sbin:/usr/sbin:$PATH
1 build binutilss
../binutils-2.23.1/configure --prefix=$CROSS_TOOL \
--target=$TARGET --with-sysroot=$SYSROOT
build success
then add this lines to .bashrc And this want build glibc next use the
tools I just build
export AR="$TARGET-ar"
export AS="$TARGET-as"
export RANLIB="$TARGET-ranlib"
export LD="$TARGET-ld"
export STRIP="$TARGET-strip"
2 build freestanding compiler first perpare gmp source
cd gcc-4.7.2/
tar -xvf ../../source/mpfr-3.1.1.tar.bz2
tar -xvf ../../source/mpc-1.0.1.tar.gz
tar -xvf ../../source/gmp-5.0.5.tar.bz2
mv gmp-5.0.5/ gmp
mv mpfr-3.1.1/ mpfr
mv mpc-1.0.1/ mpc
then cd to gcc-build1
../gcc-4.7.2/configure --prefix=$CROSS_GCC_TMP --target=$TARGET \
--with-sysroot=$SYSROOT --with-newlib --enable-languages=c \
--with-mpfr-include=/vita/build/gcc-4.7.2/mpfr/src \
--with-mpfr-lib=/vita/build/gcc-build1/mpfr/src/.libs \
--disable-shared --disable-threads --disable-decimal-float \
--disable-libquadmath --disable-libmudflap --disable-libgomp \
--disable-nls --disable-libssp --disable-multilib
succss . So add this line the ~/.bashrc (this will use this build
gcc to build a second gcc )
export CC="$TARGET-gcc"
3 build glibc
../glibc-2.15/configure --prefix=/usr --host=$TARGET \
--enable-kernel=3.7.4 --enable-add-ons \
--with-headers=$SYSROOT/usr/include\
libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes \
libc_cv_ctors_header=yes
and make and install
make install_root=$SYSROOT install
after install :
vita@engine-virtual-machine:/vita$ ls sysroot/usr/lib64/*.o
sysroot/usr/lib64/crt1.o sysroot/usr/lib64/crtn.o
sysroot/usr/lib64/Mcrt1.o
sysroot/usr/lib64/crti.o sysroot/usr/lib64/gcrt1.o
sysroot/usr/lib64/Scrt1.o
4 build second pass gcc , cd to gcc-build2
../gcc-4.7.2/configure --prefix=$CROSS_TOOL --target=$TARGET \
--with-sysroot=$SYSROOT \
--with-newlib --enable-languages=c,c++ \
--with-mpfr-include=/vita/build/gcc-4.7.2/mpfr/src \
--with-mpfr-lib=/vita/build/gcc-build2/mpfr/src/.libs \
--disable-multilib --enable-threads=posix
Here will be error
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-none-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libitm support... yes
checking for gcc... x86_64-none-linux-gnu-gcc
checking for C compiler default output file name...
configure: error: in `/vita/build/gcc-build2':
configure: error: C compiler cannot create executables
Then I cd /vita/cross-gcc-tmp/bin The first pass install dir :
vita@engine-virtual-machine:/vita/cross-gcc-tmp/bin$
./x86_64-none-linux-gnu-gcc test.c
/vita/cross-tool/bin/x86_64-none-linux-gnu-ld: cannot find crt1.o:
No such file or directory
/vita/cross-tool/bin/x86_64-none-linux-gnu-ld: cannot find crti.o:
No such file or directory
collect2: error: ld returned 1 exit status
(I install bintuils in /vita/cross-tool and install tmp gcc in
/vita/cross-gcc-tmp )
Here is question :
Seem /vita/cross-tool/bin/x86_64-none-linux-gnu-ld can't find crti.o
and it don't know the $sysroot/usr/lib64 I already success build
So I am wondering the --with-sysroot=$SYSROOT mean to search libs in
$SYSROOT, why it can't known ?
Any suggestion ?