GCC installation manual

xiaoxiao2021-03-06  20

source:

Linuxbyte

This article is translated into GCC Installation Guide, all rights reserved, and translators allow this article to circulate, replicate on the Internet, and for use, except for translator allows for any commercial use.

Translator: Chen Zhenyu, Industrial Technical Directory

Ranma@hunt.cs.ntit.edu.tw

Song Zhenhua, Command of Jiaotong University

chsong@iim.nctu.edu.tw

If there is any negligence, hurt, welcome to point 7/1/1997

[Editor: See

http://www.lslnet.com/linux/books/howto/gcc --howto.html]

This is a program that installs the GNU CC on the UNIX system. Users of the VMS system, please see * Note:

VMS installation. In this section, we assume that the compiled action is performed in the same directory as the original file; if you want to perform compilation actions in other directory, please see * Note: Other directories.

Installing the GNU CC directly under MS-DOS is not feasible, and any compiler under DOS cannot successfully compile the GNU CC unless you use the GNU CC itself. To install GNU CC under MS-DOS, you must obtain a fully compiled completed kit: DJGPP. DJGPP contains machine code files and original program files, and also contains all necessary compilation tools and ferries.

1. If you are on another machine, complete the GNU CC's compilation, execute / "make distclean /" in the same directory, and execute / "make distclean /" to delete some unique files. One of the deleted files called / "makefile /"; if / "make distclean /" responds to Makefile does not exist, it may indicate that this directory has been properly cleaned up.

2. On the System V Release 4 system, make sure you are in the path / "path /" setting, / "/ usr / bin /" before / "/ usr / ucb /". Because the CC in / "/ USR / UCB /" uses a file library with errors.

3. You can perform / "configure /" to set Host Machine, Build Machine, and Target Machine.

The so-called / "build machine /" refers to the machine you are currently being used; / "host machine /" is the machine you expect after compiling the compiler; the last / "target machine /" is you It is expected that this compiler (that is being compiled) hosting the host code. (Generally, the first two are the same).

If you are building a compiler (Native Compiler) of the machine code that produces its own machine, it is generally not necessary to make any settings on / "configure /"; it will be used as the machine currently used as the machine Host, Build and Target Machine. So when you make Native Compiler, you don't need any setting. Unless / "configure /" can't point out your system configuration or it guess it wrong.

In this case, use the option -build to specify the build machine / "configuration name /"; Host and Target Machine will be the same as that of Build Machine. (If you are building a interactive compiler, please see * Note: Interactive Compiler)

Under the bottom is an example:

./configure --build = sparc-sun-sunos4.1

Configuration Name may be a standard form or a standard formatic abbreviation.

A complete construction name is three parts from / "- /". Probably: / "CPU Name - Vendor Name - System Name /" (each part can contain its own / "- /", configure this program). For example: / "M68k-Sun-SunOS4.1 /" means Sun 3.

You can also replace part of the building name. For example: `sun3 /" represents `M68k-sun /", `sun3-sunos4.1 /" is also another SUN 3 representation. You can also use `sun3-sunos /", because Suppose SUNOS's version is preset to 4. `Sun3-BSD /" It is also possible because `configure /" Know SunOS is the only BSD variant on Sun 3.

You can indicate the version number and the CPU model later in various system types. In most examples, the version is useless, and it will be ignored. So if you know, it is best to add the number. (RANMA Note: This original text is weird)

For information on the construction name and construction of the support, please refer to * Note: Built. Before you continue to install the GNU CC, you'd better look at the annotation.

There are four additional options at the bottom to make you specify different hardware and software construction:

`--with-gnu-as /", `with-gnu-ld`,` --with-stabs / "and` - NFP / ".

`--with-gnu-as /"

If you want to use the GNU CC with the GNU group translation (GNU Assembler), you can do this option in performing `configure /". - With-GNU-as / "option.

Using this option does not have GAS. It just modifies the output of the GNU CC to be used by GAS. Do you want to install GAS by yourself.

Conversely, if you * do not * use GAS and do not indicate the `--with-gnu-as /" when constructing GNU CC, you must decide whether it is to install the GAS. GNU CC will be in each directory □ `as /" This program, if it finds GAS, it will use GAS. If you don't sure the GNU CC is found in which group translator is used, add the `-v /" option when performing GCC.

Will you have different changes because of whether you use GAS:

`HPPA1.0-Any-Any /", `HPPA1.1-Any-Any /", `I386-Any-Sysv /",

`i386-any-isc /",

`I860-Any-BSD /", `M68k-Bull-Sysv /", `M68k-HP-HPUX /",

`m68k-sony-bsd /", `m68k-altos-sysv /", `m68000-hp-hpux /", `m68000-att-sysv /",

`Any-Lynx-Lynxos /", and `MIPS-ANY /"). For other systems,

`--With-gnu-as /" does not affect.

In the above system (in addition to ISC on HP-PA, 386, and `MIPS-SGI-IRIX5. * /"), If you use GAS, you should also use the GNU connector (Linker), which is to indicate` --with-gnu-ld / ".

`--with-gnu-ld /"

If you want to take the GNU loop with the GNU CC, specify this option.

This option does not install the GNU cable, which is just changing the habit of the GNU CC to cooperate with the GNU loop. It is divided into, it makes `collet2 /" This program will not be installed. This program is used in most constructors to do the pre-processing of system connectors.

`--with-stabs /"

On most of the MIPS-based systems and alpha, you must specify the GNU CC to generate a regular ECOFF amplifier format, or the STABS to be bsd to pass the symbolic table. Regular ECOFF density format does not complete the language other than C. The BSD Stabs format can handle other languages, but only

Do it above the GNU Debugger.

Under normal circumstances, the GNU CC presets using the ECOFF amplifies format, if you prefer the BSD Stabs format, indicate the `--with-stabs /" at compile time.

No matter which preset value is selected when establishing a GNU CC, users can specify the deactivation format he wants to use with the `-gcoff /" and `-gstabs /".

`--with-stabs /" There is a special meaning in the ISC system on 386, when `--with-gas /" is used. It chooses Stabs Debugging Information Embedded in coff output in the COFF output (STABS Debugging Information Embedded In Coff Output). This type of extension information also supports C , and ordinary COFF is unable to do.

`--with-stabs /" There is also a special meaning in the 386 system of running SVR4. It chooses to use Stabs embedded in the ELF output. On the 386 SVR4 platform, the current C compiler (version 2.6.0) DWARF is not supported. Stabs provides another way to use. It requires GAS and GDB because normal SVR4 tools do not generate or interpret the Stabs format.

`- NFP /"

On some systems, you must indicate whether this machine has a floating point opener. These systems include `M68k-sun-sunosn /" and `m68k-ISI-bsd /". Currently `- NFP /" There is no effect on other systems, although there may be different effects on other systems.

`configure /" This program will go to the subdirectory under the original code directory to find other compilers to integrate with the GNU CC. For example, the C compiler, G , placed in `CP /" this subdirectory □. `Configure /" will add the rules of the establishment of these compilers to `makefile /". Under the end, we will explain the files in detail. In normal conditions, you don't need to worry about these files.

* The file called `config.h /" will be established, and there is a `# incrude /" on the face. The top floor setting file you want to perform this compiler row (* annotation: build). This file is used to define information from Host Machine. It contains `TM.H /".

The top floor setting is placed in `config /" This subdirectory □. It is called `XM - a thing. H /", usually a `XM-machine name .h /", but some exceptions.

If your system does not support symbolic link, you can set the `config.h /" Let it contain a `# include /" to point to the appropriate file.

* The file called `tconfig.h /" will introduce the top floor setting file of Target Machine. This is to be used to compile some programs to run on that machine.

* The file called `tm.h /" will contain the machine to describe the Machine-Description Macro file. It should be placed in the `config /" subdirectory and its name is usually Is `machine name .h /".

* `configure /" This command will also add some words on this mode file to generate `makefile /". These extra text are called `t-target /" in the `config /" directory And `x-host /" archives. If these files do not exist, it means that there is no need to add other things for Target or Host Machine.

4. The standard directory for installing the GNU CC is `/ usr / local / lib /". If you intend to install other places, execute the `configure /" indicate` --Previx = directory / ".` Directory / " It is a directory name that you plan to replace `/ usr / local /", in addition to this exception: No matter where your compiler is installed, `/ usr / local / include /" will be added to find the header Directory of files. If you don't want this, you can use the following `--Local-prefix /" option.

5. Specify the `-local-prefix = directory /", this allows you to set the path to the compiler to find the header file. Instead of using `/ usr / local / include /".

* Only when you put your special specification files on your computer, you will need a `--local-prefix /" option.

* Don't * specify `/ usr /" to `--Local-prefix /"! You are in `--local-prefix /" The directory * must not * contains all system standard headers. If it is really included, some prices are compiled. (Including GNU Emacs, in some On the target machine), because this will cover or do the header file set set by the `fixincludes /". 6. Determine the BISON parser generator already installed. (If Bison's `c-parse.c /" follow `CEXP.C /" is new than `c-parse.y /" with `CEXP.Y /" is new, and you don't plan to change These `.y /" files, this step does not have to be done. The Bison version before September 8, 1988 produces incorrect `c-parse.c /".

7. If you have selected a configuration of other GNU tools (like a GAS or GNU cable) instead of the standard system tool, remember to install the tools required under the creation of the GNU CC, and name To `as /", / "ld /" or other related names. This will make the compiler to find these appropriate tools when compiling `enquire /".

Or, you can set the `path /" environment variable value before you have made later compilation work before the standard system tool.

8. Establish this compiler. Just in the compiler directory □ Into the `make language = C /".

`Languages ​​= C /" indicates that only the C, C and Objective C are currently compiled, and currently C, C and Objective C. However, only c is you with other non-GNU C compiler One of the artificial movements. Again, things outside this stage are wasting time.

Usually, you can be entered into this parameter `Languages ​​= /" List / "指 指 的 你 要," List / "is` c / ", one or one or one or one or one or one of` C / "and` Objective-c / "or Multiple. If you have other additional GNU compilers under the original code of the GNU CC, you will be able to add `list /".

Ignore all / "statement not reached /" warning messages when editing `insn-emit.c /", it is normal. Also, warning message / "unknown escape sequence /" in the editing `genopinit.c /" Or other files are normal. Similarly, you can also do those on `insn-esn-emit.c /" and `insn-recget /" constant is so limited it it is unsigned / "and` enquire.o / " / "Comparison always being zero /". Other compilation errors may indicate errors when transplanted into your machine or job system, you should carefully check and report (notes: insects).

Some compilers who want money are failed during the editing GNU CC because they own insects or restrictions. For example, Microsoft's compiler says all gauge spaces. Some ULTRIX compilers will run out of the expression space, and you must separate the description of the problem. 9. If you are doing a compiler, you will hit it. * Note: Interactive compiler

10. Use this command to put the first phase of the file and the executive file to a directory:

Make stage1

These files will be placed in a sub-directory called `stage1 /". When the installation is complete, you may kill these files with `rm -r stage.

11. If you have selected a configuration of other GNU tools (like a GAS or GNU cable) instead of the standard system tool, put these tools in the `Stage1 /" subdirectory, And named `as /", `ld /" or related file name. This will make the first phase compiler in this to find suitable tools when doing the next phase.

Or, you can set the `path /" environment variable value to the standard system tool when you do subsequent compilation work.

12. Use this command called this compiler to recompile itself:

Make cc = / "stage1 / xgcc -bstage1 //" cflags = / "- g -O2 /"

This is called the construction of the second phase compiler.

The above command will create a compiler of all support languages. If you don't do it, you can use `Languages ​​= /" List / "/" to indicate the language you have to do. List can contain `C /", `C /", `Objective-c /" and `proto / "One or more, with blank separation. `proto /" means two programs in the `protoize /" and `unprotoize /", they are not a separate language, but you use `Languages ​​/" Don't Install them.

If you have to continue your third phase compiler, you just make a C language in the second phase.

When you finish the second phase compiler, if the disk space is almost, you can cut off the `stage1 /" this subdirector.

On the 68000 or 68020 system without floating point calculation hardware, unless you have selected a preset no floating point of the `tm.h /" file, don't use this below:

Make cc = / "stage1 / xgcc -bstage1 //" cflags = / "- g -O2-msoft-float /"

13. If you want to test it with this compiler to test it, put other needs GNU tools (like GAS or GNU Linker) on `Stage2 /" Sub Directory, just like you `Stage1 /" Sub Directory □ Doing the same, then:

Make stage2

Make cc = / "stage2 / xgcc -bstage2 //" cflags = / "- g-g -O2 /"

This is called the construction of the third stage compiler. In addition to the `-b /" option, the compile option is the same as you are doing the second phase compiler. But `languages ​​/" This option is not necessarily the same. The above command will make a compiler of all support. If you don't do all, you can specify the language you want to use as mentioned above. If you don't need any additional GNU tools, you may have to use this command.

Make bootstrap language = language-list boot_cflags = option-list

Instead of making `stage1 /", `stage2 /" and perform what they make.

14. Then, the second phase of the destination file with the final destination - except for Time Stamp, they should be just right.

In some systems, meaningful comparative destination files are impossible; they always display / "different /". Currently in Solaris and some systems that use ELF destination formats. These files are compared on certain versions of the Dec Unix (OSF / 1) on the Irix (OSF / 1) on the Alpha system, you can't specify `-save-temps /". If you are wrong, go See the instructions of the above individual systems. You may also have similar problems in other systems.

Use this command to compare the file:

Make Compare

It will refer to the difference in destination files in all second phases and third phases. There is any difference, no matter how harmless, the GNU CC is displayed in a second phase, so it is possible to have a serious error. You should check and make a report. (* Note: insects)

If your system does not place timestamp on the destination file, there is a faster way to compare them (with bourne shell):

For File in * .o; do

CMP $ FILETAGE2 / $ FILE

DONE

If you are using the `-mno-mips-tfile /" option on the MIPS machine, you will have no way to compare these files.

15. Playing the `make install /" Install the compiler driver, this is included in the various phases of the compiler (PASS) and execution period support. At `cc /", `cflag /", `Languages ​​/" □ use You are doing the same value when you compile. Doing so there is a necessary reason because some versions of Make homework, will inexplicably recompile the file. If you specify the same variable value, those files are properly compiled.

For example, if you have established a second-stage compiler, you can use the command:

Make Install CC = / "stage2 / xgcc -bstage2 //" cflags = / "- g-g-= /" Languages ​​= / "list /"

This will put the `cc1 /", `cpp /" copy to `/ usr / local / lib / gcc-lib / target / version /" this directory, this directory is the compiler driver Used to find these files. Target is the target machine type you specified when executing `configure /", and Version is the version number of the GNU CC. This naming method is to make different versions and / or interactive compilers exist at the same time.

This will also put the drive program `XGCC /" placed in `/ usr / local / bin / gcc /", so that it appears in a typical execution search path. In some systems, this command will make certain files being recompiled. This is usually `make /". You can ignore this problem, or use GNU Make.

* WARNING * SUN's Valida / "is wrong. To avoid this error, make sure you have installed the GNU CC executable files compiled with the GNU CC. (That is, the second phase or The executable files in the third phase, rather than the first phase) they will put the `alloca /" as the built-in function, not the one in the library.

(Usually, it is best to use the GNU CC executable generated by the second phase or third phase, because in general, they will be faster than other compilers.

16. If you want to use C , you have to install the libg set. It should be the same place you get GNU C. Since the GNU C does not have another C executable periodic library, it does not contain a C execution program library. All I / O functions, special category fuses, etc. are all included in the libg .

转载请注明原文地址:https://www.9cbs.com/read-53139.html

New Post(0)