baiheng222 发表于 2006-10-17 15:36:05

交叉编译gcc3.4.4错误,哪为帮忙指导一下

我的系统是:FC3
内核:2.6.9-1.667
gcc:gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)

使用的源代码包是:binutils-2.16 glibc-2.3.3 gcc-3.4.4

编译步骤如下:
OWTO build arm-linux toolchain for ARM/XSCALE
----------------------------------------------

These instructions document how to build an arm-linux tool chain
that contains both little-endian and big-endian target libraries.


1. Packages used:

binutils-2.16.tar.gz
gcc-3.4.4.tar.gz
glibc-2.3.3.tar.gz
glibc-linuxthreads-2.3.3.tar.gz


2. binutils-2.16

tar xvzf binutils-2.16.tar.gz
cd binutils-2.16
mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --with-lib-path=/usr/local/arm-linux/lib:/usr/local/arm-linux/lib/be:/usr/local/arm-linux/lib/soft-float:/usr/local/arm-linux/lib/be/soft-float
make
make install
chmod 777 /usr/local/arm-linux


3. gcc-3.4.4

tar xvzf gcc-3.4.4.tar.gz
cd gcc-3.4.4

cp $(ATTACHED t-linux file) gcc/config/arm/
vi gcc/config/arm/linux-elf.h
-- remove line that defines LIBGCC_SPEC

mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --disable-shared --disable-threads \
--prefix=/usr/local --with-headers=linux-2.4.x/include \
--with-gnu-as --with-gnu-ld --enable-multilib --enable-languages=c
make
make install


4. glibc-2.3.3 (big-endian)

tar xvzf glibc-2.3.3.tar.gz
cd glibc-2.3.3
tar xvzf glibc-linuxthreads-2.3.3.tar.gz

rm -rf nptl
vi sysdeps/unix/sysv/linux/arm/ioperm.c
- change "BUS_ISA" to be "CTL_BUS_ISA" lines 103 and 104
vi config.make.in
- change "slibdir = @...@" to "slibdir = @libdir@"
vi Makeconfig
- change all occurrances of "O2" to "O"
- remove any occurrances of -lgcc_eh
vi configure
- change all occurrances of "O2" to "O"
touch sysdeps/arm/framestate.c

mkdir arm-linux
cd arm-linux
CC="arm-linux-gcc -mbig-endian -finline-limit=10000" \
AS="arm-linux-as -mbig-endian" \
LD="arm-linux-ld -EB" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.4.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux \
--libdir=/usr/local/arm-linux/lib/be
make
make install


5. glibc-2.3.3 (little-endian)

tar xvzf glibc-2.3.3.tar.gz
cd glibc-2.3.3
tar xvzf glibc-linuxthreads-2.3.3.tar.gz

[ Apply same fixes as above ]

mkdir arm-linux
cd arm-linux
CC="arm-linux-gcc -finline-limit=10000" \
AS="arm-linux-as" \
LD="arm-linux-ld" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.4.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux
make
make install



6. glibc-2.3.3 (big-endian/soft-float)

tar xvzf glibc-2.3.3.tar.gz
cd glibc-2.3.3
tar xvzf glibc-linuxthreads-2.3.3.tar.gz

[ Apply same fixes as above ]

mkdir arm-linux
cd arm-linux
CC="arm-linux-gcc -mbig-endian -msoft-float -finline-limit=10000" \
AS="arm-linux-as -mbig-endian" \
LD="arm-linux-ld -EB" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.4.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux \
--without-fp --libdir=/usr/local/arm-linux/lib/be/soft-float
make
make install



7. glibc-2.3.3 (little-endian/soft-float)

tar xvzf glibc-2.3.3.tar.gz
cd glibc-2.3.3
tar xvzf glibc-linuxthreads-2.3.3.tar.gz

[ Apply same fixes as above ]

mkdir arm-linux
cd arm-linux)

cp -r ../soft-fp .
cd soft-fp
CC="arm-linux-gcc" make
cd ..

CC="arm-linux-gcc -msoft-float -finline-limit=10000" \
AS="arm-linux-as" \
LD="arm-linux-ld" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.4.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux \
--without-fp --libdir=/usr/local/arm-linux/lib/soft-float
make
make install


8. gcc-3.4.4 (c++, etc)

tar xvzf gcc-3.4.4.tar.gz
cd gcc-3.4.4

cp $(ATTACHED t-linux file) gcc/config/arm/
vi gcc/config/arm/t-linux
- remove all "-Dinhibit_libc" occruances
vi gcc/config/arm/linux-elf.h
-- remove line that defines LIBGCC_SPEC
perl -pi -e 's/int namelen/unsigned int namelen/' libjava/java/net/natInetAddressPosix.cc

mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --disable-shared \
--prefix=/usr/local --with-headers=linux-2.4.x/include \
--with-gnu-as --with-gnu-ld --enable-multilib
make
make install


7. cd /
find /usr/local/arm-linux -name CVS -type d | xargs rm -rf
strip /usr/local/arm-linux/bin/*
strip /usr/local/bin/arm-linux-*
tar cvzf /tmp/arm-linux-tools-xxxxxxxx.tar.gz /usr/local/arm-linux \
/usr/local/lib/gcc/arm-linux /usr/local/include/c++/3.4.3 \
/usr/local/bin/arm-linux-* /usr/local/bin/genext2fs


------------------------------------------------------------------------------

APPENDIX A -- modified t-linux for gcc-3.4.4

------------------------------------------------------------------------------
# Just for these, we omit the frame pointer since it makes such a big
# difference. It is then pointless adding debugging.
TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix
LIBGCC2_DEBUG_CFLAGS = -g0

# Don't build enquire
ENQUIRE=

LIB1ASMSRC = arm/lib1funcs.asm
LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
_bb_init_func _call_via_rX _interwork_call_via_rX \
_negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
_truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
_fixsfsi _fixunssfsi

MULTILIB_OPTIONS = mlittle-endian/mbig-endian mhard-float/msoft-float
MULTILIB_DIRNAMES = le be hard-float soft-float

EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o crtn.o

LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h

# Assemble startup files.
$(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
-c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/arm/crti.asm

$(T)crtn.o: $(srcdir)/config/arm/crtn.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
-c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/arm/crtn.asm
------------------------------------------------------------------------------


按照以上步骤,编译完 glibc-2.3.3 (little-endian) 后 ,第二次编译gcc出错了,错误提示如下:cp g++ g++-cross
make: Leaving directory `/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc'
Checking multilib configuration...
multilib.out is unchanged
Configuring in arm-linux/libstdc++-v3
configure: loading cache ./config.cache
checking build system type... (cached) i686-pc-linux-gnu
checking host system type... (cached) arm-unknown-linux-gnu
checking target system type... (cached) arm-unknown-linux-gnu
checking for a BSD-compatible install... (cached) /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... (cached) gawk
checking whether make sets $(MAKE)... (cached) yes
checking for arm-linux-strip... (cached) arm-linux-strip
checking for arm-linux-gcc... (cached) /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc -B/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/ -B/home/baiheng222/phone-project/tools/arm-linux/bin/ -B/home/baiheng222/phone-project/tools/arm-linux/lib/ -isystem /home/baiheng222/phone-project/tools/arm-linux/include -isystem /home/baiheng222/phone-project/tools/arm-linux/sys-include
checking for suffix of object files... (cached) o
checking whether we are using the GNU C compiler... (cached) yes
checking whether /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc -B/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/ -B/home/baiheng222/phone-project/tools/arm-linux/bin/ -B/home/baiheng222/phone-project/tools/arm-linux/lib/ -isystem /home/baiheng222/phone-project/tools/arm-linux/include -isystem /home/baiheng222/phone-project/tools/arm-linux/sys-include accepts -g... (cached) yes
checking for /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc -B/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/ -B/home/baiheng222/phone-project/tools/arm-linux/bin/ -B/home/baiheng222/phone-project/tools/arm-linux/lib/ -isystem /home/baiheng222/phone-project/tools/arm-linux/include -isystem /home/baiheng222/phone-project/tools/arm-linux/sys-include option to accept ANSI C... (cached) none needed
checking for arm-linux-g++... (cached) /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc -shared-libgcc -B/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/ -nostdinc++ -L/home/baiheng222/phone-project/build-tools/BUILD/gcc/arm-linux/libstdc++-v3/src -L/home/baiheng222/phone-project/build-tools/BUILD/gcc/arm-linux/libstdc++-v3/src/.libs -B/home/baiheng222/phone-project/tools/arm-linux/bin/ -B/home/baiheng222/phone-project/tools/arm-linux/lib/ -isystem /home/baiheng222/phone-project/tools/arm-linux/include -isystem /home/baiheng222/phone-project/tools/arm-linux/sys-include
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc -shared-libgcc -B/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/ -nostdinc++ -L/home/baiheng222/phone-project/build-tools/BUILD/gcc/arm-linux/libstdc++-v3/src -L/home/baiheng222/phone-project/build-tools/BUILD/gcc/arm-linux/libstdc++-v3/src/.libs -B/home/baiheng222/phone-project/tools/arm-linux/bin/ -B/home/baiheng222/phone-project/tools/arm-linux/lib/ -isystem /home/baiheng222/phone-project/tools/arm-linux/include -isystem /home/baiheng222/phone-project/tools/arm-linux/sys-include accepts -g... (cached) yes
checking for GCC version number... 3.4.4
checking whether ln -s works... yes
checking for arm-linux-as... (cached) /home/baiheng222/phone-project/tools/arm-linux/bin/as
checking for arm-linux-ar... (cached) arm-linux-ar
checking for arm-linux-ranlib... (cached) arm-linux-ranlib
checking whether to enable maintainer-specific portions of Makefiles... no
configure: CPU config directory is cpu/generic
configure: OS config directory is os/gnu-linux
checking for ld used by GCC... (cached) /home/baiheng222/phone-project/tools/arm-linux/bin/ld
checking if the linker (/home/baiheng222/phone-project/tools/arm-linux/bin/ld) is GNU ld... (cached) yes
checking for /home/baiheng222/phone-project/tools/arm-linux/bin/ld option to reload object files... (cached) -rchecking for BSD-compatible nm... (cached) /home/baiheng222/phone-project/tools/arm-linux/bin/nm
checking how to recognise dependant libraries... (cached) file_magic ELF *-bit SB (shared object|dynamic lib )
checking for arm-linux-file... (cached) /usr/bin/file
checking for arm-linux-ranlib... (cached) arm-linux-ranlib
checking for arm-linux-strip... (cached) arm-linux-strip
updating cache ./config.cache
loading cache ./config.cache within ltconfig
checking for objdir... .libs
checking for /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc option to produce PIC... -fPIC -DPIC
checking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc PIC flag -fPIC -DPIC works... (cached) yes
checking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc static flag -static works... (cached) yes
finding the maximum length of command line arguments... (cached) 49153
checking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc supports -c -o file.o... (cached) yeschecking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc supports -fno-rtti -fno-exceptions ... no
checking whether the linker (/home/baiheng222/phone-project/tools/arm-linux/bin/ld) supports shared libraries... yes
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking command to parse /home/baiheng222/phone-project/tools/arm-linux/bin/nm output... failed
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
creating libtool
updating cache ./config.cache
configure: loading cache ./config.cache
checking how to run the C++ preprocessor... /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc -shared-libgcc -B/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/ -nostdinc++ -L/home/baiheng222/phone-project/build-tools/BUILD/gcc/arm-linux/libstdc++-v3/src -L/home/baiheng222/phone-project/build-tools/BUILD/gcc/arm-linux/libstdc++-v3/src/.libs -B/home/baiheng222/phone-project/tools/arm-linux/bin/ -B/home/baiheng222/phone-project/tools/arm-linux/lib/ -isystem /home/baiheng222/phone-project/tools/arm-linux/include -isystem /home/baiheng222/phone-project/tools/arm-linux/sys-include -E
loading cache ./config.cache within ltconfig
checking host system type... arm-unknown-linux-gnu
checking build system type... i686-pc-linux-gnu
checking for objdir... .libs
checking for /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc option to produce PIC... -fPIC -DPICchecking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc PIC flag -fPIC -DPIC works... yes
checking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc static flag -static works... yes
finding the maximum length of command line arguments... (cached) 49153
checking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc supports -c -o file.o... (cached) yeschecking if /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc supports -fno-rtti -fno-exceptions ... yes
checking whether the linker (/home/baiheng222/phone-project/tools/arm-linux/bin/ld) supports shared libraries...
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking command to parse /home/baiheng222/phone-project/tools/arm-linux/bin/nm output... failed
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
appending configuration tag "CXX" to libtool
checking for exception model to use... sjlj
checking for enabled PCH... yes
checking for compiler with PCH support... yes
checking for underlying I/O to use... stdio
checking how to run the C preprocessor... /home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/xgcc -B/home/baiheng222/phone-project/build-tools/BUILD/gcc/gcc/ -B/home/baiheng222/phone-project/tools/arm-linux/bin/ -B/home/baiheng222/phone-project/tools/arm-linux/lib/ -isystem /home/baiheng222/phone-project/tools/arm-linux/include -isystem /home/baiheng222/phone-project/tools/arm-linux/sys-include -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for C locale to use... generic
checking for std::allocator base class to use... new
configure: "C" header strategy set to c_std
checking for ISO C99 support in <math.h>... yes
checking for ISO C99 support in <stdio.h>... yes
checking for lldiv_t declaration... yes
checking for ISO C99 support in <stdlib.h>... yes
checking for additional ISO C99 support in <wchar.h>... yes
checking for enabled ISO C99 support... yes
checking for thread model used by GCC... posix
configure: Debug build flags set to -g3 -O0
checking for additional debug build... no
checking for extra compiler flags for building...
configure: WARNING: No native atomic operations are provided for this platform.
configure: WARNING: They will be faked using a mutex.
configure: WARNING: Performance of certain classes will degrade as a result.
checking nan.h usability... no
checking nan.h presence... no
checking for nan.h... no
checking ieeefp.h usability... no
checking ieeefp.h presence... no
checking for ieeefp.h... no
checking endian.h usability... yes
checking endian.h presence... yes
checking for endian.h... yes
checking sys/isa_defs.h usability... no
checking sys/isa_defs.h presence... no
checking for sys/isa_defs.h... no
checking machine/endian.h usability... no
checking machine/endian.h presence... no
checking for machine/endian.h... no
checking machine/param.h usability... no
checking machine/param.h presence... no
checking for machine/param.h... no
checking sys/machine.h usability... no
checking sys/machine.h presence... no
checking for sys/machine.h... no
checking for sys/types.h... (cached) yes
checking fp.h usability... no
checking fp.h presence... no
checking for fp.h... no
checking float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking for endian.h... (cached) yes
checking for inttypes.h... (cached) yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for float.h... (cached) yes
checking for stdint.h... (cached) yes
checking for main in -lm... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
make: *** 错误 1

各为大哥,这错误怎么解决啊?请帮忙指导一下,谢谢了

Lisa2006 发表于 2006-10-18 13:59:02

向你推荐一个网站: http://kegel.com/crosstool/
那里有做好的编译脚本crosstool, 很好用的。我用它编过MIPS工具链,下载的gcc版本和你的一样。

wiserltz 发表于 2006-10-18 14:47:52

Yes, crosstool is the bestttttttttttttttttt starting point

crosser 发表于 2006-10-18 17:03:10

楼上不错

呵呵非常感谢楼上的几位我最近也在学这个GCC编译问题 谢了
不知大家有没有在LINUX上试过这个实时数据库eXtremeDB没有 呵呵 推荐给大家一起看看吧

jiangtao9999 发表于 2006-10-18 23:02:20

--host 的问题?你是在当前系统里运行你还是在 arm 里运行?好像本地运行需要 host 也是 i686?在 arm 运行的话 --host 是 arm ,但需要有一个 arm-linux 编译器?

baiheng222 发表于 2006-10-19 10:30:24

首先,谢谢楼上的各位了。
我已经下载了别人编译好的交叉编译工具了,而且也能用。但是我觉得还是根据自己的具体情况编译出来的更合适。
而且我现在想学一下怎么制作交叉编译工具,没向导遇到这么多问题。
我的交叉编译工具是在本地的X86机器上运行的,楼上斑竹所说的--host应该是编译glibc时的参数,我认为这没有问题,glibc是运行在arm目标板上的程序所必须,所以说glibc应该也是跑在arm目标板上的。不知道我的理解对不对?

likehht 发表于 2006-12-2 16:56:14

大家好,不知楼主是在那里下的,能否给出链接阿?
页: [1]
查看完整版本: 交叉编译gcc3.4.4错误,哪为帮忙指导一下