Centos6.5 from the source code compilation and installation of GCC-4.9.1 full recording of the Second part: compilation, installation, testing

Source: Internet
Author: User
Tags key string posix


Preface

GCC (GNU Compiler Collection, GNU Compiler Collection) is an open-source project on Linux and other UNIX-like platforms, software development and other essential tool chains (other members of the tool chain include binutils, glibc, libstdc ++, etc)

In addition, programmers and System Administrators often need to manually compile and install the software source code, whether it is a configure script or make tool/MAKEFILE file, in the end, GCC (or other compilers) needs to be called for actual compilation. Therefore, it is often necessary to use the new version of GCC and coexist with the old version of GCC to call it based on actual needs.


In this blog, we download the latest GCC source code package from the Internet based on the old GCC binary executable files installed on the centos 32-bit System and the glibc C library, perform simple tests, integrate with the make tool, PASS Parameters from the configure script, and optimize compilation.

The entire process is simple and clear, with graphic and text code. It is expected to play a role in attracting others and stimulate their enthusiasm for programming and learning.


Compilation, installation and testing


We have mentioned many times that GCC should be configured and compiled in a separate directory. Do not make the generated intermediate file contaminated with the source code directory unless you decide to finish the entire installation process, delete the source and compilation directories.

We use the separate compilation directory compile-Dir to store the binary files compiled by the make command, and then run the make install command to copy these files to the final installation directory:

/usr/local/new-exec-gcc-4.9.1


First, go to the compilation directory. Under this directory, call the configure script file under the GCC source code directory in an absolute path, and specify the compilation parameters after it:


--prefix=/usr/local/new-exec-gcc-4.9.1/Is the final installation path mentioned above.


--enable-bootstrap Here we will reference some documents on the Internet to explain this parameter: Use the program generated in the first compilation for the second compilation, and then use the program generated again for the third compilation, check the correctness of the second and third results, that is, the redundant compilation check.

In a non-Cross-compilation environment, this value has been set to enable by default, so you do not need to specify it. In a cross-compilation environment, the value needs to be set to disable.


-- Enable-checking = releaseCheck the consistency of the code generated during compilation based on the software release standard. setting this option to enable does not change the binary result generated by the compiler, but will increase the Compilation Time; this option only supports the GCC compiler;

In general, for the above options, the hardware configuration of the machine is low and the children's shoes that do not want to wait too long for compilation can be set to disable; but this increases the risk of unexpected errors, therefore, use it with caution.

You can set -- disable-bootstrapAnd -- disable-checking, which helps speed up the compilation process.


-- Enable-threads = POSIXAs the name implies, enable POSIX standard thread support

To enable the program to run correctly on a POSIX compliant Linux release, this option should be enabled, depending on the type of the host or target operating system. Other available values include Aix, Dec, solaris, Win32, etc. If you are another Unix-like system, you need to set the corresponding value.


-- Enable-languages ages = C, C ++
Supported advanced language types and runtime libraries. All languages that can be set include Ada, C, C ++, Fortran, Java, objc, obj-C ++, and go. Only C and C ++ are enabled here, because the more languages are supported, the more static and dynamic libraries need to be installed, and a variety of dependent libraries exist, this will make management difficult and the size will become huge.


-- Disable-multilibMany articles may be confused about this parameter. To put it simply, if your operating system is 32-bit, it is already set to disable by default, which means GCC can only generate 32-bit executable programs; if your operating system is 64-bit, it is set to enable by default, which means you can use the-M32 option to determine whether to generate 32-bit machine code when compiling other source files with GCC.

To disable 32-bit code generation on a 64-bit system, set -- disable-multilib.


-- Enable-gather-detailed-Mem-Stats

Allows the collection of detailed memory usage information. If this parameter is set to enable, the GCC executable program will be compiled in the future, you can use the-fmem-report option to output the real-time memory usage when compiling other programs.


-- With-Long-double-128.

Set the long double type to 128 bits (16 bytes !); If it is set to without, the long double type will be 64-bit (8 bytes), which will be the same as the normal double type.

When compiling Based on glib 2.4 or later, the default value is already 128 bits.


[[Email protected] desktop] # cd/extracted-Src-DIR/gcc-4.9.1/[[email protected] gcc-4.9.1] # cd/compile-DIR/[email protected] compile-Dir # PWD/compile-dir [[email protected] compile-Dir] #/extracted-Src-DIR/gcc-4.9.1/configure -- prefix =/usr/local/new-exec-gcc-4.9.1/-- enable- bootstrap -- enable-checking = release -- enable-threads = POSIX -- enable-languages ages = C, c ++ -- enable-gather-detailed-Mem-stats-with-Long-double-128


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/42/89/wKiom1PYYFmDYh5LAAOxQB-QfBE687.jpg "Title =" screenshot.jpg "alt =" wKiom1PYYFmDYh5LAAOxQB-QfBE687.jpg "/>


If the above parameter set is used to run the configure script, it will be generated in the compile-Dir directory.

Config. log, config. status, makefile, serdep. TMP files. Open config in gedit or another text editor. log, with error as the key string, searches for potential configuration errors and warnings detected by configure, which is critical to the normal compilation of future make phases: if there is no warning information related to the error, You can execute the make command.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/42/91/wKioL1PYbbvx7Wv7ABHdYX8COwo245.jpg "Title =" screenshot.jpg "alt =" wkiol1pybbvx7wv7abhdyx8cowo245.jpg "/>



In the current working directory, execute the make command to start the compilation process. The entire compilation process takes a lot of time depending on your system hardware configuration and the parameters specified for the configure script,

My hardware configuration is as follows, and it takes about 40 minutes to complete the compilation:


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/42/94/wKiom1PYcpnyc86LAAxjAXRJhJ4603.jpg "Title =" screenshot.jpg "alt =" wkiom1pycpnyc86laaxjax1_hj4603.jpg "/>









This article is from the "gnuisnotunix" blog, please be sure to keep this source http://gnuisnotunix.blog.51cto.com/4681835/1532646

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.