📄 install.texi
字号:
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.@c This is part of the GCC manual.@c For copying conditions, see the file gcc.texi.@c The text of this file appears in the file INSTALL@c in the GCC distribution, as well as in the GCC manual.@ifclear INSTALLONLY@node Installation@chapter Installing GNU CC@end ifclear@cindex installing GNU CC@menu* Configurations:: Configurations Supported by GNU CC.* Other Dir:: Compiling in a separate directory (not where the source is).* Cross-Compiler:: Building and installing a cross-compiler.* Sun Install:: See below for installation on the Sun.* VMS Install:: See below for installation on VMS.* Collect2:: How @code{collect2} works; how it finds @code{ld}.* Header Dirs:: Understanding the standard header file directories.@end menuHere is the procedure for installing GNU CC on a Unix system. See@ref{VMS Install}, for VMS systems. In this section we assume youcompile in the same directory that contains the source files; see@ref{Other Dir}, to find out how to compile in a separate directory on Unixsystems.You cannot install GNU C by itself on MSDOS; it will not compile underany MSDOS compiler except itself. You need to get the completecompilation package DJGPP, which includes binaries as well as sources,and includes all the necessary compilation tools and libraries.@enumerate@itemIf you have built GNU CC previously in the same directory for adifferent target machine, do @samp{make distclean} to delete all filesthat might be invalid. One of the files this deletes is@file{Makefile}; if @samp{make distclean} complains that @file{Makefile}does not exist, it probably means that the directory is already suitablyclean.@itemOn a System V release 4 system, make sure @file{/usr/bin} precedes@file{/usr/ucb} in @code{PATH}. The @code{cc} command in@file{/usr/ucb} uses libraries which have bugs.@itemSpecify the host, build and target machine configurations. You do thisby running the file @file{configure}.The @dfn{build} machine is the system which you are using, the@dfn{host} machine is the system where you want to run the resultingcompiler (normally the build machine), and the @dfn{target} machine isthe system for which you want the compiler to generate code.If you are building a compiler to produce code for the machine it runson (a native compiler), you normally do not need to specify any operandsto @file{configure}; it will try to guess the type of machine you are onand use that as the build, host and target machines. So you don't needto specify a configuration when building a native compiler unless@file{configure} cannot figure out what your configuration is or guesseswrong.In those cases, specify the build machine's @dfn{configuration name}with the @samp{--build} option; the host and target will default to bethe same as the build machine. (If you are building a cross-compiler,see @ref{Cross-Compiler}.)Here is an example:@smallexample./configure --build=sparc-sun-sunos4.1@end smallexampleA configuration name may be canonical or it may be more or lessabbreviated.A canonical configuration name has three parts, separated by dashes.It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}.(The three parts may themselves contain dashes; @file{configure}can figure out which dashes serve which purpose.) For example,@samp{m68k-sun-sunos4.1} specifies a Sun 3.You can also replace parts of the configuration by nicknames or aliases.For example, @samp{sun3} stands for @samp{m68k-sun}, so@samp{sun3-sunos4.1} is another way to specify a Sun 3. You can alsouse simply @samp{sun3-sunos}, since the version of SunOS is assumed bydefault to be version 4. @samp{sun3-bsd} also works, since@file{configure} knows that the only BSD variant on a Sun 3 is SunOS.You can specify a version number after any of the system types, and someof the CPU types. In most cases, the version is irrelevant, and will beignored. So you might as well specify the version if you know it.See @ref{Configurations}, for a list of supported configuration names andnotes on many of the configurations. You should check the notes in thatsection before proceeding any further with the installation of GNU CC.There are four additional options you can specify independently to describe variant hardware and software configurations. These are@samp{--with-gnu-as}, @samp{--with-gnu-ld}, @samp{--with-stabs} and@samp{--nfp}.@table @samp@item --with-gnu-asIf you will use GNU CC with the GNU assembler (GAS), you should declarethis by using the @samp{--with-gnu-as} option when you run@file{configure}.Using this option does not install GAS. It only modifies the output ofGNU CC to work with GAS. Building and installing GAS is up to you.Conversely, if you @emph{do not} wish to use GAS and do not specify@samp{--with-gnu-as} when building GNU CC, it is up to you to make surethat GAS is not installed. GNU CC searches for a program named@code{as} in various directories; if the program it finds is GAS, thenit runs GAS. If you are not sure where GNU CC finds the assembler it isusing, try specifying @samp{-v} when you run it.The systems where it makes a difference whether you use GAS are@*@samp{hppa1.0-@var{any}-@var{any}}, @samp{hppa1.1-@var{any}-@var{any}},@samp{i386-@var{any}-sysv}, @samp{i386-@var{any}-isc},@*@samp{i860-@var{any}-bsd}, @samp{m68k-bull-sysv}, @samp{m68k-hp-hpux},@samp{m68k-sony-bsd},@*@samp{m68k-altos-sysv}, @samp{m68000-hp-hpux}, @samp{m68000-att-sysv},@samp{@var{any}-lynx-lynxos}, and @samp{mips-@var{any}}).On any other system, @samp{--with-gnu-as} has no effect.On the systems listed above (except for the HP-PA, for ISC on the386, and for @samp{mips-sgi-irix5.*}), if you use GAS, you should alsouse the GNU linker (and specify @samp{--with-gnu-ld}).@item --with-gnu-ldSpecify the option @samp{--with-gnu-ld} if you plan to use the GNUlinker with GNU CC.This option does not cause the GNU linker to be installed; it justmodifies the behavior of GNU CC to work with the GNU linker.Specifically, it inhibits the installation of @code{collect2}, a programwhich otherwise serves as a front-end for the system's linker on mostconfigurations.@item --with-stabsOn MIPS based systems and on Alphas, you must specify whether you wantGNU CC to create the normal ECOFF debugging format, or to use BSD-stylestabs passed through the ECOFF symbol table. The normal ECOFF debugformat cannot fully handle languages other than C. BSD stabs format canhandle other languages, but it only works with the GNU debugger GDB.Normally, GNU CC uses the ECOFF debugging format by default; if youprefer BSD stabs, specify @samp{--with-stabs} when you configure GNUCC.No matter which default you choose when you configure GNU CC, the usercan use the @samp{-gcoff} and @samp{-gstabs+} options to specify explicitlythe debug format for a particular compilation.@samp{--with-stabs} is meaningful on the ISC system on the 386, also, if@samp{--with-gas} is used. It selects use of stabs debugginginformation embedded in COFF output. This kind of debugging informationsupports C++ well; ordinary COFF debugging information does not.@samp{--with-stabs} is also meaningful on 386 systems running SVR4. Itselects use of stabs debugging information embedded in ELF output. TheC++ compiler currently (2.6.0) does not support the DWARF debugginginformation normally used on 386 SVR4 platforms; stabs provide aworkable alternative. This requires gas and gdb, as the normal SVR4tools can not generate or interpret stabs.@item --nfpOn certain systems, you must specify whether the machine has a floatingpoint unit. These systems include @samp{m68k-sun-sunos@var{n}} and@samp{m68k-isi-bsd}. On any other system, @samp{--nfp} currently has noeffect, though perhaps there are other systems where it could usefullymake a difference.@end tableThe @file{configure} script searches subdirectories of the sourcedirectory for other compilers that are to be integrated into GNU CC.The GNU compiler for C++, called G++ is in a subdirectory named@file{cp}. @file{configure} inserts rules into @file{Makefile} to buildall of those compilers.Here we spell out what files will be set up by @code{configure}. Normallyyou need not be concerned with these files.@itemize @bullet@item@ifset INTERNALSA file named @file{config.h} is created that contains a @samp{#include}of the top-level config file for the machine you will run the compileron (@pxref{Config}). This file is responsible for defining informationabout the host machine. It includes @file{tm.h}.@end ifset@ifclear INTERNALSA file named @file{config.h} is created that contains a @samp{#include}of the top-level config file for the machine you will run the compileron (@pxref{Config,,The Configuration File, gcc.info, Using and PortingGCC}). This file is responsible for defining information about the hostmachine. It includes @file{tm.h}.@end ifclearThe top-level config file is located in the subdirectory @file{config}.Its name is always @file{xm-@var{something}.h}; usually@file{xm-@var{machine}.h}, but there are some exceptions.If your system does not support symbolic links, you might want toset up @file{config.h} to contain a @samp{#include} command whichrefers to the appropriate file.@itemA file named @file{tconfig.h} is created which includes the top-level configfile for your target machine. This is used for compiling certainprograms to run on that machine.@itemA file named @file{tm.h} is created which includes themachine-description macro file for your target machine. It should be inthe subdirectory @file{config} and its name is often@file{@var{machine}.h}.@itemThe command file @file{configure} also constructs the file@file{Makefile} by adding some text to the template file@file{Makefile.in}. The additional text comes from files in the@file{config} directory, named @file{t-@var{target}} and@file{x-@var{host}}. If these files do not exist, it means nothingneeds to be added for a given target or host.@end itemize@itemThe standard directory for installing GNU CC is @file{/usr/local/lib}.If you want to install its files somewhere else, specify@samp{--prefix=@var{dir}} when you run @file{configure}. Here @var{dir}is a directory name to use instead of @file{/usr/local} for all purposeswith one exception: the directory @file{/usr/local/include} is searchedfor header files no matter where you install the compiler. To overridethis name, use the @code{--local-prefix} option below.@itemSpecify @samp{--local-prefix=@var{dir}} if you want the compiler tosearch directory @file{@var{dir}/include} for locally installed headerfiles @emph{instead} of @file{/usr/local/include}.You should specify @samp{--local-prefix} @strong{only} if your site hasa different convention (not @file{/usr/local}) for where to putsite-specific files.@strong{Do not} specify @file{/usr} as the @samp{--local-prefix}! Thedirectory you use for @samp{--local-prefix} @strong{must not} containany of the system's standard header files. If it did contain them,certain programs would be miscompiled (including GNU Emacs, on certaintargets), because this would override and nullify the header filecorrections made by the @code{fixincludes} script.@cindex Bison parser generator@cindex parser generator, Bison@itemMake sure the Bison parser generator is installed. (This isunnecessary if the Bison output files @file{c-parse.c} and@file{cexp.c} are more recent than @file{c-parse.y} and @file{cexp.y}and you do not plan to change the @samp{.y} files.)Bison versions older than Sept 8, 1988 will produce incorrect outputfor @file{c-parse.c}.@itemIf you have chosen a configuration for GNU CC which requires other GNUtools (such as GAS or the GNU linker) instead of the standard systemtools, install the required tools in the build directory under the names@file{as}, @file{ld} or whatever is appropriate. This will enable thecompiler to find the proper tools for compilation of the program@file{enquire}.Alternatively, you can do subsequent compilation using a value of the@code{PATH} environment variable such that the necessary GNU tools comebefore the standard system tools.@itemBuild the compiler. Just type @samp{make LANGUAGES=c} in the compilerdirectory.@samp{LANGUAGES=c} specifies that only the C compiler should becompiled. The makefile normally builds compilers for all the supportedlanguages; currently, C, C++ and Objective C. However, C is the onlylanguage that is sure to work when you build with other non-GNU Ccompilers. In addition, building anything but C at this stage is awaste of time.In general, you can specify the languages to build by typing theargument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or morewords from the list @samp{c}, @samp{c++}, and @samp{objective-c}. Ifyou have any additional GNU compilers as subdirectories of the GNU CCsource directory, you may also specify their names in this list.Ignore any warnings you may see about ``statement not reached'' in@file{insn-emit.c}; they are normal. Also, warnings about ``unknownescape sequence'' are normal in @file{genopinit.c} and perhaps someother files. Likewise, you should ignore warnings about ``constant isso large that it is unsigned'' in @file{insn-emit.c} and@file{insn-recog.c} and a warning about a comparison always being zeroin @file{enquire.o}. Any other compilation errors may represent bugs inthe port to your machine or operating system, and@ifclear INSTALLONLYshould be investigated and reported (@pxref{Bugs}).@end ifclear@ifset INSTALLONLYshould be investigated and reported.@end ifsetSome commercial compilers fail to compile GNU CC because they have bugsor limitations. For example, the Microsoft compiler is said to run outof macro space. Some Ultrix compilers run out of expression space; thenyou need to break up the statement where the problem happens.@itemIf you are building a cross-compiler, stop here. @xref{Cross-Compiler}.@cindex stage1@itemMove the first-stage object files and executables into a subdirectorywith this command:@smallexamplemake stage1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -