Compiling ARM-LINUX-GCC 4.8.2

Source: Internet
Author: User
Tags gcov gmp

When compiling GCC,

Main references from http://blog.csdn.net/mcy_cool/article/details/17047027

Modified for some reason, marked red place for the modified place

Compilation Environment:
Kernel Name: Linux
Hardware schema name: i686
Hardware platform: I386
Operating system: Ubuntu 13.10
Current system GCC version number: 4.8.1

Target Platform OK6410:ARM11

First, the preparatory work

1. Download the source package

binutils-2.23.1.tar.bz2

gcc-4.8.2.tar.bz2
glibc-2.18.tar.bz2
glibc-linuxthreads-2.5.tar.bz2
gdb-7.6.1.tar.bz2
Linux-2.6.34.14.tar.xz
mpfr-3.1.2.tar.bz2
Mpc-1.0.1.tar.gz
gmp-5.1.3.tar.bz2

2. Prepare the SOFTWARE Environment
#apt-get Install Xz-utils
#apt-get Install M4
#apt-get Install Libncurses-dev
#apt-get Install g++
#apt-get Install Gawk

3, set the environment variables (recommended to be modified directly in the ~/.BASHRC, note that after the change to make the variable effective)
#vim ~/.BASHRC
Export Target=arm-linux-gnueabi
Export prefix=/usr/local/arm/4.8.2
Export target_prefix= $PREFIX/$TARGET
Export path= $PATH: $PREFIX/bin
#source ~/.BASHRC
4, for host installation MPFR, MPC, GMP
#tar-XJVF gmp-5.1.3.tar.bz2
#cd gmp-5.1.3
#mkdir Build && CD Build
#.. /configure--prefix=/usr/local/gmp--build=x86_64-linux-gnu
#make
#make Install

#tar-XJVF mpfr-3.1.2.tar.bz2
# CD mpfr-3.1.2
#.. /configure--build=x86_64-linux-gnu--PREFIX=/USR/LOCAL/MPFR--with-gmp=/usr/local/gmp
#make
#make Install

#tar-XZVF mpc-1.0.1.tar.gz
#cd mpc-1.0.1
#mkdir Build && CD Build
#.. /configure--build=x86_64-linux-gnu--PREFIX=/USR/LOCAL/MPC--with-gmp=/usr/local/gmp--WITH-MPFR=/USR/LOCAL/MPFR
#make
#make Install
5. Copy Linux-kernel-headers
#xz-D Linux-2.6.34.14.tar.xz
#tar-XVF Linux-2.6.34.14.tar
#cd linux-2.6.34.14
#make Menuconfig
Do not make changes and exit directly.
#make Include/linux/version.h
#mkdir-P $TARGET _prefix/include
#cp-R./include/linux/$TARGET _prefix/include
#cp-R./include/asm-generic/$TARGET _prefix/include
#cp-R./arch/arm/include/asm/$TARGET _prefix/include
Then go to the appropriate directory to see if the Version.h file was established successfully.

Second, compiling binutils
#tar-XJVF binutils-2.23.1.tar.bz2
#cd binutils-2.23.1
#mkdir Build && CD Build
#.. /configure--prefix= $PREFIX--target= $TARGET
#make
#make Install
When you are done, go to $prefix to check the generated tools.
# CD $PREFIX/bin
# LL
The following files are available:
arm-linux-addr2line*
arm-linux-ar*
arm-linux-as*
arm-linux-c++filt*
arm-linux-elfedit*
arm-linux-gprof*
arm-linux-ld*
arm-linux-ld.bfd*
arm-linux-nm*
arm-linux-objcopy*
arm-linux-objdump*
arm-linux-ranlib*
arm-linux-readelf*
arm-linux-size*
arm-linux-strings*
arm-linux-strip*
The resulting files have the following effects:
Arm-linux-addr2line: Turn the address you're looking for into a file and line number, and it's going to use the debug information
Arm-linux-ar: Generating, modifying, and unlocking an archive file
Arm-linux-as:gnu's Assembler
Arm-linux-c++filt:c++ and Java have an overloaded function, the overloaded function used by the end will be compiled into the assembly of the standard, c++filt is to achieve this reverse conversion, according to the label to get the function name
Arm-linux-elfedit: Use temporarily unknown
ARM-LINUX-GPROF:GNU Assembler Pre-compiler
The ARM-LINUX-LD:GNU connector
ARM-LINUX-LD.BFD: Use temporarily unknown
ARM-LINUX-NM: Lists the symbol and corresponding address of the target file
Arm-linux-objcopy: Convert a target file in one format to a different format target file
Arm-linux-objdump: Displays information about the destination file
Arm-linux-ranlib: An index is generated for an archive file, and the index is stored in an archive file
Arm-linux-readelf: Displays information about the target file in elf format
Arm-linux-size: Displays the size of each section of the target file and the size of the target file
Arm-linux-strings: Prints a string that can be printed in the destination file, with a default length of 4
Arm-linux-strip: Stripping all symbolic information from the target file

Third, establish the initial compiler (without GLIBC support)
#tar-XJVF gcc-4.8.2.tar.bz2
Re-unzip mpfr-3.1.2.tar.bz2, mpc-1.0.1.tar.gz, gmp-5.1.3.tar.bz2, and rename to gcc-4.8.2
#rm-rf mpfr-3.1.2 mpc-1.0.1 gmp-5.1.3
#tar-XJVF gmp-5.1.3.tar.bz2
#mv gmp-5.1.3 GMP
#mv./gmp./gcc-4.8.2
#tar-XJVF mpfr-3.1.2.tar.bz2
#mv mpfr-3.1.2 MPFR
#mv./mpfr./gcc-4.8.2
#tar-XZVF mpc-1.0.1.tar.gz
#mv mpc-1.0.1 MPC
#mv./mpc./gcc-4.8.2

#cd gcc-4.8.2
#mkdir Build
#cd Build
#.. /configure--prefix= $PREFIX--target= $TARGET--without-headers--enable-languages=c--disable-threads--with-newlib- -disable-shared--disable-libmudflap--DISABLE-LIBSSP--disable-decimal-float
#make ALL-GCC

#make INSTALL-GCC
#make ALL-TARGET-LIBGCC
#make INSTALL-TARGET-LIBGCC

After completion, $PREFIX/bin a few more files:
arm-linux-cpp*
arm-linux-gcc*
arm-linux-gcc-4.8.2*
arm-linux-gcov*
The resulting files have the following effects:
Arm-linux-cpp:gnu C's pre-compiler
C language Compiler for ARM-LINUX-GCC:GNU
Arm-linux-gcc-4.8.2:gnu C language compiler, in fact, and ARM-LINUX-GCC is the same
ARM-LINUX-GCOV:GCC Auxiliary testing tools for analyzing and optimizing programs

Iv. compiling glibc
GLIBC is the runtime of the cross-compilation environment.

#tar-xvf glibc-2.18.tar.xz
#tar-xvf glibc-linuxthreads-2.5.tar.bz2--directory=./glibc-2.18
# CD glibc-2.18
# mkdir Build
# cd Build
# cc= $TARGET-gcc
#export cflags= " -g-o2-march=arm "
# ln-s/usr/local/arm/4.8.2/lib/gcc/arm-linux-gnueabi/4.8.2/libgcc.a/usr/local/arm/ 4.8.2/LIB/GCC/ARM-LINUX-GNUEABI/4.8.2/LIBGCC_EH.A
Create Config.cache configuration file
# vim Config.cache
Libc_cv_forced_ Unwind=yes
Libc_cv_c_cleanup=yes
Libc_cv_arm_tls=yes
#.. /configure--host= $TARGET--target= $TARGET--prefix= $TARGET _prefix--enable-add-ons--disable-profile--cache-file= Config.cache--with-binutils= $PREFIX/bin--with-headers= $TARGET _prefix/include cc= $TARGET-gcc cflags= "-G o2– March-armv6 "

Note: The CC and cflags to modify will affect the subsequent compilation of GCC, resulting in CC using ARM-LINUX-GCC and cxx using g++ platform different error, where-MARCH-ARMV6 is 6410 ARM11 instruction set used
#make All
#make Install
V. Build a full set of compilers (fully GCC)
# CD gcc-4.8.2/build/
# RM-RF *
# .. /configure--prefix= $PREFIX--target= $TARGET--enable-shared--enable-languages=c,c++--with-arch=armv6–with-cpu= Arm1176jzf-s–with-tune=arm1176jzf-s–with-fpu=vfp

Description: 6410 contains the floating-point processor, adds it when compiling gcc, and the ARM11 architecture is the ARMV6 instruction set.
# make
# make Install

After completion, $PREFIX/bin a few more files:
arm-linux-c++*
arm-linux-g++*
The resulting files have the following effects:
C + + compiler for ARM-LINUX-G++:GNU
Arm-linux-c++: Equivalent to arm-linux-g++

Vi. compiling GDB
# TAR-XVF GDB-7.6.1.TAR.BZ2

#./configure--prefix= $PREFIX--target= $TARGET

Description: Red should be added, original error
# make
# make Install
Vii. Creating Links
# CD $PREFIX/bin
# ln-s Arm-linux-gnueabi-addr2line Arm-linux-addr2line
# ln-s Arm-linux-gnueabi-ar Arm-linux-ar
# ln-s Arm-linux-gnueabi-as Arm-linux-as
# ln-s Arm-linux-gnueabi-c++ arm-linux-c++
# ln-s Arm-linux-gnueabi-c++filt arm-linux-c++filt
# ln-s Arm-linux-gnueabi-cpp Arm-linux-cpp
# ln-s Arm-linux-gnueabi-elfedit Arm-linux-elfedit
# ln-s arm-linux-gnueabi-g++ arm-linux-g++
# ln-s ARM-LINUX-GNUEABI-GCC ARM-LINUX-GCC
# ln-s arm-linux-gnueabi-gcc-4.8.2 arm-linux-gcc-4.8.2
# ln-s Arm-linux-gnueabi-gcov Arm-linux-gcov
# ln-s Arm-linux-gnueabi-gdb arm-linux-gdb
# ln-s Arm-linux-gnueabi-gdbtui Arm-linux-gdbtui
# ln-s Arm-linux-gnueabi-gprof arm-linux-gprof
# ln-s Arm-linux-gnueabi-ld Arm-linux-ld
# ln-s ARM-LINUX-GNUEABI-LD.BFD ARM-LINUX-LD.BFD
# ln-s ARM-LINUX-GNUEABI-NM arm-linux-nm
# ln-s Arm-linux-gnueabi-objcopy arm-linux-objcopy
# ln-s Arm-linux-gnueabi-objdump Arm-linux-objdump
# ln-s Arm-linux-gnueabi-ranlib Arm-linux-ranlib
# ln-s Arm-linux-gnueabi-readelf arm-linux-readelf
# ln-s Arm-linux-gnueabi-run Arm-linux-run
# ln-s Arm-linux-gnueabi-size arm-linux-size
# ln-s Arm-linux-gnueabi-strings arm-linux-strings
# ln-s Arm-linux-gnueabi-strip Arm-linux-strip
Viii. Verification
Use Vim to write a simple file, here hello.c for example (Cheng):

Then execute the compile command:
# arm-linux-gcc-static Hello.c–o Hello
Validates the final compiled file after compilation is complete. Instance:
# file Hello
Hello:elf 32-bit LSB executable, ARM, version 1, statically linked, for Gnu/linux 2.0.0, not stripped
As above output indicates the success of compiling the arm version of the program.

This completes.

GCC Settings for 6410

Http://www.arm9home.net/simple/index.php?t7832.html

http://www.crifan.com/find_s3c6410_march_macpu_mtune_mfpu_mfloat_abi/, the principle is correct, configuration has a problem, or refer to the above address

Build a cross-compilation environment (arm-linux-gcc-4.6.1 version) in Ubuntu11.04, http://my.oschina.net/u/225867/blog/38473

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.