use gcc 4.12 on Fedora 7
可參考 http://www.uclinux.org/pub/uClinux/m68k-elf-tools/tools-20061214/build-uclinux-tools.sh 的做法,可惜完全沒用。

1. download soure codes.
a. http://gcc.gnu.org/ (2006-03-06)
ftp://mirrors.laffeycomputer.com/pub/gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-4.2.2.tar.bz2
b. http://www.gnu.org/software/binutils/ (2007/12/3)
ftp://sourceware.org/pub/binutils/snapshots/binutils-2.18.50.tar.bz2
c. http://www.uclibc.org/ (2007-05-06)
http://www.uclibc.org/downloads/uClibc-0.9.27.tar.bz2
d. http://sourceware.org/newlib/ (2005-12-16)
ftp://sources.redhat.com/pub/newlib/newlib-1.14.0.tar.gz
e.
http://www.uclinux.org/pub/uClinux/m68k-elf-tools/tools-20061214/elf2flt-20060608.tar.gz

2. make directory
a. mkdir /toolchain
b. cd /toolchain
c. mkdir arm
d. mkdir build-gcc
e. mkdir build-binutils

3. extract
a. cd /toolchain
b. tar jxvf /mnt/hgfs/sigma/src/toolchains/binutils-2.18.50.tar.bz2
c. tar jxvf /mnt/hgfs/sigma/src/toolchains/gcc-4.2.2.tar.bz2
d. tar jxvf /mnt/hgfs/sigma/src/toolchains/uClibc-0.9.27.tar.bz2
e. tar zxvf /mnt/hgfs/sigma/src/toolchains/newlib-1.14.0.tar.gz
f. tar zxvf /mnt/hgfs/sigma/src/toolchains/elf2flt-20060608.tar.gz
g. cd /toolchain/gcc-4.2.2
h. ln -s ../newlib-1.14.0 newlib

4. build binutils
a. cd /toolchain/build-binutils
b. configure
../binutils-2.18.50/configure \
--srcdir=../binutils-2.18.50 \
--target=arm-elf \
--disable-shared \
--enable-multilib \
--prefix=/toolchain/arm
c. make all
d. make install
e. export PATH=/toolchain/arm/bin:$PATH

- 編譯完成後可以在 /toolchain 目錄下找到執行檔。
- 設定 path 是因為在 build gcc 時需用到 arm-elf-ar。

5. build elf2flt
a. cd /toolchain/elf2flt-20060608
b. configure
./configure --target=arm-elf --prefix=/toolchain/arm \
--with-bfd-include-dir=/toolchain/build-binutils/bfd \
--with-binutils-include-dir=/sigma/binutils-2.18.50/include \
--with-libbfd=/toolchain/build-binutils/bfd/.libs/libbfd.a \
--with-libiberty=/toolchain/build-binutils/libiberty/libiberty.a
c. make
d. make install

6. build gcc without library
a. cd /toolchain/build-gcc
c. configure
../gcc-4.2.2/configure \
--srcdir=../gcc-4.2.2 \
--target=arm-elf \
--prefix=/toolchain/arm \
--enable-multilib \
--enable-threads \
--with-cpu=arm7tdmi \
--with-float=soft \
--with-newlib \
--without-headers \
--disable-shared \
--enable-languages=c,c++
d. make all-gcc
e. make install-gcc

- GCC 3.4 必須在編譯設定時加上 “--with-float=soft|hard” 來指定要使用軟體或硬體浮點運算,在這裡我們必須指定使用軟體浮點運算。
- GCC 3.4 針對 ”arm-elf” 的 cross toolchain 改用由 Nicolas Pitre 所設計的 ARM 軟體浮點運算功能,這個新的 ARM 軟體浮點運算實作不但體積小而且比原來的 C 版本速度更快。因此請務必將target 設定成 arm- elf,GCC 預設才會去使用新的軟體浮點運算。
- 編譯完成後可以在 /toolchain 目錄下找到執行檔。
- with-headers 會造成下列錯誤,千萬不要用,改用 without-headers。
In file included from ../../gcc-3.4.6/gcc/crtstuff.c:62:
../../gcc-3.4.6/gcc/tsystem.h:79:19: stdio.h: No such file or directory
../../gcc-3.4.6/gcc/tsystem.h:82:23: sys/types.h: No such file or directory
../../gcc-3.4.6/gcc/tsystem.h:85:19: errno.h: No such file or directory
../../gcc-3.4.6/gcc/tsystem.h:92:20: string.h: No such file or directory
../../gcc-3.4.6/gcc/tsystem.h:93:20: stdlib.h: No such file or directory
../../gcc-3.4.6/gcc/tsystem.h:94:20: unistd.h: No such file or directory
../../gcc-3.4.6/gcc/tsystem.h:100:18: time.h: No such file or directory

7. build newlib
a. cd /toolchain/newlib-1.14.0
b. configure
./configure \
--target=arm-elf \
--prefix=/toolchain/arm \
--disable-shared \
--enable-multilib \
--enable-languages=c,c++
c. make all
d. make install

8. build gcc with library
a. cd /toolchain/build-gcc
b. make all
c. make install

9. build uClibc
a. cd /toolchain/uClibc-0.9.27
b. make menuconfig
** Target Architecture (arm)
** Target Architecture Features and Options
++ Target Processor Type (Generic Arm)
++ Target Processor Endianness (Little Endian)
-- Target CPU has a memory management unit (MMU)
++ Enable floating point number support
-- Target CPU has a floating point unit
++ Enable full C99 math library support
++ (-Wall) Compiler Warnings
++ (/sigma/armutils_2.8.0.2/build_arm/linux-2.4.26-em86xx) Linux kernel header location
** General Library Settings
-- Generate Position Independent Code
++ Support global constructors and destructors
++ POSIX Threading Support
-- Build pthreads debugging support
++ Large File Support
++ Malloc Implementation (malloc)
-- Malloc returns live pointer for malloc(0)
++ Dynamic atexit() Support
++ Shadow Password Support
++ Support only Unix 98 PTYs
++ Assume that /dev/pts is a devpts or devfs file system
++ Support 'struct tm' timezone extension fields
++ Enable caching of the last valid timezone 'TZ' string
++ Enable '/etc/TZ' file support to set a default timezone (uClibc-specific)
++ Repeatedly read the '/etc/TZ' file
++ (/etc/TZ) Path to the 'TZ' file for setting the global timezone
** Networking Support
-- IP version 6 Support
++ Remote Procedure Call (RPC) support
++ Full RPC support
其它不用改了。
b. CFLAG=-nostdinc make CROSS=arm-elf-
c. make PREFIX=/toolchain/arm/arm-elf DEVEL_PREFIX=/ install
d. cd /toolchain/arm/arm-elf
d. ln -s include sys-include

- 記得要加 CFLAG=-nostdinc,讓 arm-elf-gcc 只用 uClibc 本身的 include 而不會去找 newlib 的 include,會相衝的。
創作者介紹

邱小新の工作筆記

台南小新 發表在 痞客邦 PIXNET 留言(0) 人氣()