- 论坛徽章:
- 0
|
以前都是直接到网上去下载现成的toolchain , 一是权威网站提供的toolchain很权威经典(比如arm-9tdmi-linux-gnu , 还有2.95的那个) ,而是自己也真不会做,以前看过类似的文章, 麻烦的要命, 也觉得没有必要把时间浪费在这上面。
不过通过这两天做toolchain , 我彻底改变看法了。
这个东西还是自己掌握方法是最重要的。 不能依赖别人。
几种情况必须重新生成toolchain(我说的是个大概念,包括glibc和gdb)
1,厂商提供的glibc lib里面没有你需要的库文件.so , 比如locale
你就必须重新编译locale , 我在05年的时候就碰到这个问题, 真不知道咋办。现在知道怎么弄了。
2, 一般的交叉编译器都没有xx-gdb , 比如arm-linux-gdb 或者arm-9tdmi-linux-gnu-gdb
,怎么办? 必须重新编译gdb , 我们现在的toolchain就没有mips-linux-gdb , 所以只要找来gdb-6.5的源码包 , 执行 ./configure --target=mips-linux --prefix=/usr/ && make && make install 就在 /usr/bin/下面生成mips-linux-gdb mips-linux-gdbtui mips-linux-run 三个文件了。
crosstool是个好工具。 省事多了, 为咱们省了不少时间。
下面是一些参考文章。 感兴趣的可以试试。
我的环境:suse-10.3 , gcc version is 4.2。1 ,必须修改一下 crosstool的glibc的patch才能被4.2.1 编译。 我后面会说到。
我用的版本是crosstoll-0.43
下载链接:
我的demo-arm9tdmi.sh
是这样的:
# This script has one line for each known working toolchain
# for this architecture. Uncomment the one you want.
# Generated by generate-demo.pl from buildlogs/all.dats.txt
set -ex
TARBALLS_DIR=$HOME/downloads/
RESULT_TOP=$HOME/crosstool
export TARBALLS_DIR RESULT_TOP
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES
# Really, you should do the mkdir before running this,
# and chown /opt/crosstool to yourself so you don't need to run as root.
mkdir -p $RESULT_TOP
#eval `cat arm9tdmi.dat gcc-3.2.3-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.2.3-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.2.3-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.3.6-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.3.6-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.3.6-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.4.5-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.4.5-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.4.5-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.4.5-glibc-2.3.5.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.4.5-glibc-2.3.5-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.4.5-glibc-2.3.6.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-3.4.5-glibc-2.3.6-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-4.0.2-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-4.0.2-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-4.0.2-glibc-2.3.5.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-4.0.2-glibc-2.3.5-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-4.0.2-glibc-2.3.6.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-4.0.2-glibc-2.3.6-tls.dat` sh all.sh --notest
#eval `cat arm9tdmi.dat gcc-4.1.0-glibc-2.3.2.dat` sh all.sh --notest
eval `cat arm9tdmi.dat gcc-4.1.0-glibc-2.3.2-tls.dat` sh all.sh --gdb
echo Done.
因为我要编译gdb 所以加上 --gdb
有点要注意 ,crosstool 的特点, 每次 执行 demo-arm9tdmi.sh 都把 downloads 目录下面的.tar.bz2 解压到 build目录, 这个很烦。
第一次还行, 第二次编译的时候, 可以加上个 --nounpack 选项(因为第二次build里面已经有源码了,不需要在反复解压了)
版本信息:
[email=bob@BobZhang:~/toolchain/crosstool-0.43]bob@BobZhang:~/toolchain/crosstool-0.43[/email]
> cat gcc-4.1.0-glibc-2.3.2-tls.dat
BINUTILS_DIR=binutils-2.16.1
GCC_CORE_DIR=gcc-3.3.6
GCC_DIR=gcc-4.1.0
GLIBC_DIR=glibc-2.3.2
LINUX_DIR=linux-2.6.15.4
LINUX_SANITIZED_HEADER_DIR=linux-libc-headers-2.6.12.0
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2
GDB_DIR=gdb-6.5
GLIBC_EXTRA_CONFIG="$GLIBC_EXTRA_CONFIG --with-tls --with-__thread --enable-kernel=2.4.18"
源码可以到这里下载: 自己用快车下载吧, 迅雷最好, 把所有网址黏贴到一个文件里面, 可以实现批量下载。
kernel source code:
http://www.cn.kernel.org/pub/linux/kernel/v2.6/2.6.15.4.tar.bz2
glibc:
http://ftp.gnu.org/gnu/glibc/glibc-2.3.2.tar.bz2
glibc-linuxthreads-2.3.2.tar.bz2
http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.3.2.tar.bz2
gcc-3.3.6:
http://ftp.gnu.org/gnu/gcc/gcc-3.3.6/gcc-3.3.6.tar.bz2
gcc-4.1.0
http://ftp.gnu.org/gnu/gcc/gcc-4.1.0/gcc-4.1.0.tar.bz2
http://ep09.pld-linux.org/~mmazur/linux-libc-headers/linux-libc-headers
-
2.6.12.0.tar.bz2
gdb-6.5
http://ftp.gnu.org/gnu/gdb/gdb-6.5.tar.bz2
binutils-2.16.1.tar.bz2
http://ftp.gnu.org/gnu/binutils/binutils-2.16.1.tar.bz2
注意在 suse10.3 发现的一个问题:
就是crosstool 不识别4.2.1 ,configure glibc的时候会出错。
解觉:
看这个patch:
[email=bob@BobZhang:~/toolchain/crosstool-0.43]bob@BobZhang:~/toolchain/crosstool-0.43[/email]
> vi patches/glibc-2.3.2/glibc-2.3.3-allow-gcc-4.0-configure.patch
Fixes following problem building glibc-2.3.3 with gcc-4.0:
checking version of i686-unknown-linux-gnu-gcc ... 4.0.0, bad
checking for gnumake... no
checking for gmake... gmake
checking version of gmake... 3.79.1, ok
checking for gnumsgfmt... no
checking for gmsgfmt... no
checking for msgfmt... msgfmt
checking version of msgfmt... 0.11.4, ok
checking for makeinfo... makeinfo
checking version of makeinfo... 4.3, ok
checking for sed... sed
checking version of sed... 4.0.5, ok
checking for autoconf... autoconf
checking whether autoconf works... yes
configure: error:
*** These critical programs are missing or too old: gcc
--- glibc-2.3.3/configure.old Mon Mar 14 12:01:10 2005
+++ glibc-2.3.3/configure Mon Mar 14 12:02:03 2005
@@ -3899,7 +3899,7 @@
ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcygnustpi-]*[0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
- 3.[2-9]*)
+ 3.[2-9]*|4.[012]*) //这里多加个2 就行了。
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
还可以参考这里:
http://blog.chinaunix.net/u2/72383/showart_1076976.html
其他的参考:
交叉编译
这个链接是最经典的, 我就是基本按照这个做的。
http://hi.baidu.com/fcni_cn/blog/item/a56498fb52257b274f4aeabc.html/cmtid/709533d87ba3673032fa1c27
在 Fedora 下建立 ARM-Linux 交叉编译环境_Scorpio's CyberSpace - Computer technology
为S3C2410建立arm-linux交叉编译环境 gcc-4.1.1-glibc-2.3.2-Linux -idc中文资讯站-客观公证的IDC产业权威媒体,关注域名、虚拟主机、服务器、网络、开源技术资讯,整合运营商资源,客观评价各地机房带宽线路质量、IDC企业名录等信息
ARM Linux 交叉编译 工具链 制作攻略 - 建立ARM-Linux交叉编译环境 - Tekkaman Ninja
crosstool编译过程中gcc版本问题 - toolchain - osama123
dd
https://www6.software.ibm.com/developerworks/education/l-cross/l-cross-ltr.pdf
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/22617/showart_1710629.html |
|