Detailed introduction to creating a PowerPC cross compiler based on the newlib Library

Source: Internet
Author: User

The introduction to PowerPC's cross-compilation tool is indeed not as much as that of arm. Previously, ELDK was used for a great deal of effort, but it was too big and inconvenient to use. Therefore, I have reprinted this article, and I will keep it for later study.

 

If you need to reprint it, please attach my space address to your location. Thank you.

Http://blog.csdn.net/pro_or_gram/article/details/6642079

 

Production of PowerPC cross compiler based on newlib Library

Stage 1: Preparation

Create four directories cross_source, cross_configure, cross_build, and cross_archives on the d drive of the computer.

The cross_archives directory contains the downloaded binutils, GCC, and newlib compressed packages.

{

Binutils-2.21.tar.bz2

Gcc-core-4.1.1.tar.bz2

Newlib-1.14.0.tar

}

 

The cross_source directory is used to store the files extracted from the compressed package. You can manually decompress the files or decompress the files under the cygwin command.

{

Binutils-2.21

Gcc-4.1.1

Newlib-1.14.0

}

The cross_configure directory is used to store configuration information for binutils, GCC, newlib,/configure, and makefile.

{

Binutils

Gcc

Newlib

}

The cross_build directory will be used to store the files after binutils, GCC, and newlib make compilation.

{

// The following files are all compiled and generated, not manually created

Bin

Include

Info

Lib

Libexec

Man

PowerPC-elf

Share

}

 

Stage 2: Steps for creating a cross-compilation tool

Step 1: Compile binutils

(1) $ CD/cygdrive/D/cross_source/* This path should be empty */

(2) $ tar xvjf/cygdrive/D/cross_archives/binutils-2.16.1.tar.bz2

/* This command stores the extracted files in the current directory, that is, the/cygdrive/D/cross_source directory. If you manually extract the files, skip this step */

(3) $ CD/cygdrive/D/cross_configure/binutils

/* Enter the directory for storing configure information, which corresponds to binutils in cross_source (4) remote access to the configure file under the binutils-2.21 in cross_source directory

$/Cygdrive/D/cross_source/binutils-2.21/configure -- prefix =/cygdrive/D/cross_build -- target = PowerPC-elf

/* -- Prefix =/cygdrive/D/cross_build: Specifies the path for storing the files after make compilation */

(5) $ make 2> & 1 | tee make. Log

(6) $ make install 2> & 1 | tee install. Log

 

Step 2: Compile gcc

(1) Before compiling GCC, add the new environment variable path, "ensure that the GNU binary utilities, e.g. PowerPC-elf-ar are at the head of the path ."

Command: $ Path =/cygdrive/D/cross_build/bin: $ path

Run the command $ echo $ path. If/usr/local/bin: [...] Or/opt/Cross/bin: [...] appears,

It indicates that it is successfully added.

(2) $ CD/cygdrive/D/cross_configure/GCC

/* Enter the directory used to store configure information. It corresponds to GCC in cross_source.

(3) remotely access the configure file under the gcc-4.1.1 in the cross_source directory

$/Cygdrive/D/cross_source/gcc-4.1.1/configure -- prefix =/cygdrive/D/cross_build -- target = PowerPC-elf -- With-GNU-as -- With-GNU-LD -- -newlib -- disable-shared -- enable-extensions ages = c -- disable-libssp

/* The prefix must point to the same path as the binutils compiling path. That is, when binutils and GCC are compiled and installed, the prefix is the same parameter setting */

(4) $ make 2> & 1 | tee make. Log

(5) $ make install 2> & 1 | tee install. Log

Note: not all -- disable-libssp options need to be set. In this version of GCC, you must set for -- disable-libssp (stack protector Support) See GCC Bugzilla bug 25035. anyhow, the stack protector support is not needed for Embedded standalone applications.

Now PowerPC-elf is installed, but no header files are present. Until now it is only usable for Embedded standalones which provide their own header files.

 

Step 3: Compile newlib

The -- prefix option is not supported when newlib is configured.

(1) $ CD/cygdrive/D/cross_configure/newlib

/* Enter the directory used to store configure information. It corresponds to newlib in cross_source.

(2) remotely access the configure file under the newlib-1.14.0 in the cross_source directory

$/Cygdrive/D/cross_source/newlib-1.14.0/configure -- target = PowerPC-elf 2> & 1 | tee configure. Log

(3) After configure runs OK, view the MAKEFILE file in/cygdrive/D/cross_configure/newlib and search for makeinfo. If the following information is found:

Makeinfo =/cygdrive/D/package_source/newlib-1.14.0/missing makeinfo

Make sure that texinfo is installed in the cygwin environment.

The command is $ cygcheck-C texinfo.

If shown as follows:

Cygwin package information

Package version status

Textinfo 4.13-3 OK

The installation is successful. If no installation is displayed, run the cygwininstaller setup.exe to install texinfo.

If the installation is successful, and the information in makefile is

Makeinfo =/cygdrive/D/package_source/newlib-1.14.0/missing makeinfo

Modify makeinfo, comment out the original line, and add a new line:

Makeinfo =/bin/makeinfo

If you do not modify it, the following message appears during make newlib.

Warning: 'makeinfo' is missing on your system. You shoshould only need it if

You modified a '. texi' or'. texinfo' file, or any other file

Indirectly affecting the aspect of the Manual. The spurious

Call might also be the consequence of using a buggy 'make' (Aix,

Du, IRIX). You might want to install the 'textinfo' package or

The 'gnu make' package. Grab either from any GNU archive site.

(4) Make 2> & 1 | tee make. Log

(5) make install 2> & 1 | tee install. Log

So far, binutils GCC and newlib have been compiled, and the cross compiler has been created successfully.

 

Highlights of problems during compilation:

(1) problems with the configure:/bin/sh: Bad Interpreter: Permission denied class,

Solution:

You can try to use setup.exe to reinstall shell interpreters such as Bash.

(2) As: Unrecognized option '-mppc', for example, as: Unrecognized option'-G'

The trick is to always build the cross-binutils * First * and install

Them before trying to configure/build the cross-GCC, because GCC needs

A working cross-worker er to build its runtime.

Solution: create four directories to save different files and configuration information, as described in the preceding steps.

(3) When the tar command is decompressed, cannot change ownership to uid *** and GID *** appears ***

Solution:

Use the -- no-same-permissions parameter option of the tar command or try the -- no-same-owner options parameter option.

Tar -- no-same-permissions-xvjf/cygdrive/e/cross_archives/binutils-2.21.tar.bz2

Alternatively, use the following command in quotation marks under the cygwin command line:

"Chown $ user/cygdrive/D"

This command adds the/cygdrive/d path to the user's accessible permissions.

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.