Binutils-2.17 | gcc-4.1.1 | glibc-2.5 for cross compiler record highlights

Source: Internet
Author: User
Binutils-2.17 | gcc-4.1.1 | glibc-2.5 for cross compiler record points-Linux general technology-Linux technology and application information, the following is a detailed reading. Author: iibull email: iibull@yahoo.com.cn nick: Daniel @ FUZHOU 20080515
If you need to reprint it, please indicate the author's source.

Tossing a day, finally get the arm-linux-gcc4.11. The record is as follows. By the way, I wish my daughter a happy birthday.

On the homepage, prepare the software packages for compilation:
Software Package
Http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2 wget-c
Http://ftp.gnu.org/gnu/gcc/gcc-4.1.1/gcc-4.1.1.tar.bz2 wget-c
Http://ftp.gnu.org/gnu/glibc/glibc-2.5.tar.bz2 wget-c
Http://ftp.gnu.org/gnu/glibc/glibc-ports-2.5.tar.bz2 wget-c
Http://ftp.gnu.org/gnu/gdb/gdb-6.6.tar.bz2 wget-c
Wget-c http://www.kernel.org/pub/linux/kernel/v2.6/source code file and patch

Patches
Wget http://svn.cross-lfs.org/svn/rep... ioperm_fix-1.patch
Wget http://svn.cross-lfs.org/svn/rep... anch_update-3.patch
Wget http://svn.cross-lfs.org/svn/rep... cross_hacks-1.patch
Wget http://svn.cross-lfs.org/svn/rep... cross_hacks-2.patch
Wget http://svn.cross-lfs.org/svn/rep... 5-hppa_nptl-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 5-libgcc_eh-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 5-libgcc_eh-2.patch
Wget http://svn.cross-lfs.org/svn/rep... ef_segfault-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 5-mawk_fix-1.patch
Wget http://svn.cross-lfs.org/svn/rep... mips_fixes-1.patch

Wget http://svn.cross-lfs.org/svn/rep... cc-4.1.1-32-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 1.1-PR20425-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 1.1-PR29114-1.patch
Wget http://svn.cross-lfs.org/svn/rep... earch_paths-1.patch
Wget http://svn.cross-lfs.org/svn/rep... c-4.1.1-n32-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 4.1.1-posix-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 1.1-pure64-1.patch
Wget http://svn.cross-lfs.org/svn/rep... ure64_specs-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 1-sparc_tls-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 4.1.1-specs-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 1-specs_n32-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 1.1-uclibc-1.patch

Wget http://svn.cross-lfs.org/svn/rep... anch_update-1.patch
Wget http://svn.cross-lfs.org/svn/rep... anch_update-2.patch
Wget http://svn.cross-lfs.org/svn/rep... anch_update-3.patch
Wget http://svn.cross-lfs.org/svn/rep... ts_multilib-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 17-hppa_tls-1.patch
Wget http://svn.cross-lfs.org/svn/rep...-2.17-posix-1.patch
Wget http://svn.cross-lfs.org/svn/rep... 2.17-uclibc-1.patch


Install some software packages that may be required:
Sudo apt-get install bison flex texinfo gawk

Working directory of the entire compilation process:
Sudo mkdir/crosstool
Sudo chmod a + rwx/crosstool
Cd/crosstool
Mkdir linux-2.6.20
Mkdir-p src/patches

Linux-2.6.20 to store the kernel header files to use, patches to store the required patches, src to store the software package PS: after the completion of the compilation of files will be installed ~ /Arm-linux

Set some environment variables (~ /. Bashrc)
Export CLFS_HOST = "$ (echo $ MACHTYPE | sed" s/$ (echo $ {MACHTYPE} | cut-d--f2)/cross /")"
Export CLFS_TARGET = "arm-linux"
Export CLFS =/crosstool/arm-linux
Export PATH = $ CLFS/bin: $ CLFS/cross-tools/bin: $ PATH
Unset CFLAGS
Unset CXXFLAGS

Source ~ /. Bashrc to make it take effect

New header file storage address
Install-dv $ CLFS/include
Install-dv $ CLFS/usr
Install-dv $ CLFS/usr/include

Install the kernel header file:
Create a directory for saving the header file and generate a linux/version. h file to indicate the kernel version. If this file is missing, an error will occur during subsequent compilation.
Install-dv $ {CLFS}/usr/include
Cd linux-2.6.20
Make include/linux/version. h

Copy necessary header files and system structure (arm)-related header files
Install-dv $ {CLFS}/usr/include
Cp-av include/{asm-generic, linux, mtd, scsi, sound }$ {CLFS}/usr/include
Cp-av include/asm-arm $ {CLFS}/usr/include/asm



Compile binutils-2.17:
# Install necessary patches
Cd src
Tar jxvf binutils-2.17.tar.bz2
Cd binutils-2.17
Patch-Np1-I ../patches/binutils-2.17-posix-1.patch (do not mess up the patch, otherwise make will not succeed)


Create a compilation directory:
Mkdir-v ../binutils-build
Cd ../binutils-build

Configure:
.. /Binutils-2.17/configure -- prefix =$ {CLFS}/cross-tools -- host =$ {CLFS_HOST} -- target =$ {CLFS_TARGET} -- with-sysroot =$ {CLFS} -- disable -nls -- enable-shared -- disable-multilib

Compile binutils:
Make configure-host
Make

Install binutils to $ {CLFS}/cross-tools:
Make install

Open $ {CLFS}/cross-tools/bin, and many files starting with "arm-linux-" are generated.

The following header file will be used in the future, so install it in include:
Cp-v ../binutils-2.17/include/libiberty. h $ {CLFS}/usr/include

Install the header file of glibc to the kernel header file
The header file of glibc is required for compiling glibc, so it must be copied to the kernel header folder.
Cd src
Tar jxvf glibc-2.5.tar.bz2
Cd glibc-2.5

Gcc 3.4.x dependency for glibc
Cp configure {,. orig}
Sed-e's/3.4/3. [0-9]/G' configure. orig> configure

Install arm support for glibc:
Tar-jxvf ../glibc-ports-2.5.tar.bz2
Music v glibc-ports-2.5 ports

Create a compilation directory:
Mkdir-v ../glibc-build_1
Cd./glibc-build_1

Added NPTL thread library support:
Echo "libc_cv_forced_unwind = yes"> config. cache
Echo "libc_cv_c_cleanup = yes"> config. cache
Echo "libc_cv_arm_tls = yes"> config. cache

Specify the installation path:
Echo "install_root =$ {CLFS}"> configparms

Configure
CC = gcc
.. /Glibc-2.5/configure -- prefix =/usr -- host =$ {CLFS_TARGET} -- build =$ {CLFS_HOST} -- with-headers =$ {CLFS}/usr/include -- cache-file = config. cache

Install the glibc header file:
Make install-headers # (vi .. /glibc-2.5/scripts/gen-sorted.awk error 19/59/65 lines of modification code change \ [^ \] To \ [\ ^]) or install gawk Tool

Cp-v bits/stdio_lim.h $ {CLFS}/usr/include/bits
Touch $ {CLFS}/usr/include/gnu/stubs. h
Cp-v ../glibc-2.5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes. h $ {CLFS}/usr/include/bits

Compile static gcc (without glibc) for compiling glibc
Cd src
Tar jxvf gcc-4.1.1.tar.bz2
Cd gcc-4.1.1

Patch:
Patch-Np1-I ../patches/gcc-4.1.1-posix-1.patch
Patch-Np1-I ../patches/gcc-4.1.1-cross_search_paths-1.patch

Create a compilation directory:
Mkdir-v ../gcc-build
Cd ../gcc-build

Configure:
.. /Gcc-4.1.1/configure -- prefix =$ {CLFS}/cross-tools -- host =$ {CLFS_HOST} -- target =$ {CLFS_TARGET} -- disable-multilib -- with-sysroot =$ {CLFS} -- disable-nls -- disable-shared -- enable-distributed ages = c

Compile and install gcc-static
Make all-gcc
Make install-gcc

Compile and install glibc:

Unzip the patch and install the patch:
Cd src
Mkdir glibc_2.5
Tar jxvf glibc-2.5.tar.bz2-C glibc_2.5
Cd glibc_2.5; mv glibc-2.5/*./; rm-rf glibc-2.5/

Gcc 3.4.x dependency for glibc
Cp configure {,. orig}
Sed-e's/3.4/3. [0-9]/G' configure. orig> configure

Tar-jxvf ../glibc-ports-2.5.tar.bz2
Music v glibc-ports-2.5 ports

Patch-Np1-I ../patches/glibc-2.5-libgcc_eh-2.patch
Patch-Np1-I ../patches/glibc-2.5-localedef_segfault-1.patch
Patch-Np1-I ../patches/glibc-2.5-cross_hacks-2.patch

Create a compilation directory:
Mkdir-v ../glibc-build_2
Cd./glibc-build_2

Compile and install:
Echo "libc_cv_forced_unwind = yes"> config. cache
Echo "libc_cv_c_cleanup = yes"> config. cache
Echo "libc_cv_arm_tls = yes"> config. cache
Echo "install_root =$ {CLFS}"> configparms

BUILD_CC = "gcc"
CC = "$ {CLFS_TARGET}-gcc"
AR = "$ {CLFS_TARGET}-ar"
RANLIB = "$ {CLFS_TARGET}-ranlib"
.. /Glibc_2.5/configure -- prefix =/usr -- libexecdir =/usr/lib/glibc -- host =$ {CLFS_TARGET} -- build =$ {CLFS_HOST} -- disable-profile -- enable-add -ons -- with-tls -- enable-kernel = 2.6.0 -- with-_ thread -- with-binutils =$ {CLFS}/cross-tools/bin -- with-headers =$ {CLFS}/usr/include -- cache-file = config. cache

Install the glibc header file:
Make install-headers # (if mawk is used, an error will be sent. Modify vi .. /glibc-2.5/scripts/gen-sorted.awk error 19/59/65 lines of modification code change \ [^ \] To \ [\ ^]) or install gawk Tool

Cp-v bits/stdio_lim.h $ {CLFS}/usr/include/bits
Touch $ {CLFS}/usr/include/gnu/stubs. h
Cp-v ../glibc_2.5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes. h $ {CLFS}/usr/include/bits

Make
Make install

Configure glibc
Cat >$ {CLFS}/etc/nsswitch. conf <"EOF"
# Begin/etc/nsswitch. conf

Passwd: files
Group: files
Shadow: files

Hosts: files dns
Networks: files

Protocols: files
Services: files
Ethers: files
Rpc: files

# End/etc/nsswitch. conf
EOF (ctrl + D)

Configure Dynamic Loading for glibc:
Cat >$ {CLFS}/etc/ld. so. conf <"EOF"
# Begin/etc/ld. so. conf

/Usr/local/lib
/Opt/lib

# End/etc/ld. so. conf
EOF (ctrl + D)

Fully install gcc

Add a GCC patch:
Cd./gcc-4.1.1
Patch-Np1-I ../patches/gcc-4.1.1-posix-1.patch
Patch-Np1-I ../patches/gcc-4.1.1-PR20425-1.patch
Patch-Np1-I ../patches/gcc-4.1.1-cross_search_paths-1.patch

Configure:
Cd ../gcc-build

.. /Gcc-4.1.1/configure -- prefix =$ {CLFS}/cross-tools -- host =$ {CLFS_HOST} -- target =$ {CLFS_TARGET} -- disable-multilib -- with-sysroot =$ {CLFS} -- disable-nls -- enable-shared -- enable-languages ages = c, c ++ -- enable-_ cxa_atexit -- enable-c99 -- enable-long -- enable-threads = posix

Compile and install gcc:
Make
Make install

Compile gdb
Cd src
Tar jxvf gdb-6.6.tar.bz2
Mkdir gdb-build
Cd gdb-build
.. /Gdb-6.6/configure -- prefix =$ {CLFS}/cross-tools -- host =$ {CLFS_HOST} -- target =$ {CLFS_TARGET} -- with-sysroot =$ {CLFS} -- enable -threads = posix -- enable-long

Make
Make install


Pack and compress arm-linux-toolchains

Tar cvjf/tmp/arm-linux-toolchains.tar.bz2 \
Cross-tools/arm-linux \
Cross-tools/bin/arm-linux -*\
Cross-tools/bin/genext2fs \
Cross-tools/include/c ++/4.1.1 \
Cross-tools/lib/gcc/arm-linux/4.1.1 \
Cross-tools/libexec/gcc/arm-linux/4.1.1
Related Article

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.