| Red Hat Documentation |
|
Installing GNU CC The following documentation discusses installation and what you need to get the GNU compiler, GCC, to work for you.
You cannot install GNU CC by itself on MSDOS; it will not compile under any MSDOS compiler except itself. You need to get the complete compilation package, DJGPP, which includes binaries as well as sources, and includes all the necessary compilation tools and libraries. What follows is the procedure
for installing GCC on a UNIX system. In this documentation, we assume you
compile in the same directory that contains the source files; see Compilation
in a separate directory to find out how to compile in a separate directory
on UNIX systems.
1.
2.
3.
The build machine is the system which you are using, the host machine is the system where you want to run the resulting compiler (normally the build machine), and the target machine is the system for which you want the compiler to generate code. If you are building a compiler to produce code for the machine it runs on (a native compiler), you normally do not need to specify any operands to configure; it will try to guess the type of machine you are on and use that as the build, host and target machines. So you dont need to specify a configuration when building a native compiler unless configure cannot figure out what your configuration is or guesses wrong. In those cases, specify the build machines configuration name with the option, --build; the host and target will default to be the same as the build machine. The following is an example of a specification command. ./configurebuild=sparc-sun-sunos4.1A configuration name may be canonical or it may be more or less abbreviated. A canonical configuration name has three parts, separated by dashes. It uses the following parts. cpu-company-systemThe three parts may themselves contain dashes; configure can figure out which dashes serve which purpose. For example, m68k-sun-sunos4.1 specifies a Sun 3. (If you are building a cross-compiler, see Building and installing a cross-compiler.) You can also replace parts of the configuration by nicknames or aliases. For example, sun3 stands for m68k-sun, so sun3-sunos4.1 is another way to specify a Sun 3. You can also use sun3-sunos, since the version of SunOS is, by default, version 4. You can specify a version number after any of the system types, and some of the CPU types. In most cases, the version is irrelevant, and will be ignored. So you might as well specify the version if you know it.
See Configurations supported by GNU CC for a list of supported configuration names and notes on many of the configurations. Check the notes in that section before proceeding any further with the installation of GNU CC.
The GNU compiler for C++, called g++, is in a subdirectory named cp. configure inserts rules into Makefile to build all of those compilers. In the following, we clarify which files will be set up by configure. Normally you need not be concerned with these files.
xm- machine.h, but there are some exceptions. The standard directory for installing GNU CC is /usr/local/lib. If you want to install its files somewhere else, specify --prefix=dir when you run configure. dir is a directory name to use instead of /usr/local for all purposes with one exception: the directory /usr/local/include is searched for header files no matter where you install the compiler. To override this name, use the --local-prefix option in Step 5. 5.
You should specify --local-prefix only if your site has a different convention (not /usr/local) for where to put site-specific files. The default value for --local-prefix is /usr/local regardless of the value of --prefix. Specifying --prefix has no effect on which directory GNU CC searches for local header files. This may seem counterintuitive, but actually it is logical. The purpose of --prefix is to specify where to install GNU CC. The local header files in /usr/local/includeif you put any in that directoryare not part of GNU CC. They are part of other programsperhaps many others. (GNU CC installs its own header files in another directory which is based on the --prefix value.)
Do not specify /usr as the --local-prefix! Indications are that people use this option use it based on mistaken ideas of its purpose. They use it as if it specified where to install GNU CC, perhaps on the assumption that installing GNU CC creates this directory. 6.
Bison versions older than Sept 8, 2025 will produce incorrect output for c-parse.c. 7.
Alternatively, you can do subsequent compilation using a value of the PATH environment variable such that the necessary GNU tools come before the standard system tools. 8.
In general, you can specify the languages to build by typing the argument LANGUAGES="list" where list is one or more words from the list c, c++, and objective-c. If you have any additional GNU compilers as subdirectories of the GNU CC source directory, you may also specify their names in this list. Ignore any warnings you may see about statement not reached in insn-emit.c; they are normal. Also, warnings about unknown escape sequence are normal in genopinit. and perhaps some other files. Likewise, you should ignore warnings about constant is so large that it is unsigned in insn-emit.c and insn-recog.c and a warning about a comparison always being zero in enquire.o. Any other compilation errors may represent bugs in the port to your machine or operating system, and should be investigated and reported (see Reporting bugs). Some commercial compilers fail to compile GNU CC because they have bugs or limitations. For example, the Microsoft compiler is said to run out of macro space. Some Ultrix compilers run out of expression space; then you need to break up the statement where the problem happens. 9.
10.
make stage1The files are moved into a subdirectory named stage1. Once installation is complete, you may wish to delete these files with rm -r stage1. 11.
Alternatively, you can do subsequent compilation using a value of the PATH environment variable such that the necessary GNU tools come before the standard system tools. 12.
make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2"This is called making the stage 2 compiler. The command shown in the previous example builds compilers for all the supported languages. If you dont want them all, you can specify the languages to build by typing the argument LANGUAGES="list". Where list should contain one or more words from the list c, c++, objective-c, and proto. Separate the words with spaces. proto stands for the programs protoize and unprotoize; they are not a separate language, but you use LANGUAGES to enable or disable their installation. If you are going to build the stage 3 compiler, then you might want to build only the C language in stage 2. Once you have built the stage 2 compiler, if you are short of disk space, you can delete the subdirectory stage1. On a 68000 or 68020 system lacking floating point hardware, unless you have selected a tm.h file that expects by default to find no hardware; instead, use the following command. make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2 -msoft-float"13. If you wish to test the compiler by compiling it with itself one more time, install any other necessary GNU tools (such as GAS or the GNU linker) in the stage2 subdirectory as you did in the stage1 subdirectory; then, use the following. This is called making the stage 3 compiler. make stage2 make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2"Aside from the -B option, the compiler options should be the same as when you made the stage 2 compiler. But the LANGUAGES option need not be the same. The command in the previous example builds compilers for all the supported languages; if you dont want them all, you can specify the languages to build by typing the argument LANGUAGES="list" as described in Step 8. If you dont have to install any additional GNU tools, you may use the following command instead of making stage1, stage2, and performing the two compiler builds. make bootstrap LANGUAGES= language-list \ BOOT_CFLAGS= option-list14. Then compare the latest object files with the stage 2 object filesthey ought to be identical, aside from time stamps (if any). On some systems, meaningful comparison of object files is impossible; they always appear different. This is currently true on Solaris and some systems that use ELF object file format. On some versions of Irix on SGI machines and DEC Unix (OSF/1) on Alpha systems, you will not be able to compare the files without specifying -save-temps; see the description of individual systems above to see if you get comparison failures. You may have similar problems on other systems. Use the following command to compare the files. make compareThis will mention any object files that differ between stage 2 and stage 3. Any difference, no matter how innocuous, indicates that the stage 2 compiler has compiled GNU CC incorrectly, and is therefore a potentially serious bug which you should investigate and report (see Reporting bugs). If your system does not put time stamps in the object files, then use the following as a faster way to compare them (using the Bourne shell). for file in *.o; do cmp $file stage2/$file doneNote: If you built the compiler on MIPS machines with the option, -mno-mips-tfile, you cant compare files. 15. Install the compiler driver, the compilers passes and run-time support with make install. Use the same value for CC, CFLAGS and LANGUAGES that you used when compiling the files that are being installed. One reason this is necessary is that some versions of Make have bugs and recompile files gratuitously when you use this step. If you use the same variable values, those files will be properly recompiled. For example, if you have built the stage 2 compiler, you can use the following command. make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" \ LANGUAGES=" list"This copies the files cc1, cpp and libgcc.a to files cc1, cpp and libgcc.a in the directory /usr/local/lib/gcc-lib/target/version, which is where the compiler driver program looks for them. In this case, target is the target machine type specified when you ran configure, and version is the version number of GNU CC. This naming scheme permits various versions and/or cross-compilers to coexist. It also copies the executables for compilers for other languages (e.g., cc1plus for C++) to the same directory. This also copies the driver program xgcc into /usr/local/bin/gcc, so that it appears in typical execution search paths. It also copies gcc.1 into /usr/local/man/man1 and info pages into /usr/local/info. On some systems, this command causes recompilation of some files. This is usually due to bugs in make. You should either ignore this problem, or use GNU Make.
There is a bug in alloca in the Sun library. To avoid this bug, be sure to install the executables of GNU CC that were compiled by GNU CC. (The executables from stage 2 or 3, not stage 1.) They use alloca as a built-in function, never the one in the library. 16.
Just as GNU C does not distribute a C runtime library, it also does not include a C++ run-time library. All I/O functionality, special class libraries, etc., are available in the libg++ distribution. 17.
When you run configure, it picks the appropriate Objective-C thread implementation file for the target platform. In some situations, you may wish to choose a different back-end as some platforms support multiple thread implementations or you may wish to disable thread support completely. You do this by specifying a value for the OBJC_THREAD_FILE makefile variable on the command line when you run make. Use the folllowing example, for instance. make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" OBJC_THREAD_FILE=thr-singleThe following lists the currently available back-ends.
Top|Contents|Index|Previous|Next |
|
© 2001 Red Hat, Inc. All rights reserved. About Red Hat : Legal statement : Privacy statement : Y2K statement : Contact Red Hat |