編譯linaro-gcc工具鏈

原文地址:http://blog.chinaunix.net/uid-24943863-id-3997047.html

關於linaro參見其官網www.linaro.org
gcc-linara源碼可以從這個網址下載 http://launchpad.net/gcc-linaro/+milestone/4.8-2013.10
gcc的編譯依賴於幾個庫,GMP,MPFR,MPC,首先需要編譯他們,從ftp://gcc.gnu.org/pub/gcc/infrastructure/ 下載這幾個庫的源代碼。
1. 編譯GMP  ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
解壓後使用標準的GNU源碼編譯方法
./configure  --prefix=/home/yangtze/tools/gmp
make
make install
--host指定的是編譯所用主機類型
2. 編譯MPFR  ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
./configure  --prefix=/home/yangtze/tools/mpfr --with-gmp=/home/yangtze/tools/gmp
make && make install
3.編譯MPC  ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
./configure --prefix=/home/yangtze/tools/mpc --with-gmp=/home/yangtze/tools/gmp --with-mpfr=/home/yangtze/tools/mpfr
make && make install
4.編譯isl 下載地址 http://isl.gforge.inria.fr/isl-0.12.tar.gz
./configure --prefix=/home/yangtze/tools/isl --with-gmp-prefix=/home/yangtze/tools/gmp
make && make install
5.編譯cloog  下載地址 http://www.bastoul.net/cloog/pages/download/count.php3?url=./cloog-0.18.1.tar.gz
./configure  --prefix=/home/yangtze/tools/cloog --with-gmp-prefix=/home/yangtze/tools/gmp
make && make install
6.編譯libelf   下載地址 http://www.mr511.de/software/libelf-0.8.9.tar.gz
 ./configure --prefix=/home/yangtze/tools/libelf
make && make install
7.編譯binutils http://releases.linaro.org/13.10/components/toolchain/binutils-linaro
./configure --prefix=/usr/local/linaro-gcc --with-sysroot=/usr/local/arm-linux/arm-linux-gnueabi/libc --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --with-gmp=/home/yangtze/tools/gmp --with-isl=/home/yangtze/tools/isl  --with-mpfr=/home/yangtze/tools/mpfr --with-mpc=/home/yangtze/tools/mpc
make 
sudo make install
加上--with-sysroot是很重要的,否則編譯gcc的時候會出現“ld:this linker was not configured to use sysroots”的錯誤。
8. 安裝內核頭文件
解壓內核並cd到源碼目錄,執行下面的命令構建sanitized 版本內核頭文件。
make ARCH=arm headers_check
 sudo make ARCH=arm INSTALL_HDR_PATH=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr headers_install
9. 編譯c庫頭文件  eglibc  http://releases.linaro.org/13.10/components/toolchain/eglibc-linaro/eglibc-linaro-2.18-2013.10.tar.bz2
mkdir build
CC=gcc ../configure  --prefix=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr --build=x86_64-linux-gnu --host=arm-linux-gnueabi --with-header=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr/include 
sudo make install-headers
注意這裏設置的--host是目標板,與其他地方的不一樣。
內核頭文件和C庫頭文件放在sysroot下,消除缺少頭文件的問題“The directory that should contain system headers does not exist” 。
10.編譯用於編譯glibc的gcc
解壓gcc-linara,cd到源碼目錄
mkdir build
cd build
../gcc-linaro-4.8-2013.10/configure --prefix=/usr/local/arm-linux --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --with-gmp=/home/yangtze/tools/gmp 
 --with-mpfr=/home/yangtze/tools/mpfr --with-mpc=/home/yangtze/tools/mpc --with-isl=/home/yangtze/tools/isl --with-cloog=/home/yangtze/tools/cloog 
--with-libelf=/home/yangtze/tools/libelf --enable-languages=c,c++,fortran --enable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard 
--enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-gold  --enable-c99 
--enable-long-long --with-mode=thumb --with-sysroot=/usr/local/linaro-gcc/arm-linux-gnueabi/libc --with-local-prefix=/usr/local/linaro-gcc/arm-linux-gnueabi/libc
make -j4




到這裏配置出錯了
checking for version 0.10 of ISL... no
checking for version 0.11 of ISL... no
checking for version 0.12 of ISL... no
configure: error: Unable to find a usable ISL.  See config.log for details.
打開config.log
configure:5857: checking for version 0.10 of ISL
configure:5876: x86_64-linux-gnu-gcc -o conftest -g -O2 -I/home/yangtze/tools/isl/include -I/home/yangtze/tools/gmp/include -I/home/yangtze/tools/mpfr/include -I/home/yangtze/tools/mpc/include    -L/home/yangtze/tools/isl/lib conftest.c  -lisl >&5
configure:5876: $? = 0
configure:5876: ./conftest
./conftest: error while loading shared libraries: libisl.so.10: cannot open shared object file: No such file or directory
configure:5876: $? = 127
configure: program exited with status 127
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h.  */
| #include 
|    #include 
| int
| main ()
| {
| if (strncmp (isl_version (), "isl-0.10", strlen ("isl-0.10")) != 0)
|      return 1;
|
|   ;
|   return 0;
| }
configure:5885: result: no
configure:5905: checking for version 0.11 of ISL
configure:5924: x86_64-linux-gnu-gcc -o conftest -g -O2 -I/home/yangtze/tools/isl/include -I/home/yangtze/tools/gmp/include -I/home/yangtze/tools/mpfr/include -I/home/yangtze/tools/mpc/include    -L/home/yangtze/tools/isl/lib conftest.c  -lisl >&5
configure:5924: $? = 0
configure:5924: ./conftest
好吧,是加載動態庫的時候出問題了。
 sudo vim /etc/ld.so.conf.d/ld.isl.so.conf
將isl的lib庫的絕對路徑寫入ld.isl.so.conf文件中 /home/yangtze/tools/isl/lib
順便將tools目錄下的其他動態庫的路徑都加上
執行下面的命令重建/etc/ld.so.cache
sudo ldconfig
重新來一遍配置gcc-linara。
執行make,喝杯咖啡歇會,這是個漫長的過程。
sudo make install


11 編譯eglibc
 CC=arm-linux-gnueabi-gcc ../configure  --prefix=/usr/local/arm-linux/arm-linux-gnueabi/libc/ --build=x86_64-linux-gnu --host=arm-linux-gnueabi 
--with-header=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr/include --enable-add-ons --with-binutils=/usr/local/arm-linux/bin --enable-shared libc_cv_forced_unwind=yes 
libc_cv_c_cleanup=yes
make 
sudo make install


好吧,現在工具鏈已經編譯完成,下一步是使用該工具鏈編譯uboot和kernel。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章