]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/install-old.texi
root.texi: Fix typo in patches e-mail address.
[thirdparty/gcc.git] / gcc / doc / install-old.texi
CommitLineData
5c25e11d 1@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2284f91b
DE
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@c The text of this file appears in the file INSTALL
6@c in the GCC distribution, as well as in the GCC manual.
7
99bdaa68
JM
8Note most of this information is out of date and superseded by the
9online GCC install procedures @uref{http://gcc.gnu.org/install/}. It is
10provided for historical reference only.
f2d76545 11
2284f91b
DE
12@ifclear INSTALLONLY
13@node Installation
14@chapter Installing GNU CC
15@end ifclear
16@cindex installing GNU CC
17
18@menu
ab87f8c8 19* Configuration Files:: Files created by running @code{configure}.
2284f91b
DE
20* Configurations:: Configurations Supported by GNU CC.
21* Other Dir:: Compiling in a separate directory (not where the source is).
22* Cross-Compiler:: Building and installing a cross-compiler.
2284f91b
DE
23* VMS Install:: See below for installation on VMS.
24* Collect2:: How @code{collect2} works; how it finds @code{ld}.
25* Header Dirs:: Understanding the standard header file directories.
26@end menu
27
ab87f8c8
JL
28Here is the procedure for installing GNU CC on a GNU or Unix system.
29See @ref{VMS Install}, for VMS systems. In this section we assume you
2284f91b 30compile in the same directory that contains the source files; see
ab87f8c8
JL
31@ref{Other Dir}, to find out how to compile in a separate directory on
32Unix systems.
2284f91b
DE
33
34You cannot install GNU C by itself on MSDOS; it will not compile under
35any MSDOS compiler except itself. You need to get the complete
36compilation package DJGPP, which includes binaries as well as sources,
37and includes all the necessary compilation tools and libraries.
38
39@enumerate
40@item
41If you have built GNU CC previously in the same directory for a
42different target machine, do @samp{make distclean} to delete all files
43that might be invalid. One of the files this deletes is
44@file{Makefile}; if @samp{make distclean} complains that @file{Makefile}
45does not exist, it probably means that the directory is already suitably
46clean.
47
48@item
49On a System V release 4 system, make sure @file{/usr/bin} precedes
50@file{/usr/ucb} in @code{PATH}. The @code{cc} command in
51@file{/usr/ucb} uses libraries which have bugs.
52
ab87f8c8
JL
53@cindex Bison parser generator
54@cindex parser generator, Bison
55@item
86702e31
ZW
56Make sure the Bison parser generator is installed. (This is unnecessary
57if the Bison output file @file{c-parse.c} is more recent than
58@file{c-parse.y},and you do not plan to change the @samp{.y} file.)
ab87f8c8
JL
59
60Bison versions older than Sept 8, 1988 will produce incorrect output
61for @file{c-parse.c}.
62
63@item
64If you have chosen a configuration for GNU CC which requires other GNU
65tools (such as GAS or the GNU linker) instead of the standard system
66tools, install the required tools in the build directory under the names
67@file{as}, @file{ld} or whatever is appropriate. This will enable the
68compiler to find the proper tools for compilation of the program
69@file{enquire}.
70
71Alternatively, you can do subsequent compilation using a value of the
72@code{PATH} environment variable such that the necessary GNU tools come
73before the standard system tools.
74
2284f91b
DE
75@item
76Specify the host, build and target machine configurations. You do this
ab87f8c8 77when you run the @file{configure} script.
2284f91b
DE
78
79The @dfn{build} machine is the system which you are using, the
80@dfn{host} machine is the system where you want to run the resulting
81compiler (normally the build machine), and the @dfn{target} machine is
82the system for which you want the compiler to generate code.
83
84If you are building a compiler to produce code for the machine it runs
85on (a native compiler), you normally do not need to specify any operands
86to @file{configure}; it will try to guess the type of machine you are on
87and use that as the build, host and target machines. So you don't need
88to specify a configuration when building a native compiler unless
89@file{configure} cannot figure out what your configuration is or guesses
90wrong.
91
92In those cases, specify the build machine's @dfn{configuration name}
e5e809f4
JL
93with the @samp{--host} option; the host and target will default to be
94the same as the host machine. (If you are building a cross-compiler,
2284f91b
DE
95see @ref{Cross-Compiler}.)
96
97Here is an example:
98
99@smallexample
f5963e61 100./configure --host=sparc-sun-sunos4.1
2284f91b
DE
101@end smallexample
102
103A configuration name may be canonical or it may be more or less
104abbreviated.
105
106A canonical configuration name has three parts, separated by dashes.
107It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}.
108(The three parts may themselves contain dashes; @file{configure}
109can figure out which dashes serve which purpose.) For example,
110@samp{m68k-sun-sunos4.1} specifies a Sun 3.
111
112You can also replace parts of the configuration by nicknames or aliases.
113For example, @samp{sun3} stands for @samp{m68k-sun}, so
e954b3d7 114@samp{sun3-sunos4.1} is another way to specify a Sun 3.
2284f91b
DE
115
116You can specify a version number after any of the system types, and some
117of the CPU types. In most cases, the version is irrelevant, and will be
118ignored. So you might as well specify the version if you know it.
119
120See @ref{Configurations}, for a list of supported configuration names and
121notes on many of the configurations. You should check the notes in that
122section before proceeding any further with the installation of GNU CC.
123
ab87f8c8
JL
124@item
125When running @code{configure}, you may also need to specify certain
126additional options that describe variant hardware and software
127configurations. These are @samp{--with-gnu-as}, @samp{--with-gnu-ld},
128@samp{--with-stabs} and @samp{--nfp}.
2284f91b
DE
129
130@table @samp
131@item --with-gnu-as
132If you will use GNU CC with the GNU assembler (GAS), you should declare
133this by using the @samp{--with-gnu-as} option when you run
134@file{configure}.
135
136Using this option does not install GAS. It only modifies the output of
137GNU CC to work with GAS. Building and installing GAS is up to you.
138
139Conversely, if you @emph{do not} wish to use GAS and do not specify
140@samp{--with-gnu-as} when building GNU CC, it is up to you to make sure
141that GAS is not installed. GNU CC searches for a program named
142@code{as} in various directories; if the program it finds is GAS, then
143it runs GAS. If you are not sure where GNU CC finds the assembler it is
144using, try specifying @samp{-v} when you run it.
145
146The systems where it makes a difference whether you use GAS are@*
147@samp{hppa1.0-@var{any}-@var{any}}, @samp{hppa1.1-@var{any}-@var{any}},
148@samp{i386-@var{any}-sysv}, @samp{i386-@var{any}-isc},@*
149@samp{i860-@var{any}-bsd}, @samp{m68k-bull-sysv},@*
150@samp{m68k-hp-hpux}, @samp{m68k-sony-bsd},@*
151@samp{m68k-altos-sysv}, @samp{m68000-hp-hpux},@*
152@samp{m68000-att-sysv}, @samp{@var{any}-lynx-lynxos},
153and @samp{mips-@var{any}}).
154On any other system, @samp{--with-gnu-as} has no effect.
155
156On the systems listed above (except for the HP-PA, for ISC on the
157386, and for @samp{mips-sgi-irix5.*}), if you use GAS, you should also
158use the GNU linker (and specify @samp{--with-gnu-ld}).
159
160@item --with-gnu-ld
161Specify the option @samp{--with-gnu-ld} if you plan to use the GNU
162linker with GNU CC.
163
164This option does not cause the GNU linker to be installed; it just
165modifies the behavior of GNU CC to work with the GNU linker.
ace62b49
JL
166@c Specifically, it inhibits the installation of @code{collect2}, a program
167@c which otherwise serves as a front-end for the system's linker on most
168@c configurations.
2284f91b
DE
169
170@item --with-stabs
171On MIPS based systems and on Alphas, you must specify whether you want
172GNU CC to create the normal ECOFF debugging format, or to use BSD-style
173stabs passed through the ECOFF symbol table. The normal ECOFF debug
174format cannot fully handle languages other than C. BSD stabs format can
175handle other languages, but it only works with the GNU debugger GDB.
176
177Normally, GNU CC uses the ECOFF debugging format by default; if you
178prefer BSD stabs, specify @samp{--with-stabs} when you configure GNU
179CC.
180
181No matter which default you choose when you configure GNU CC, the user
182can use the @samp{-gcoff} and @samp{-gstabs+} options to specify explicitly
183the debug format for a particular compilation.
184
185@samp{--with-stabs} is meaningful on the ISC system on the 386, also, if
186@samp{--with-gas} is used. It selects use of stabs debugging
187information embedded in COFF output. This kind of debugging information
188supports C++ well; ordinary COFF debugging information does not.
189
190@samp{--with-stabs} is also meaningful on 386 systems running SVR4. It
191selects use of stabs debugging information embedded in ELF output. The
192C++ compiler currently (2.6.0) does not support the DWARF debugging
193information normally used on 386 SVR4 platforms; stabs provide a
194workable alternative. This requires gas and gdb, as the normal SVR4
195tools can not generate or interpret stabs.
196
197@item --nfp
198On certain systems, you must specify whether the machine has a floating
199point unit. These systems include @samp{m68k-sun-sunos@var{n}} and
200@samp{m68k-isi-bsd}. On any other system, @samp{--nfp} currently has no
201effect, though perhaps there are other systems where it could usefully
202make a difference.
203
9ec36da5
JL
204@cindex Internal Compiler Checking
205@item --enable-checking
206When you specify this option, the compiler is built to perform checking
207of tree node types when referencing fields of that node. This does not
208change the generated code, but adds error checking within the compiler.
209This will slow down the compiler and may only work properly if you
210are building the compiler with GNU C.
2284f91b 211
ab87f8c8
JL
212@cindex Native Language Support
213@cindex NLS
214@item --enable-nls
215@itemx --disable-nls
216The @samp{--enable-nls} option enables Native Language Support (NLS),
217which lets GCC output diagnostics in languages other than American
ebb48a4d 218English. Native Language Support is enabled by default if not doing a
69fe169e 219canadian cross build. The @samp{--disable-nls} option disables NLS.
ab87f8c8
JL
220
221@cindex @code{gettext}
222@item --with-included-gettext
69fe169e
PT
223If NLS is enbled, the @samp{--with-included-gettext} option causes the build
224procedure to prefer its copy of GNU @code{gettext}. This is the default. If
225you want the GCC build procedure to prefer the host's @code{gettext}
226libraries, use @samp{--without-included-gettext}.
ab87f8c8
JL
227
228@cindex @code{catgets}
229@item --with-catgets
230If NLS is enabled, and if the host lacks @code{gettext} but has the
231inferior @code{catgets} interface, the GCC build procedure normally
232ignores @code{catgets} and instead uses GCC's copy of the GNU
233@code{gettext} library. The @samp{--with-catgets} option causes the
234build procedure to use the host's @code{catgets} in this situation.
f4ab28e3
MK
235
236@cindex Windows32 Registry support
237@item --enable-win32-registry
238@itemx --enable-win32-registry=@var{KEY}
239@itemx --disable-win32-registry
240The @samp{--enable-win32-registry} option enables Windows-hosted GCC
241to look up installations paths in the registry using the following key:
242
243@smallexample
244@code{HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\<KEY>}
245@end smallexample
246
247<KEY> defaults to GCC version number, and can be overridden by the
248@code{--enable-win32-registry=KEY} option. Vendors and distributors
249who use custom installers are encouraged to provide a different key,
250perhaps one comprised of vendor name and GCC version number, to
251avoid conflict with existing installations. This feature is enabled
252by default, and can be disabled by @code{--disable-win32-registry}
253option. This option has no effect on the other hosts.
ab87f8c8
JL
254@end table
255
2284f91b
DE
256@item
257Build the compiler. Just type @samp{make LANGUAGES=c} in the compiler
258directory.
259
260@samp{LANGUAGES=c} specifies that only the C compiler should be
261compiled. The makefile normally builds compilers for all the supported
669ed2b1
UD
262languages; currently, C, C++, Objective C, Java, FORTRAN, and CHILL.
263However, C is the only language that is sure to work when you build with
264other non-GNU C compilers. In addition, building anything but C at this
265stage is a waste of time.
2284f91b
DE
266
267In general, you can specify the languages to build by typing the
268argument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or more
669ed2b1
UD
269words from the list @samp{c}, @samp{c++}, @samp{objective-c},
270@samp{java}, @samp{f77}, and @samp{CHILL}. If you have any additional
271GNU compilers as subdirectories of the GNU CC source directory, you may
272also specify their names in this list.
2284f91b
DE
273
274Ignore any warnings you may see about ``statement not reached'' in
275@file{insn-emit.c}; they are normal. Also, warnings about ``unknown
276escape sequence'' are normal in @file{genopinit.c} and perhaps some
277other files. Likewise, you should ignore warnings about ``constant is
278so large that it is unsigned'' in @file{insn-emit.c} and
86702e31
ZW
279@file{insn-recog.c}, and a warning about a comparison always being zero
280in @file{enquire.o}. Any other compilation errors may represent bugs in
2284f91b
DE
281the port to your machine or operating system, and
282@ifclear INSTALLONLY
283should be investigated and reported (@pxref{Bugs}).
284@end ifclear
285@ifset INSTALLONLY
286should be investigated and reported.
287@end ifset
288
ab87f8c8
JL
289Some compilers fail to compile GNU CC because they have bugs or
290limitations. For example, the Microsoft compiler is said to run out of
291macro space. Some Ultrix compilers run out of expression space; then
2284f91b
DE
292you need to break up the statement where the problem happens.
293
294@item
295If you are building a cross-compiler, stop here. @xref{Cross-Compiler}.
296
297@cindex stage1
298@item
299Move the first-stage object files and executables into a subdirectory
300with this command:
301
302@smallexample
303make stage1
304@end smallexample
305
306The files are moved into a subdirectory named @file{stage1}.
307Once installation is complete, you may wish to delete these files
308with @code{rm -r stage1}.
309
310@item
311If you have chosen a configuration for GNU CC which requires other GNU
312tools (such as GAS or the GNU linker) instead of the standard system
313tools, install the required tools in the @file{stage1} subdirectory
314under the names @file{as}, @file{ld} or whatever is appropriate. This
315will enable the stage 1 compiler to find the proper tools in the
316following stage.
317
318Alternatively, you can do subsequent compilation using a value of the
319@code{PATH} environment variable such that the necessary GNU tools come
320before the standard system tools.
321
322@item
323Recompile the compiler with itself, with this command:
324
325@smallexample
326make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2"
327@end smallexample
328
329This is called making the stage 2 compiler.
330
331The command shown above builds compilers for all the supported
332languages. If you don't want them all, you can specify the languages to
333build by typing the argument @samp{LANGUAGES="@var{list}"}. @var{list}
334should contain one or more words from the list @samp{c}, @samp{c++},
335@samp{objective-c}, and @samp{proto}. Separate the words with spaces.
336@samp{proto} stands for the programs @code{protoize} and
337@code{unprotoize}; they are not a separate language, but you use
338@code{LANGUAGES} to enable or disable their installation.
339
340If you are going to build the stage 3 compiler, then you might want to
341build only the C language in stage 2.
342
343Once you have built the stage 2 compiler, if you are short of disk
344space, you can delete the subdirectory @file{stage1}.
345
346On a 68000 or 68020 system lacking floating point hardware,
347unless you have selected a @file{tm.h} file that expects by default
348that there is no such hardware, do this instead:
349
350@smallexample
351make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2 -msoft-float"
352@end smallexample
353
354@item
355If you wish to test the compiler by compiling it with itself one more
356time, install any other necessary GNU tools (such as GAS or the GNU
357linker) in the @file{stage2} subdirectory as you did in the
358@file{stage1} subdirectory, then do this:
359
360@smallexample
361make stage2
362make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2"
363@end smallexample
364
365@noindent
366This is called making the stage 3 compiler. Aside from the @samp{-B}
367option, the compiler options should be the same as when you made the
368stage 2 compiler. But the @code{LANGUAGES} option need not be the
369same. The command shown above builds compilers for all the supported
370languages; if you don't want them all, you can specify the languages to
371build by typing the argument @samp{LANGUAGES="@var{list}"}, as described
372above.
373
374If you do not have to install any additional GNU tools, you may use the
375command
376
377@smallexample
378make bootstrap LANGUAGES=@var{language-list} BOOT_CFLAGS=@var{option-list}
379@end smallexample
380
381@noindent
382instead of making @file{stage1}, @file{stage2}, and performing
383the two compiler builds.
384
385@item
ab87f8c8
JL
386Compare the latest object files with the stage 2 object files---they
387ought to be identical, aside from time stamps (if any).
2284f91b
DE
388
389On some systems, meaningful comparison of object files is impossible;
390they always appear ``different.'' This is currently true on Solaris and
391some systems that use ELF object file format. On some versions of Irix
392on SGI machines and DEC Unix (OSF/1) on Alpha systems, you will not be
393able to compare the files without specifying @file{-save-temps}; see the
394description of individual systems above to see if you get comparison
395failures. You may have similar problems on other systems.
396
397Use this command to compare the files:
398
399@smallexample
400make compare
401@end smallexample
402
403This will mention any object files that differ between stage 2 and stage
4043. Any difference, no matter how innocuous, indicates that the stage 2
405compiler has compiled GNU CC incorrectly, and is therefore a potentially
406@ifclear INSTALLONLY
407serious bug which you should investigate and report (@pxref{Bugs}).
408@end ifclear
409@ifset INSTALLONLY
410serious bug which you should investigate and report.
411@end ifset
412
413If your system does not put time stamps in the object files, then this
414is a faster way to compare them (using the Bourne shell):
415
416@smallexample
417for file in *.o; do
418cmp $file stage2/$file
419done
420@end smallexample
421
422If you have built the compiler with the @samp{-mno-mips-tfile} option on
423MIPS machines, you will not be able to compare the files.
424
425@item
426Install the compiler driver, the compiler's passes and run-time support
427with @samp{make install}. Use the same value for @code{CC},
428@code{CFLAGS} and @code{LANGUAGES} that you used when compiling the
429files that are being installed. One reason this is necessary is that
430some versions of Make have bugs and recompile files gratuitously when
431you do this step. If you use the same variable values, those files will
432be recompiled properly.
433
434For example, if you have built the stage 2 compiler, you can use the
435following command:
436
437@smallexample
438make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES="@var{list}"
439@end smallexample
440
441@noindent
442This copies the files @file{cc1}, @file{cpp} and @file{libgcc.a} to
443files @file{cc1}, @file{cpp} and @file{libgcc.a} in the directory
444@file{/usr/local/lib/gcc-lib/@var{target}/@var{version}}, which is where
445the compiler driver program looks for them. Here @var{target} is the
e5e809f4
JL
446canonicalized form of target machine type specified when you ran
447@file{configure}, and @var{version} is the version number of GNU CC.
448This naming scheme permits various versions and/or cross-compilers to
449coexist. It also copies the executables for compilers for other
450languages (e.g., @file{cc1plus} for C++) to the same directory.
2284f91b
DE
451
452This also copies the driver program @file{xgcc} into
453@file{/usr/local/bin/gcc}, so that it appears in typical execution
454search paths. It also copies @file{gcc.1} into
455@file{/usr/local/man/man1} and info pages into @file{/usr/local/info}.
456
457On some systems, this command causes recompilation of some files. This
458is usually due to bugs in @code{make}. You should either ignore this
459problem, or use GNU Make.
460
2284f91b
DE
461(It is usually better to install GNU CC executables from stage 2 or 3,
462since they usually run faster than the ones compiled with some other
463compiler.)
464
2284f91b
DE
465@item
466GNU CC includes a runtime library for Objective-C because it is an
467integral part of the language. You can find the files associated with
468the library in the subdirectory @file{objc}. The GNU Objective-C
469Runtime Library requires header files for the target's C library in
470order to be compiled,and also requires the header files for the target's
471thread library if you want thread support. @xref{Cross Headers,
472Cross-Compilers and Header Files, Cross-Compilers and Header Files}, for
473discussion about header files issues for cross-compilation.
474
475When you run @file{configure}, it picks the appropriate Objective-C
476thread implementation file for the target platform. In some situations,
477you may wish to choose a different back-end as some platforms support
478multiple thread implementations or you may wish to disable thread
479support completely. You do this by specifying a value for the
480@var{OBJC_THREAD_FILE} makefile variable on the command line when you
481run make, for example:
482
483@smallexample
484make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" OBJC_THREAD_FILE=thr-single
485@end smallexample
486
487@noindent
488Below is a list of the currently available back-ends.
489
490@itemize @bullet
491@item thr-single
492Disable thread support, should work for all platforms.
493@item thr-decosf1
494DEC OSF/1 thread support.
495@item thr-irix
496SGI IRIX thread support.
497@item thr-mach
498Generic MACH thread support, known to work on NEXTSTEP.
499@item thr-os2
500IBM OS/2 thread support.
501@item thr-posix
502Generix POSIX thread support.
503@item thr-pthreads
504PCThreads on Linux-based GNU systems.
505@item thr-solaris
506SUN Solaris thread support.
507@item thr-win32
508Microsoft Win32 API thread support.
509@end itemize
510@end enumerate
511
ab87f8c8
JL
512@node Configuration Files
513@section Files Created by @code{configure}
514
515Here we spell out what files will be set up by @code{configure}. Normally
516you need not be concerned with these files.
517
518@itemize @bullet
519@item
520@ifset INTERNALS
521A file named @file{config.h} is created that contains a @samp{#include}
522of the top-level config file for the machine you will run the compiler
523on (@pxref{Config}). This file is responsible for defining information
524about the host machine. It includes @file{tm.h}.
525@end ifset
526@ifclear INTERNALS
527A file named @file{config.h} is created that contains a @samp{#include}
528of the top-level config file for the machine you will run the compiler
529on (@pxref{Config,,The Configuration File, gcc.info, Using and Porting
530GCC}). This file is responsible for defining information about the host
531machine. It includes @file{tm.h}.
532@end ifclear
533
534The top-level config file is located in the subdirectory @file{config}.
535Its name is always @file{xm-@var{something}.h}; usually
536@file{xm-@var{machine}.h}, but there are some exceptions.
537
538If your system does not support symbolic links, you might want to
539set up @file{config.h} to contain a @samp{#include} command which
540refers to the appropriate file.
541
542@item
543A file named @file{tconfig.h} is created which includes the top-level config
544file for your target machine. This is used for compiling certain
545programs to run on that machine.
546
547@item
548A file named @file{tm.h} is created which includes the
549machine-description macro file for your target machine. It should be in
550the subdirectory @file{config} and its name is often
551@file{@var{machine}.h}.
552
553@item
554The command file @file{configure} also constructs the file
555@file{Makefile} by adding some text to the template file
556@file{Makefile.in}. The additional text comes from files in the
557@file{config} directory, named @file{t-@var{target}} and
558@file{x-@var{host}}. If these files do not exist, it means nothing
559needs to be added for a given target or host.
560@end itemize
561
2284f91b
DE
562@node Configurations
563@section Configurations Supported by GNU CC
564@cindex configurations supported by GNU CC
565
566Here are the possible CPU types:
567
568@quotation
55383d87 569@c gmicro, fx80, spur and tahoe omitted since they don't work.
052a4b28 5701750a, a29k, alpha, arm, avr, c@var{n}, clipper, dsp16xx, elxsi, fr30, h8300,
55383d87 571hppa1.0, hppa1.1, i370, i386, i486, i586, i686, i786, i860, i960, m32r,
2856c3e3
SC
572m68000, m68k, m6811, m6812, m88k, mcore, mips, mipsel, mips64, mips64el,
573mn10200, mn10300, ns32k, pdp11, powerpc, powerpcle, romp, rs6000, sh, sparc,
574sparclite, sparc64, v850, vax, we32k.
2284f91b
DE
575@end quotation
576
577Here are the recognized company names. As you can see, customary
578abbreviations are used rather than the longer official names.
579
580@c What should be done about merlin, tek*, dolphin?
581@quotation
582acorn, alliant, altos, apollo, apple, att, bull,
583cbm, convergent, convex, crds, dec, dg, dolphin,
584elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi,
585mips, motorola, ncr, next, ns, omron, plexus,
586sequent, sgi, sony, sun, tti, unicom, wrs.
587@end quotation
588
589The company name is meaningful only to disambiguate when the rest of
590the information supplied is insufficient. You can omit it, writing
591just @samp{@var{cpu}-@var{system}}, if it is not needed. For example,
592@samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}.
593
594Here is a list of system types:
595
596@quotation
0c82f6bf 597386bsd, aix, acis, amigaos, aos, aout, aux, bosx, bsd, clix, coff, ctix, cxux,
57119aa9
ZW
598dgux, dynix, ebmon, ecoff, elf, esix, freebsd, hms, genix, gnu, linux,
599linux-gnu, hiux, hpux, iris, irix, isc, luna, lynxos, mach, minix, msdos, mvs,
2284f91b
DE
600netbsd, newsos, nindy, ns, osf, osfrose, ptx, riscix, riscos, rtu, sco, sim,
601solaris, sunos, sym, sysv, udi, ultrix, unicos, uniplus, unos, vms, vsta,
602vxworks, winnt, xenix.
603@end quotation
604
605@noindent
606You can omit the system type; then @file{configure} guesses the
607operating system from the CPU and company.
608
609You can add a version number to the system type; this may or may not
610make a difference. For example, you can write @samp{bsd4.3} or
611@samp{bsd4.4} to distinguish versions of BSD. In practice, the version
612number is most needed for @samp{sysv3} and @samp{sysv4}, which are often
613treated differently.
614
f49957d6
JL
615@samp{linux-gnu} is the canonical name for the GNU/Linux target; however
616GNU CC will also accept @samp{linux}. The version of the kernel in use is
617not relevant on these systems. A suffix such as @samp{libc1} or @samp{aout}
618distinguishes major versions of the C library; all of the suffixed versions
619are obsolete.
57119aa9 620
2284f91b
DE
621If you specify an impossible combination such as @samp{i860-dg-vms},
622then you may get an error message from @file{configure}, or it may
623ignore part of the information and do the best it can with the rest.
624@file{configure} always prints the canonical name for the alternative
625that it used. GNU CC does not support all possible alternatives.
626
627Often a particular model of machine has a name. Many machine names are
628recognized as aliases for CPU/company combinations. Thus, the machine
629name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}.
630Sometimes we accept a company name as a machine name, when the name is
631popularly used for a particular machine. Here is a table of the known
632machine names:
633
634@quotation
6353300, 3b1, 3b@var{n}, 7300, altos3068, altos,
636apollo68, att-7300, balance,
637convex-c@var{n}, crds, decstation-3100,
638decstation, delta, encore,
639fx2800, gmicro, hp7@var{nn}, hp8@var{nn},
640hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn},
641hp9k8@var{nn}, iris4d, iris, isi68,
642m3230, magnum, merlin, miniframe,
643mmax, news-3600, news800, news, next,
644pbd, pc532, pmax, powerpc, powerpcle, ps2, risc-news,
645rtpc, sun2, sun386i, sun386, sun3,
646sun4, symmetry, tower-32, tower.
647@end quotation
648
649@noindent
650Remember that a machine name specifies both the cpu type and the company
651name.
652If you want to install your own homemade configuration files, you can
653use @samp{local} as the company name to access them. If you use
654configuration @samp{@var{cpu}-local}, the configuration name
655without the cpu prefix
656is used to form the configuration file names.
657
658Thus, if you specify @samp{m68k-local}, configuration uses
659files @file{m68k.md}, @file{local.h}, @file{m68k.c},
660@file{xm-local.h}, @file{t-local}, and @file{x-local}, all in the
661directory @file{config/m68k}.
662
663Here is a list of configurations that have special treatment or special
664things you must know:
665
666@table @samp
2284f91b
DE
667@item vax-dec-vms
668See @ref{VMS Install}, for details on how to install GNU CC on VMS.
2284f91b
DE
669@end table
670
671@node Other Dir
672@section Compilation in a Separate Directory
673@cindex other directory, compilation in
674@cindex compilation in a separate directory
675@cindex separate directory, compilation in
676
677If you wish to build the object files and executables in a directory
678other than the one containing the source files, here is what you must
679do differently:
680
681@enumerate
682@item
683Make sure you have a version of Make that supports the @code{VPATH}
684feature. (GNU Make supports it, as do Make versions on most BSD
685systems.)
686
687@item
688If you have ever run @file{configure} in the source directory, you must undo
689the configuration. Do this by running:
690
691@example
692make distclean
693@end example
694
695@item
696Go to the directory in which you want to build the compiler before
697running @file{configure}:
698
699@example
700mkdir gcc-sun3
701cd gcc-sun3
702@end example
703
704On systems that do not support symbolic links, this directory must be
705on the same file system as the source code directory.
706
707@item
708Specify where to find @file{configure} when you run it:
709
710@example
711../gcc/configure @dots{}
712@end example
713
714This also tells @code{configure} where to find the compiler sources;
715@code{configure} takes the directory from the file name that was used to
716invoke it. But if you want to be sure, you can specify the source
717directory with the @samp{--srcdir} option, like this:
718
719@example
720../gcc/configure --srcdir=../gcc @var{other options}
721@end example
722
723The directory you specify with @samp{--srcdir} need not be the same
724as the one that @code{configure} is found in.
725@end enumerate
726
727Now, you can run @code{make} in that directory. You need not repeat the
728configuration steps shown above, when ordinary source files change. You
729must, however, run @code{configure} again when the configuration files
730change, if your system does not support symbolic links.
731
732@node Cross-Compiler
733@section Building and Installing a Cross-Compiler
734@cindex cross-compiler, installation
735
736GNU CC can function as a cross-compiler for many machines, but not all.
737
738@itemize @bullet
739@item
740Cross-compilers for the Mips as target using the Mips assembler
741currently do not work, because the auxiliary programs
742@file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled on
743anything but a Mips. It does work to cross compile for a Mips
744if you use the GNU assembler and linker.
745
746@item
747Cross-compilers between machines with different floating point formats
748have not all been made to work. GNU CC now has a floating point
749emulator with which these can work, but each target machine description
750needs to be updated to take advantage of it.
751
752@item
753Cross-compilation between machines of different word sizes is
754somewhat problematic and sometimes does not work.
755@end itemize
756
757Since GNU CC generates assembler code, you probably need a
758cross-assembler that GNU CC can run, in order to produce object files.
759If you want to link on other than the target machine, you need a
760cross-linker as well. You also need header files and libraries suitable
761for the target machine that you can install on the host machine.
762
763@menu
764* Steps of Cross:: Using a cross-compiler involves several steps
765 that may be carried out on different machines.
766* Configure Cross:: Configuring a cross-compiler.
767* Tools and Libraries:: Where to put the linker and assembler, and the C library.
768* Cross Headers:: Finding and installing header files
769 for a cross-compiler.
2284f91b
DE
770* Build Cross:: Actually compiling the cross-compiler.
771@end menu
772
773@node Steps of Cross
774@subsection Steps of Cross-Compilation
775
776To compile and run a program using a cross-compiler involves several
777steps:
778
779@itemize @bullet
780@item
781Run the cross-compiler on the host machine to produce assembler files
782for the target machine. This requires header files for the target
783machine.
784
785@item
786Assemble the files produced by the cross-compiler. You can do this
787either with an assembler on the target machine, or with a
788cross-assembler on the host machine.
789
790@item
791Link those files to make an executable. You can do this either with a
792linker on the target machine, or with a cross-linker on the host
793machine. Whichever machine you use, you need libraries and certain
794startup files (typically @file{crt@dots{}.o}) for the target machine.
795@end itemize
796
797It is most convenient to do all of these steps on the same host machine,
798since then you can do it all with a single invocation of GNU CC. This
799requires a suitable cross-assembler and cross-linker. For some targets,
800the GNU assembler and linker are available.
801
802@node Configure Cross
803@subsection Configuring a Cross-Compiler
804
805To build GNU CC as a cross-compiler, you start out by running
806@file{configure}. Use the @samp{--target=@var{target}} to specify the
807target type. If @file{configure} was unable to correctly identify the
808system you are running on, also specify the @samp{--build=@var{build}}
809option. For example, here is how to configure for a cross-compiler that
810produces code for an HP 68030 system running BSD on a system that
811@file{configure} can correctly identify:
812
813@smallexample
814./configure --target=m68k-hp-bsd4.3
815@end smallexample
816
817@node Tools and Libraries
818@subsection Tools and Libraries for a Cross-Compiler
819
820If you have a cross-assembler and cross-linker available, you should
821install them now. Put them in the directory
822@file{/usr/local/@var{target}/bin}. Here is a table of the tools
823you should put in this directory:
824
825@table @file
826@item as
827This should be the cross-assembler.
828
829@item ld
830This should be the cross-linker.
831
832@item ar
833This should be the cross-archiver: a program which can manipulate
834archive files (linker libraries) in the target machine's format.
835
836@item ranlib
837This should be a program to construct a symbol table in an archive file.
838@end table
839
840The installation of GNU CC will find these programs in that directory,
841and copy or link them to the proper place to for the cross-compiler to
842find them when run later.
843
844The easiest way to provide these files is to build the Binutils package
845and GAS. Configure them with the same @samp{--host} and @samp{--target}
846options that you use for configuring GNU CC, then build and install
847them. They install their executables automatically into the proper
848directory. Alas, they do not support all the targets that GNU CC
849supports.
850
851If you want to install libraries to use with the cross-compiler, such as
852a standard C library, put them in the directory
853@file{/usr/local/@var{target}/lib}; installation of GNU CC copies
854all the files in that subdirectory into the proper place for GNU CC to
855find them and link with them. Here's an example of copying some
856libraries from a target machine:
857
858@example
859ftp @var{target-machine}
860lcd /usr/local/@var{target}/lib
861cd /lib
862get libc.a
863cd /usr/lib
864get libg.a
865get libm.a
866quit
867@end example
868
869@noindent
870The precise set of libraries you'll need, and their locations on
871the target machine, vary depending on its operating system.
872
873@cindex start files
874Many targets require ``start files'' such as @file{crt0.o} and
875@file{crtn.o} which are linked into each executable; these too should be
876placed in @file{/usr/local/@var{target}/lib}. There may be several
877alternatives for @file{crt0.o}, for use with profiling or other
878compilation options. Check your target's definition of
879@code{STARTFILE_SPEC} to find out what start files it uses.
880Here's an example of copying these files from a target machine:
881
882@example
883ftp @var{target-machine}
884lcd /usr/local/@var{target}/lib
885prompt
886cd /lib
887mget *crt*.o
888cd /usr/lib
889mget *crt*.o
890quit
891@end example
892
2284f91b
DE
893@node Cross Headers
894@subsection Cross-Compilers and Header Files
895
896If you are cross-compiling a standalone program or a program for an
897embedded system, then you may not need any header files except the few
898that are part of GNU CC (and those of your program). However, if you
899intend to link your program with a standard C library such as
900@file{libc.a}, then you probably need to compile with the header files
901that go with the library you use.
902
903The GNU C compiler does not come with these files, because (1) they are
904system-specific, and (2) they belong in a C library, not in a compiler.
905
906If the GNU C library supports your target machine, then you can get the
907header files from there (assuming you actually use the GNU library when
908you link your program).
909
910If your target machine comes with a C compiler, it probably comes with
911suitable header files also. If you make these files accessible from the host
912machine, the cross-compiler can use them also.
913
914Otherwise, you're on your own in finding header files to use when
915cross-compiling.
916
917When you have found suitable header files, put them in the directory
918@file{/usr/local/@var{target}/include}, before building the cross
919compiler. Then installation will run fixincludes properly and install
920the corrected versions of the header files where the compiler will use
921them.
922
923Provide the header files before you build the cross-compiler, because
924the build stage actually runs the cross-compiler to produce parts of
925@file{libgcc.a}. (These are the parts that @emph{can} be compiled with
926GNU CC.) Some of them need suitable header files.
927
928Here's an example showing how to copy the header files from a target
929machine. On the target machine, do this:
930
931@example
932(cd /usr/include; tar cf - .) > tarfile
933@end example
934
935Then, on the host machine, do this:
936
937@example
938ftp @var{target-machine}
939lcd /usr/local/@var{target}/include
940get tarfile
941quit
942tar xf tarfile
943@end example
944
945@node Build Cross
946@subsection Actually Building the Cross-Compiler
947
948Now you can proceed just as for compiling a single-machine compiler
7857f134
ZW
949through the step of building stage 1.
950
951If your target is exotic, you may need to provide the header file
952@file{float.h}.One way to do this is to compile @file{enquire} and run
953it on your target machine. The job of @file{enquire} is to run on the
954target machine and figure out by experiment the nature of its floating
955point representation. @file{enquire} records its findings in the header
956file @file{float.h}. If you can't produce this file by running
957@file{enquire} on the target machine, then you will need to come up with
958a suitable @file{float.h} in some other way (or else, avoid using it in
959your programs).
2284f91b
DE
960
961Do not try to build stage 2 for a cross-compiler. It doesn't work to
962rebuild GNU CC as a cross-compiler using the cross-compiler, because
963that would produce a program that runs on the target machine, not on the
964host. For example, if you compile a 386-to-68030 cross-compiler with
965itself, the result will not be right either for the 386 (because it was
966compiled into 68030 code) or for the 68030 (because it was configured
967for a 386 as the host). If you want to compile GNU CC into 68030 code,
968whether you compile it on a 68030 or with a cross-compiler on a 386, you
969must specify a 68030 as the host when you configure it.
970
971To install the cross-compiler, use @samp{make install}, as usual.
972
2284f91b
DE
973@node VMS Install
974@section Installing GNU CC on VMS
975@cindex VMS installation
976@cindex installing GNU CC on VMS
977
978The VMS version of GNU CC is distributed in a backup saveset containing
979both source code and precompiled binaries.
980
981To install the @file{gcc} command so you can use the compiler easily, in
982the same manner as you use the VMS C compiler, you must install the VMS CLD
983file for GNU CC as follows:
984
985@enumerate
986@item
987Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
988to point to the directories where the GNU CC executables
989(@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are
990kept respectively. This should be done with the commands:@refill
991
992@smallexample
993$ assign /system /translation=concealed -
994 disk:[gcc.] gnu_cc
995$ assign /system /translation=concealed -
996 disk:[gcc.include.] gnu_cc_include
997@end smallexample
998
999@noindent
1000with the appropriate disk and directory names. These commands can be
1001placed in your system startup file so they will be executed whenever
1002the machine is rebooted. You may, if you choose, do this via the
1003@file{GCC_INSTALL.COM} script in the @file{[GCC]} directory.
1004
1005@item
1006Install the @file{GCC} command with the command line:
1007
1008@smallexample
1009$ set command /table=sys$common:[syslib]dcltables -
1010 /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
1011$ install replace sys$common:[syslib]dcltables
1012@end smallexample
1013
1014@item
1015To install the help file, do the following:
1016
1017@smallexample
1018$ library/help sys$library:helplib.hlb gcc.hlp
1019@end smallexample
1020
1021@noindent
1022Now you can invoke the compiler with a command like @samp{gcc /verbose
1023file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
1024Unix.
1025@end enumerate
1026
1027If you wish to use GNU C++ you must first install GNU CC, and then
1028perform the following steps:
1029
1030@enumerate
1031@item
1032Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the
1033directory where the preprocessor will search for the C++ header files.
1034This can be done with the command:@refill
1035
1036@smallexample
1037$ assign /system /translation=concealed -
1038 disk:[gcc.gxx_include.] gnu_gxx_include
1039@end smallexample
1040
1041@noindent
1042with the appropriate disk and directory name. If you are going to be
c85f7c16
JL
1043using a C++ runtime library, this is where its install procedure will install
1044its header files.
2284f91b
DE
1045
1046@item
1047Obtain the file @file{gcc-cc1plus.exe}, and place this in the same
1048directory that @file{gcc-cc1.exe} is kept.
1049
1050The GNU C++ compiler can be invoked with a command like @samp{gcc /plus
1051/verbose file.cc}, which is equivalent to the command @samp{g++ -v -c
1052file.cc} in Unix.
1053@end enumerate
1054
1055We try to put corresponding binaries and sources on the VMS distribution
1056tape. But sometimes the binaries will be from an older version than the
1057sources, because we don't always have time to update them. (Use the
1058@samp{/version} option to determine the version number of the binaries and
1059compare it with the source file @file{version.c} to tell whether this is
1060so.) In this case, you should use the binaries you get to recompile the
1061sources. If you must recompile, here is how:
1062
1063@enumerate
1064@item
1065Execute the command procedure @file{vmsconfig.com} to set up the files
1066@file{tm.h}, @file{config.h}, @file{aux-output.c}, and @file{md.}, and
1067to create files @file{tconfig.h} and @file{hconfig.h}. This procedure
1068also creates several linker option files used by @file{make-cc1.com} and
1069a data file used by @file{make-l2.com}.@refill
1070
1071@smallexample
1072$ @@vmsconfig.com
1073@end smallexample
1074
1075@item
1076Setup the logical names and command tables as defined above. In
1077addition, define the VMS logical name @samp{GNU_BISON} to point at the
1078to the directories where the Bison executable is kept. This should be
1079done with the command:@refill
1080
1081@smallexample
1082$ assign /system /translation=concealed -
1083 disk:[bison.] gnu_bison
1084@end smallexample
1085
1086You may, if you choose, use the @file{INSTALL_BISON.COM} script in the
1087@file{[BISON]} directory.
1088
1089@item
1090Install the @samp{BISON} command with the command line:@refill
1091
1092@smallexample
1093$ set command /table=sys$common:[syslib]dcltables -
1094 /output=sys$common:[syslib]dcltables -
1095 gnu_bison:[000000]bison
1096$ install replace sys$common:[syslib]dcltables
1097@end smallexample
1098
1099@item
1100Type @samp{@@make-gcc} to recompile everything (alternatively, submit
1101the file @file{make-gcc.com} to a batch queue). If you wish to build
1102the GNU C++ compiler as well as the GNU CC compiler, you must first edit
1103@file{make-gcc.com} and follow the instructions that appear in the
1104comments.@refill
1105
1106@item
1107In order to use GCC, you need a library of functions which GCC compiled code
1108will call to perform certain tasks, and these functions are defined in the
1109file @file{libgcc2.c}. To compile this you should use the command procedure
1110@file{make-l2.com}, which will generate the library @file{libgcc2.olb}.
1111@file{libgcc2.olb} should be built using the compiler built from
1112the same distribution that @file{libgcc2.c} came from, and
1113@file{make-gcc.com} will automatically do all of this for you.
1114
1115To install the library, use the following commands:@refill
1116
1117@smallexample
1118$ library gnu_cc:[000000]gcclib/delete=(new,eprintf)
1119$ library gnu_cc:[000000]gcclib/delete=L_*
1120$ library libgcc2/extract=*/output=libgcc2.obj
1121$ library gnu_cc:[000000]gcclib libgcc2.obj
1122@end smallexample
1123
1124The first command simply removes old modules that will be replaced with
1125modules from @file{libgcc2} under different module names. The modules
1126@code{new} and @code{eprintf} may not actually be present in your
1127@file{gcclib.olb}---if the VMS librarian complains about those modules
1128not being present, simply ignore the message and continue on with the
1129next command. The second command removes the modules that came from the
1130previous version of the library @file{libgcc2.c}.
1131
1132Whenever you update the compiler on your system, you should also update the
1133library with the above procedure.
1134
1135@item
1136You may wish to build GCC in such a way that no files are written to the
1137directory where the source files reside. An example would be the when
1138the source files are on a read-only disk. In these cases, execute the
1139following DCL commands (substituting your actual path names):
1140
1141@smallexample
1142$ assign dua0:[gcc.build_dir.]/translation=concealed, -
1143 dua1:[gcc.source_dir.]/translation=concealed gcc_build
1144$ set default gcc_build:[000000]
1145@end smallexample
1146
1147@noindent
1148where the directory @file{dua1:[gcc.source_dir]} contains the source
1149code, and the directory @file{dua0:[gcc.build_dir]} is meant to contain
1150all of the generated object files and executables. Once you have done
1151this, you can proceed building GCC as described above. (Keep in mind
1152that @file{gcc_build} is a rooted logical name, and thus the device
1153names in each element of the search list must be an actual physical
1154device name rather than another rooted logical name).
1155
1156@item
1157@strong{If you are building GNU CC with a previous version of GNU CC,
1158you also should check to see that you have the newest version of the
1159assembler}. In particular, GNU CC version 2 treats global constant
1160variables slightly differently from GNU CC version 1, and GAS version
11611.38.1 does not have the patches required to work with GCC version 2.
1162If you use GAS 1.38.1, then @code{extern const} variables will not have
1163the read-only bit set, and the linker will generate warning messages
1164about mismatched psect attributes for these variables. These warning
1165messages are merely a nuisance, and can safely be ignored.
1166
1167If you are compiling with a version of GNU CC older than 1.33, specify
1168@samp{/DEFINE=("inline=")} as an option in all the compilations. This
1169requires editing all the @code{gcc} commands in @file{make-cc1.com}.
1170(The older versions had problems supporting @code{inline}.) Once you
1171have a working 1.33 or newer GNU CC, you can change this file back.
1172
1173@item
1174If you want to build GNU CC with the VAX C compiler, you will need to
1175make minor changes in @file{make-cccp.com} and @file{make-cc1.com}
1176to choose alternate definitions of @code{CC}, @code{CFLAGS}, and
1177@code{LIBS}. See comments in those files. However, you must
1178also have a working version of the GNU assembler (GNU as, aka GAS) as
1179it is used as the back-end for GNU CC to produce binary object modules
1180and is not included in the GNU CC sources. GAS is also needed to
1181compile @file{libgcc2} in order to build @file{gcclib} (see above);
1182@file{make-l2.com} expects to be able to find it operational in
1183@file{gnu_cc:[000000]gnu-as.exe}.
1184
1185To use GNU CC on VMS, you need the VMS driver programs
1186@file{gcc.exe}, @file{gcc.com}, and @file{gcc.cld}. They are
1187distributed with the VMS binaries (@file{gcc-vms}) rather than the
1188GNU CC sources. GAS is also included in @file{gcc-vms}, as is Bison.
1189
1190Once you have successfully built GNU CC with VAX C, you should use the
1191resulting compiler to rebuild itself. Before doing this, be sure to
1192restore the @code{CC}, @code{CFLAGS}, and @code{LIBS} definitions in
1193@file{make-cccp.com} and @file{make-cc1.com}. The second generation
1194compiler will be able to take advantage of many optimizations that must
1195be suppressed when building with other compilers.
1196@end enumerate
1197
1198Under previous versions of GNU CC, the generated code would occasionally
1199give strange results when linked with the sharable @file{VAXCRTL} library.
1200Now this should work.
1201
1202Even with this version, however, GNU CC itself should not be linked with
1203the sharable @file{VAXCRTL}. The version of @code{qsort} in
1204@file{VAXCRTL} has a bug (known to be present in VMS versions V4.6
1205through V5.5) which causes the compiler to fail.
1206
1207The executables are generated by @file{make-cc1.com} and
1208@file{make-cccp.com} use the object library version of @file{VAXCRTL} in
1209order to make use of the @code{qsort} routine in @file{gcclib.olb}. If
1210you wish to link the compiler executables with the shareable image
1211version of @file{VAXCRTL}, you should edit the file @file{tm.h} (created
1212by @file{vmsconfig.com}) to define the macro @code{QSORT_WORKAROUND}.
1213
1214@code{QSORT_WORKAROUND} is always defined when GNU CC is compiled with
1215VAX C, to avoid a problem in case @file{gcclib.olb} is not yet
1216available.
1217
1218@node Collect2
1219@section @code{collect2}
1220
23851576
JL
1221GNU CC uses a utility called @code{collect2} on nearly all systems to arrange
1222to call various initialization functions at start time.
2284f91b
DE
1223
1224The program @code{collect2} works by linking the program once and
1225looking through the linker output file for symbols with particular names
1226indicating they are constructor functions. If it finds any, it
1227creates a new temporary @samp{.c} file containing a table of them,
1228compiles it, and links the program a second time including that file.
1229
1230@findex __main
1231@cindex constructors, automatic calls
1232The actual calls to the constructors are carried out by a subroutine
1233called @code{__main}, which is called (automatically) at the beginning
1234of the body of @code{main} (provided @code{main} was compiled with GNU
1235CC). Calling @code{__main} is necessary, even when compiling C code, to
1236allow linking C and C++ object code together. (If you use
1237@samp{-nostdlib}, you get an unresolved reference to @code{__main},
1238since it's defined in the standard GCC library. Include @samp{-lgcc} at
1239the end of your compiler command line to resolve this reference.)
1240
1241The program @code{collect2} is installed as @code{ld} in the directory
1242where the passes of the compiler are installed. When @code{collect2}
1243needs to find the @emph{real} @code{ld}, it tries the following file
1244names:
1245
1246@itemize @bullet
1247@item
1248@file{real-ld} in the directories listed in the compiler's search
1249directories.
1250
1251@item
1252@file{real-ld} in the directories listed in the environment variable
1253@code{PATH}.
1254
1255@item
1256The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
1257if specified.
1258
1259@item
1260@file{ld} in the compiler's search directories, except that
1261@code{collect2} will not execute itself recursively.
1262
1263@item
1264@file{ld} in @code{PATH}.
1265@end itemize
1266
1267``The compiler's search directories'' means all the directories where
1268@code{gcc} searches for passes of the compiler. This includes
1269directories that you specify with @samp{-B}.
1270
1271Cross-compilers search a little differently:
1272
1273@itemize @bullet
1274@item
1275@file{real-ld} in the compiler's search directories.
1276
1277@item
1278@file{@var{target}-real-ld} in @code{PATH}.
1279
1280@item
1281The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
1282if specified.
1283
1284@item
1285@file{ld} in the compiler's search directories.
1286
1287@item
1288@file{@var{target}-ld} in @code{PATH}.
1289@end itemize
1290
1291@code{collect2} explicitly avoids running @code{ld} using the file name
1292under which @code{collect2} itself was invoked. In fact, it remembers
1293up a list of such names---in case one copy of @code{collect2} finds
1294another copy (or version) of @code{collect2} installed as @code{ld} in a
1295second place in the search path.
1296
1297@code{collect2} searches for the utilities @code{nm} and @code{strip}
1298using the same algorithm as above for @code{ld}.
1299
1300@node Header Dirs
1301@section Standard Header File Directories
1302
1303@code{GCC_INCLUDE_DIR} means the same thing for native and cross. It is
1304where GNU CC stores its private include files, and also where GNU CC
1305stores the fixed include files. A cross compiled GNU CC runs
1306@code{fixincludes} on the header files in @file{$(tooldir)/include}.
1307(If the cross compilation header files need to be fixed, they must be
1308installed before GNU CC is built. If the cross compilation header files
5490d604 1309are already suitable for ISO C and GNU CC, nothing special need be
2284f91b
DE
1310done).
1311
0d9d12fc 1312@code{GPLUSPLUS_INCLUDE_DIR} means the same thing for native and cross. It
c85f7c16 1313is where @code{g++} looks first for header files. The C++ library
2284f91b
DE
1314installs only target independent header files in that directory.
1315
1316@code{LOCAL_INCLUDE_DIR} is used only for a native compiler. It is
1317normally @file{/usr/local/include}. GNU CC searches this directory so
1318that users can install header files in @file{/usr/local/include}.
1319
1320@code{CROSS_INCLUDE_DIR} is used only for a cross compiler. GNU CC
1321doesn't install anything there.
1322
1323@code{TOOL_INCLUDE_DIR} is used for both native and cross compilers. It
1324is the place for other packages to install header files that GNU CC will
1325use. For a cross-compiler, this is the equivalent of
1326@file{/usr/include}. When you build a cross-compiler,
1327@code{fixincludes} processes any header files in this directory.