第三步 编译GCC(第一次)需要的软件包: 编译完成需要时间大概为:1 ~ 1.5小时 软浮点支持因为要支持软浮点(Soft Float),GCC需要同时编译GMP和MPFR。GMP是实现任意精度算术运算的软件包,可以完成有符号整数、有理数和浮点数的运算。只要计算机内存的满足需要,GMP的运算精度没有任何限制。MPFR是一个用于高精度浮点运算的C库。让GCC支持GMP和MPFR有两种方法,一是分别编译安装GMP和MPFR,把路径通过configure告诉GCC,这样在编译GCC的时候就会去找到GMP和MPFR;另一种更简单的方法是把GMP和MPFR源代码拷贝到GCC源代码目录内,两个文件夹分别命名为gmp和mpfr,这样在编译GCC的过程中就会自动去编译GMP和MPFR。我们采用第二种方法,下面的命令把GMP和MPFR源代码移动到GCC目录内:
cd ${SOURCE_DIR} mv ${PACKAGE_GMP} ${PACKAGE_GCC}/gmp mv ${PACKAGE_MPFR} ${PACKAGE_GCC}/mpfr 配置选项第一次编译GCC的作用是生成支持C语言的交叉编译器,目的是用它来交叉编译后面的Glibc库。因为生成完整的GCC交叉编译器需要Glibc库的支持,但是现在还没有用于ARM平台的Glibc库,所以我们先生成一个简化的GCC,用它来编译Glibc,有了Glibc后再重新编译GCC生成完整的ARM-GCC。所以第一次编译GCC的配置选项禁止了很多功能,如下所示: cd ${BUILD_DIR}/${PACKAGE_GCC} ${SOURCE_DIR}/${PACKAGE_GCC}/configure \ --build=${HOST} \ --host=${HOST} \ --target=${TARGET} \ --prefix=${RESULT_DIR} \ --without-headers \ --with-newlib \ --with-float=soft \ --with-cpu=arm920t \ --with-tune=arm9tdmi \ --with-gnu-as \ --with-gnu-ld \ --disable-nls \ --disable-decimal-float \ --disable-libgomp \ --disable-multilib \ --disable-libmudflap \ --disable-libssp \ --disable-shared \ --disable-threads \ --disable-libmudflap \ --disable-libstdcxx-pch \ --disable-libffi \ --enable-languages=c make && make install || exit 1 选项详解BUILD= 是指在什么平台上编译源代码,这个肯定是主机了,x86
-without-headers
--with-newlib \ --with-float=soft \ --with-cpu=arm920t \ --with-tune=arm9tdmi \ --with-gnu-as \ --with-gnu-ld \ --disable-decimal-float \ --disable-libgomp \ --disable-multilib \ --disable-libmudflap \ --disable-libssp \ --disable-shared \ --disable-threads \ --disable-libmudflap \ --disable-libstdcxx-pch \ --disable-libffi \
--disable-shared Disables the creation of the shared libraries. --disable-threads This will prevent GCC from looking for the multi-thread include files, since they haven't been created for this architecture yet. GCC will be able to find the multi-thread information after the Glibc headers are created. --enable-languages=c This option ensures that only the C compiler is built. 注意: 将这GMP和MPFR软件包解压到GCC源码树的根目录下,并分别命名为"gmp"和"mpfr",那么GCC的编译程序将自动将两者与GCC一起编译。这样做了后,不需要加 --with-gmp 和with-mpfr 选项,加了反而会出错:configure: error: in `/home/hongwang/mktoolchain/build/gcc-4.4.0/mpfr': 编译和安装的结果: (待完善) |
|