Arm-Linux-GCC 4.3.2 compilation and Installation Process

Source: Internet
Author: User
Tags gmp

Arm-Linux-GCC 4.3.2 compilation and Installation Process

 

This article was corrected by "my arm-GCC tool compilation and installation process". The red text is different from the original one. I hope it will help you.

Address: http://szyou.tiao.blog.163.com/blog/static/28351497200902193223687/

 

My compiling environment is in ubuntu8.10 amd64. The GCC version is 4.3.2 and the compiled Linux kernel version is 2.6.8. Therefore, you need to modify a few kernel header files later.

Check that the environment contains texinfo, gawk (note that there is a problem when mawk compiles glibc headers), Bison, and flex. install them if none of them exist.
> Sudo apt-Get install texinfo gawk bison flex

The working directory is under the user directory
Put the source file in the directory cross_source.
The compiled working directory is cross_build.

Xxx contains the decompressed source code, such as binutils-2.19.tar.bz2, decompress it on the binutils-2.19
Xxx_build is used for the compilation of directories, such as binutils-2.19.tar.bz2, the compilation directory is a binutils-2.19_build

The file used is
Binutils-2.19.tar.bz2
Gcc-core-4.3.2.tar.bz2
Gcc-g00000000-4.3.2.tar.bz2
Mpfr-2.3.2.tar.bz2
Gmp-4.2.4.tar.bz2
Linux-2.6.28.tar.bz2
Glibc-ports-2.7.tar.bz2
Glibc-2.7.tar.bz2

First create a directory
> Mkdir cross_source
> Mkdir cross_build
> Cd cross_build

1. Compile and install binutils
During binutils configuration and compilation and installation, binutils compilation generally does not encounter any problems, at least I have not encountered any problems.
> Sudo apt-Get install texinfo
> Tar-jxvf ../cross_source/binutils-2.19.tar.bz2
Modify the tc-arm.c according to [bug gas/7026] New: arm target wont build, error: format not a string literal and no format arguments
> Mkdir binutils-2.19_build
> Cd binutils-2.19_build
> ../Binutils-2.19/configure -- target = arm-Linux -- prefix =/usr/local/ARM/4.3.2
> Make
> Sudo make all install
This will install the binutils compilation result to/usr/local/ARM/4.3.2 /.
After binutils is installed, export the path.
> Export Path = $ path:/usr/local/ARM/4.3.2/bin
> Export Path = $ path:/usr/local/ARM/4.3.2/ARM-Linux

2. Install GCC during the first compilation
<GCC is compiled for the first time only to generate a compilation tool for target. Therefore, you do not need header files or special attention. Of course, you must meet the requirements of target.>
> Cd .. # Go To cross_build
> Tar-jxvf ../cross_source/gcc-core-4.3.2.tar.bz2
Slave
Starting from the GCC-4.3, installing GCC will depend on both GMP-4.1 and above. If you extract the two packages to the root directory of the GCC source code tree, and
Name "GMP" and "mpfr" respectively, then the GCC Compilation Program will automatically compile the two together with GCC. We recommend that you use the latest GMP and mpfr versions whenever possible.
> Tar-jxvf ../cross_source/mpfr-2.3.2.tar.bz2
> Tar-jxvf ../cross_source/gmp-4.2.4.tar.bz2
> Music mpfr-2.3.2 gcc-4.3.2/mpfr
> MV gmp-4.2.4 gcc-4.3.2/GMP
Both
However, this is the first time that the arm cross-compilation tool is installed. Therefore, glibc on the local machine supports the compilation tool library instead of the arm cross-compilation tool library. Other tools supporting arm cross-Compilation
We do not have the libc library that supports languages (such as C ++ and Java) (the final gcc-generated binary code connection must be supported by this library). Therefore, we need to add the compilation switch:
-- Enable-versions ages = c -- disable-threads -- disable-shared
Similarly, because the arm cross-compilation tool is installed for the first time, the header files of the libc library are not supported! So we acquired dinhibit_libc to solve this problem. The procedure is as follows:
& Gt; CP gcc-4.3.2/GCC/config/ARM/t-Linux ~ /Gcc-3.4.5/GCC/config/ARM/t-linux.orig # Back up (see the following article ** restore backup)
> Vim gcc-4.3.2/GCC/config/ARM/t-Linux
Add operation parameters to target_libgcc2_cflags =
-Dinhibit_libc-D _ gthr_posix_h
Save and exit.
> Mkdir gcc-4.3.2_build
> Cd gcc-4.3.2_build
> ../Gcc-4.3.2/configure
-- Target = arm-Linux -- prefix =/usr/local/ARM/4.3.2 -- disable-threads
-- Disable-shared -- enable-distributed ages = c -- disable-libmudflap
-- Disable-libssp
Because there is no glibc for arm, you need to use -- disable-libmudflap -- disable-libssp to disable the libraries used for the two boundary checks.
> Make all # ignore compilation errors. I didn't pass the compilation, but don't worry. Install it immediately.
> Sudo make install

3. Create a header file, which is mainly a kernel header file. decompress the downloaded Linux Kernel File (if the corresponding ARM Kernel File is better)
> Cd .. # Go To cross_build
> Tar-jxvf ../cross_source/linux-2.6.28.tar.bz2
> Cd linux-2.6.28
> Make arch = arm cross_compile = arm-Linux-menuconfig
Load a 2410 configuration of another user in menuconfig and exit and save it.
> Make arch = arm cross_compile = arm-Linux-# Stop using Ctrl + C in one or two minutes.
@ Copy the kernel header file to the target
> Sudo CP-A include/Linux/usr/local/ARM/4.3.2/include/Linux
> Sudo CP-A include/ASM-arm/usr/local/ARM/4.3.2/include/ASM
> Sudo CP-A include/ASM-generic/usr/local/ARM/4.3.2/include/ASM-generic
# Do not perform the following two steps if the earlier kernel version does not have a file
> Sudo CP-a ARCH/ARM/include/ASM/usr/local/ARM/4.3.2/include
> Sudo CP-a ARCH/ARM/mach-s3c2410/include/Mach/usr/local/ARM/4.3.2/include/ASM

4. Compile glibc
> Cd .. # Go To cross_build
> Tar-jxvf ../cross_source/glibc-2.7.tar.bz2
Install the packages supported by the ARM Kernel
> Tar-jxvf ../cross_source/glibc-ports-2.7.tar.bz2
> MV-V glibc-ports-2.7 glibc-2.7/Ports
> Cd glibc-2.7
Patch
> Patch-Np1-I..././cross_source/glibc-2.7-alpha_ioperm_fix-1.patch
> Patch-Np1-I..././cross_source/glibc-2.7-alpha_PTR_MANGLE_fix-1.patch
> Patch-Np1-I..././cross_source/glibc-2.7-branch_update-1.patch
> Patch-Np1-I..././cross_source/glibc-2.7-branch_update-1A.patch
> Patch-Np1-I..././cross_source/glibc-2.7-libgcc_eh-1.patch
> Patch-Np1-I..././cross_source/glibc-2.7-localedef_segfault-1.patch
Follow these steps:
Originally, some header files were put into another folder starting from gcc4.3, causing glibc to fail to be found and patches glibc configure:
> SED-I-e "/ccheaders =/s @/'/(/$ CC. * include/)/'@/"&-isystem/'/1-fixed/'/" @ "Configure
Another reason is to compile the modified files.
> SED
-I's/# define undocargs_5/tundocargs_4/&/n # define
Docargs_6/tdocargs_5/N # define undocargs_6/tundocargs_5 /'
Ports/sysdeps/Unix/sysv/Linux/ARM/nptl/sysdep-cancel.h
// Do not perform the following steps in the earlier kernel version:
/*
> SED-I's/_ deprecated/_ attribute _ (Deprecated)/'../linux-2.6.27/ARCH/ARM/include/ASM/memory. h

The above File Memory. in H, add the macro config_dram_base and config_dram_size definitions (just define them as needed), and set "<Mach/memory. h> "is" <ASM/Mach/memory. h>"
In the file, ports/sysdeps/Unix/sysv/Linux/ARM/nptl/lowlevellock. H, add the header file # include <TLS. h>
*/

// Added by David. morre, starting from here:

> Cd/usr/local/ARM/4.3.2/include/ASM
> Ln-s arch-s3c2410 Arch
> Cd-# Go To cross_build
Add:
# DEFINE _ arm_nr_set_tls (_ arm_nr_base + 5)

Add row 285:
# DEFINE _ nr_set_tid_address (_ nr_syscall_base + 256)

> Mkdir-V glibc-2.7_build

> Cd glibc-2.7

> Gedit./ports/sysdeps/Unix/sysv/Linux/ARM/nptl/lowlevellock. h

Add a line # include <TLS. h>, save and exit.

> Cd ../glibc-2.7_build

> Sudo gedit ~ /. Bashrc

Add the following export Path = $ path:/usr/local/ARM/4.3.2/bin

(Note: if the path is previously added to the arm-Linux-GCC cross-compilation chain, you need to remove it)
> Cc = arm-Linux-gcc
AR = arm-Linux-ar ranlib = arm-Linux-ranlib./glibc-2.7/configure
-- Host = arm-Linux -- prefix =/usr/local/ARM/4.3.2/ARM-Linux
-- Enable-add-ons -- With-headers =/usr/local/ARM/4.3.2/include
Libc_cv_forced_unwind = Yes libc_cv_c_cleanup = Yes
> Make
> Sudo make install
According to the above method, compilation is successful.

5. Rebuild GCC with the existing cross-compilation tool
> Cd .. # Go To cross_build
Restore the previously modified T-Linux File: **
> Cd gcc-4.3.2/GCC/config/ARM/
> Mv t-Linux-Bak
> Mv t-Linux-org T-Linux
>
Install the C ++ package
> Cd.../# Go To The cross_build folder.
> Tar-jxvf ../cross_source/gcc-g00000000-4.3.2.tar.bz2 # The gcc-core-4.3.2 will be overwritten by GCC-G ++-4.3.2 to add the C ++ Section

CD gcc-4.3.2_build/
> Make clean
> Make distclean

If you need GCC to support C and C ++ programming languages, use the following Configuration:
> ../Gcc-4.3.2/configure
-- Target = arm-Linux -- prefix =/usr/local/ARM/4.3.2
-- Enable-packages ages = C, C ++ -- enable-threads = POSIX -- enable-shared
-- Enable-_ cxa_atexit -- With-local-Prefix =/usr/local/ARM/4.3.2/ARM-Linux
Copy the/usr/local/ARM/4.3.2/include folder to the/usr/local/ARM/4.3.2/ARM-Linux folder.
> Make all
> Sudo make install
Well, the compilation is over. Try your own arm-Linux-GCC tool.

 

 

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.