gcc 4.4.3 的編譯器編譯
編譯環境:gcc -versioni686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)Copyright (C) 2007 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. uname -aDarwin Mine.local 12.2.1 Darwin Kernel Version 12.2.1: Thu Oct 18 16:32:48 PDT 2012; root:xnu-2050.20.9~2/RELEASE_X86_64 x86_64
編譯步驟
1.checkout 原始碼
repo init -u https://android.googlesource.com/toolchain/manifestrepo sync
2.checkout 編譯工具到正確的版本查看toolchain下的SOURCE檔案
gcc/ synced to commit 2f2d3b42b0ea0c4871518c7b6176bd2b55ae527d Author: Jing Yu <jingyu@google.com> Date: Mon Dec 13 12:58:16 2010 -0800 And rollback the following two androideabi related patches. commit a4d9421024ed3f70aede5b11f977d264eb69bf61 Author: Jing Yu <jingyu@google.com> Date: Tue Aug 10 10:08:15 2010 -0700 commit f01e65905acd1e2052e875130cb723a658765bc8 Author: Jing Yu <jingyu@google.com> Date: Thu Jul 22 14:39:44 2010 -0700 binutils/ synced to commit 8a5a8339de3149b7f99caf08e9cb72467d60cd01 Author: Jing Yu <jingyu@google.com> Date: Thu Nov 4 17:22:38 2010 -0700 gdb/ synced to commit b028dbaa736a574062136861a11e76a9ab6b4bb3 Author: Jing Yu <jingyu@google.com> Date: Mon Dec 13 14:44:59 2010 -0800 gmp/ synced to commit 9fb242a79dd122d7fbf867daf5620dba6927bd2e Author: Jing Yu <jingyu@google.com> Date: Thu Nov 5 17:43:59 2009 -0800 mpfr/ synced to commit da6dfde986af1b56f0f41e9f5de61d093fa8af90 Author: Jing Yu <jingyu@google.com> Date: Thu Nov 5 17:50:13 2009 -0800 build/ synced to commit 4cc02faaa7e8828f9458b1828a6f85e7791ae2aa Author: Jim Huang <jserv@0xlab.org> Date: Fri Aug 20 23:30:37 2010 +0800 And rollback the following 3 patches. commit de263c26a7680529baca731c003bc58b68d72511 Author: Jing Yu <jingyu@google.com> Date: Thu Aug 12 15:52:15 2010 -0700 commit a80c0ec10d3832039c5d5a481f5f62172eddc929 Author: Jing Yu <jingyu@google.com> Date: Tue Aug 10 10:12:29 2010 -0700 commit f82379147a1d2c484dcc1bb47c4ecd90e40fa3e2 Author: Jing Yu <jingyu@google.com> Date: Thu Jul 22 14:27:24 2010 -0700
按照上述內容check到相應的版本。
3.準備sysroot可以自己先編譯一版android os,只要確保bionic c被編譯即可使用build下的指令碼拷貝到sys root下
./build-sysroot.sh build_out_target_path sysroot_path
4.build gcc建立一個buildgcc目錄,進入該目錄事先可以參照一下google的編譯參數:
arm-eabi-gcc -vUsing built-in specs.Target: arm-eabiConfigured with: /Volumes/project-jingyu/android_toolchain/build/../gcc/gcc-4.4.3/configure --prefix=/usr/local --target=arm-eabi --host=i686-apple-darwin --build=i686-apple-darwin --enable-languages=c,c++ --with-gmp=/Volumes/project-jingyu/toolchain-build/obj/temp-install --with-mpfr=/Volumes/project-jingyu/toolchain-build/obj/temp-install --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --with-abi=aapcs --with-gcc-version=4.4.3 --with-binutils-version=2.19 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 --with-gdb-version=7.1.x --with-arch=armv5te --with-multilib-list=mandroid --with-sysroot=/Volumes/project-jingyu/cupcake_rel_root --enable-gold=both/gold --program-transform-name='s&^&arm-eabi-&'Thread model: singlegcc version 4.4.3 (GCC)
接下來自己自己設定下自己的編譯參數
../build/configure --with-gcc-version=4.4.3 --with-gmp-version=4.2.4 --with-binutils-version=2.19 --with-mpfr-version=2.4.1 --with-sysroot=sysroot_path --prefix=${PWD}/gccinstall --target=arm-eabi --build=x86_64-apple-darwin --with-multi-list=mandroid --enable-gold=both/gold --host=x86_64-apple-darwin --with-gdb-version=7.1.x
本人測試過,binutils的版本不對的話,編譯OS的時候會出錯,是ld的問題 由於mac的gcc 4.2目前預設帶了-Wformat-security參數,編譯binutils會有error,需要改下binutils-2.19的configure檔案在-Wall 後面添加 -Wno-format
make build
5.install
make install
至此android 使用的 arm-eabi-gcc 4.4.3 就編譯完成了