Step by step build mips-linux-gcc-4.4.0 cross-compile tool

Source: Internet
Author: User
Tags gmp

http://blog.sina.com.cn/circlewood2010 Step by step build mips-linux-gcc-4.4.0 Cross compile tool

First, the preparatory work:
Working environment: Host: ubuntu10.04 linux-2.6.32-24-generic i686 gcc-4.4.3
Target machine: MIPS32
Package version: binutils-2.19.1
gcc-4.4.0
glibc-2.9
linux-2.6.29.1
gmp-4.3.0
mpfr-2.4.2
Glibc-2.9-libgcc_eh-1.patch
glibc-ports-2.9
Working Directory:---Home
|---crosstool
|---bin//store the final executable file and Lib
|---headers
|---MIPS
|---4.4.0
|---Bin
|---......
|---binutils//to binutils compilation
|---Build
|---binutils-2.19.1//source
|---gcc
|---Build
|---gcc-4.4.0
|---glibc
|---Build
|---glibc-2.9
|---Linux
|---linux-2.6.29.1
|---qemu//storage simulator


Second, the compilation steps:
1, compile Binutils
Lsq$:cd/home/crosstool/binutils/build EOF
lsq$:.. /binutils-2.19.1/configure--target=mips-linux--prefix=/home/crosstool/bin/mips/4.4.0--disable-nls-- Disable-werror--disable-multilib–enable-shared
Eof
Lsq$:make ALL-GCC && make INSTALL-GCC EOF
Lsq$:make ALL-TARGET-LIBGCC && make INSTALL-TARGET-LIBGCC EOF
done!
Results: Can view the generated executable file in the destination folder. such as: Mips-linux-as
Note: The meaning of each parameter can be viewed binutils install file;
The blue part is necessary and cannot be used only with "make && made Install", otherwise a file error cannot be found;
The red part is necessary and cannot be omitted, otherwise the "-LGCC" error will appear when compiling the glibc.
The specific reason has not been studied clearly.
2, compile Gcc--p1
First, the GMP and MPFR two folders are extracted and renamed to GMP,MPFR and then copied to the GCC source folder.
lsq$:.. /gcc-4.4.0/configure--target=mips-linux--prefix=/home/crosstool/bin/mips/4.4.0/--without-headers--with-newlib- -with-float=soft--with-gnu-as--with-gnu-ld--disable-nls--disable-decimal-float--disable-libgomp-- Disable-multilib--DISABLE-LIBSSP--disable-shared--disable-threads--disable-libmudflap--disable-libstdcxx-pch-- Disable-libffi Enable-languages=c EOF
Lsq$:make && make install EOF
done!
Results: The bin folder will be more MIPS-LINUX-GCC, such as executable program
Add environment variable: Export path= $PATH:/home/crosstool/bin/mips/4.4.0/bin after the terminal input MIPS-LINUX-GCC will prompt "No input file", Otherwise, no installation is successful or the environment variable is not set successfully.
3. Compiling Linux kernel--actually just copying Linux kernel header files
This step is best done after you compile GCC for the first time, or you will be prompted with the "MIPS-LINUX-GCC command does not exist" error--although it may ultimately have little effect on the outcome
lsq$: Make Arch=mips cross_compile=mips-linux-install_hdr_path=/home/crosstool/bin/headers Headers_install
Eof
done!
This step only duplicates the Linux kernel header file, but for a lower version of Linux (such as 2.24) you need to set the parameters and compile the kernel.
4, compile glibc--the most problematic step
Rename the glibc-ports-2.9 to ports and copy it to the GLIBC source folder, which is used primarily for porting to the MIPS architecture.
Important: To GLIBC plus glibc-2.9-libgcc_eh-1.patch patch, otherwise will report "Cannot find-lgcc_eh" error, of course, you can also according to the following site to modify the relevant configuration file: http://trac.cross-lfs.org/ BROWSER/PATCHES/GLIBC-2.9-LIBGCC_EH-1.PATCH?REV=DBB2738D4C11387E45FACEEA1A42CC60FAC752F1 A patch note about LFS, However, manual modification is troublesome and may be changed incorrectly.
Create the Config.cache file under the compilation root and add the following:
Libc_cv_forced_unwind=yes
Libc_cv_c_cleanup=yes
Libc_cv_mips_tls=yes
Libc_cv_gnu99_inline=yes
To increase support for NPTL, you can, of course, add related configuration parameters when configured without adding the file
LSQ$:BUILD_CC=GCC CC=MIPS-LINUX-GCC Ar=mips-linux-ar ld=mips-linux-ld ranlib=mips-linux-ranlib. /glibc-2.9/configure--host=mips-linux target=mips-linux prefix= "/home/crosstool/bin/mips/4.4.0/mips-linux"-- With-headers=/home/crosstool/bin/headers/include--with-binutils=/home/crosstool/bin/mips/4.4.0/bin--with-tls-- With-__thread--enable-sim--ENABLE-NPTL--enable-add-ons--enable-kernel=2.6.29.1--disable-profile-- Without-cvs–cache-file=config.cache EOF
When the compilation is complete, the related files will be generated in the prefix directory.
Note: The network said that need to modify $prefix$/lib/ libc.so file, in fact, the purpose is only to let the LD find the library it needs, so generally remove the folder prefix in the path, leaving only the filename-that is, in the folder where the current file is found;
An error occurred while compiling the FPU related files in math (the error description was not written down ...). , this can be combined with--WITHOUT-FP to avoid this error, and of course, the compiler may have less support for floating-point.
There may also be a variety of errors in this step.
5, compile gcc-p2--the longest time required
As long as there is no error in front of or after the error is not speculative and let it get through the compilation of the step should not be an error.
lsq$:.. /gcc-4.4.0/configure--target=mips-linux--prefix=/home/crosstool/bin/mips/4.4.0/--with-float=soft-- enable-languages=c,c++--enable-threads=posix--enable-c99--enable-long-long--enable-shared--enable-__cxa_atexit --enable-nls--enable-static–with-headers=/home/crosstool/bin/headers/include EOF
Done.
Note: This step must be accompanied by kernel header file parameters (not as in some network data), otherwise the file will not find the error, such as "... /linux/errno.h: The file could not be found. Third, work summary
IV. Reference materials
1, http://hi.baidu.com/mynana/blog/item/479eb25183ec2210377abee0.html Baidu Blog
2, "Create Arm Linux cross-compilation Environment" network data, Author: Rangil (Zhuhai) Company

  3, http://hi.baidu.com/i_know_all/blog/item/e53fb2dfb299491e632798f3.html Baidu Blog "Set up arm Cross compilation tool chain under Ubuntu"
  4, http://linux.chinaunix.net/bbs/thread-1044563-1-1.html china-uniux Forum "compiling Arm-linux tool chain"
   5, http://womking.bokee.com/3365467.html "compiling crosstoolchain detailed records" blog China
  6, http:// Trac.cross-lfs.org/browser/patches/glibc-2.9-libgcc_eh-1.patch?rev=dbb2738d4c11387e45faceea1a42cc60fac752f1 Patch from ' Cross Linux from scratch '
  7, http://sourceware.org/ml/libc-ports/2007-06/msg00008.html to Solve a FP problem
  8, http://home.srvee.com/space-2856-do-blog-id-455.html "ARM Linux Cross-compilation Environment tool" About libc.so, and so on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.