OSDN Git Service

* doc/install-old.texi: Remove more documentation of configure
[pf3gnuchains/gcc-fork.git] / gcc / doc / install-old.texi
1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
4
5 @node Installation
6 @chapter Installing GNU CC
7 @cindex installing GNU CC
8
9 Note most of this information is out of date and superseded by the
10 new GCC install manual @file{gcc/doc/install.texi}.  It is
11 provided for historical reference only.
12
13 @menu
14 * Configuration Files::  Files created by running @code{configure}.
15 * Configurations::    Configurations Supported by GNU CC.
16 * Cross-Compiler::   Building and installing a cross-compiler.
17 * VMS Install::   See below for installation on VMS.
18 * Collect2::      How @code{collect2} works; how it finds @code{ld}.
19 * Header Dirs::   Understanding the standard header file directories.
20 @end menu
21
22 Here is the procedure for installing GNU CC on a GNU or Unix system.
23 See @ref{VMS Install}, for VMS systems.
24
25 @enumerate
26 @item
27 If you have chosen a configuration for GNU CC which requires other GNU
28 tools (such as GAS or the GNU linker) instead of the standard system
29 tools, install the required tools in the build directory under the names
30 @file{as}, @file{ld} or whatever is appropriate.  This will enable the
31 compiler to find the proper tools for compilation of the program
32 @file{enquire}.
33
34 Alternatively, you can do subsequent compilation using a value of the
35 @code{PATH} environment variable such that the necessary GNU tools come
36 before the standard system tools.
37
38 @item
39 Specify the host, build and target machine configurations.  You do this
40 when you run the @file{configure} script.
41
42 The @dfn{build} machine is the system which you are using, the
43 @dfn{host} machine is the system where you want to run the resulting
44 compiler (normally the build machine), and the @dfn{target} machine is
45 the system for which you want the compiler to generate code.
46
47 If you are building a compiler to produce code for the machine it runs
48 on (a native compiler), you normally do not need to specify any operands
49 to @file{configure}; it will try to guess the type of machine you are on
50 and use that as the build, host and target machines.  So you don't need
51 to specify a configuration when building a native compiler unless
52 @file{configure} cannot figure out what your configuration is or guesses
53 wrong.
54
55 In those cases, specify the build machine's @dfn{configuration name}
56 with the @option{--host} option; the host and target will default to be
57 the same as the host machine.  (If you are building a cross-compiler,
58 see @ref{Cross-Compiler}.)
59
60 Here is an example:
61
62 @smallexample
63 ./configure --host=sparc-sun-sunos4.1
64 @end smallexample
65
66 A configuration name may be canonical or it may be more or less
67 abbreviated.
68
69 A canonical configuration name has three parts, separated by dashes.
70 It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}.
71 (The three parts may themselves contain dashes; @file{configure}
72 can figure out which dashes serve which purpose.)  For example,
73 @samp{m68k-sun-sunos4.1} specifies a Sun 3.
74
75 You can also replace parts of the configuration by nicknames or aliases.
76 For example, @samp{sun3} stands for @samp{m68k-sun}, so
77 @samp{sun3-sunos4.1} is another way to specify a Sun 3.
78
79 You can specify a version number after any of the system types, and some
80 of the CPU types.  In most cases, the version is irrelevant, and will be
81 ignored.  So you might as well specify the version if you know it.
82
83 See @ref{Configurations}, for a list of supported configuration names and
84 notes on many of the configurations.  You should check the notes in that
85 section before proceeding any further with the installation of GNU CC.
86
87 @end enumerate
88
89 @node Configuration Files
90 @section Files Created by @code{configure}
91
92 Here we spell out what files will be set up by @code{configure}.  Normally
93 you need not be concerned with these files.
94
95 @itemize @bullet
96 @item
97 @ifset INTERNALS
98 A file named @file{config.h} is created that contains a @samp{#include}
99 of the top-level config file for the machine you will run the compiler
100 on (@pxref{Config}).  This file is responsible for defining information
101 about the host machine.  It includes @file{tm.h}.
102 @end ifset
103 @ifclear INTERNALS
104 A file named @file{config.h} is created that contains a @samp{#include}
105 of the top-level config file for the machine you will run the compiler
106 on (@pxref{Config,,The Configuration File, gcc.info, Using and Porting
107 GCC}).  This file is responsible for defining information about the host
108 machine.  It includes @file{tm.h}.
109 @end ifclear
110
111 The top-level config file is located in the subdirectory @file{config}.
112 Its name is always @file{xm-@var{something}.h}; usually
113 @file{xm-@var{machine}.h}, but there are some exceptions.
114
115 If your system does not support symbolic links, you might want to
116 set up @file{config.h} to contain a @samp{#include} command which
117 refers to the appropriate file.
118
119 @item
120 A file named @file{tconfig.h} is created which includes the top-level config
121 file for your target machine.  This is used for compiling certain
122 programs to run on that machine.
123
124 @item
125 A file named @file{tm.h} is created which includes the
126 machine-description macro file for your target machine.  It should be in
127 the subdirectory @file{config} and its name is often
128 @file{@var{machine}.h}.
129
130 @item
131 The command file @file{configure} also constructs the file
132 @file{Makefile} by adding some text to the template file
133 @file{Makefile.in}.  The additional text comes from files in the
134 @file{config} directory, named @file{t-@var{target}} and
135 @file{x-@var{host}}.  If these files do not exist, it means nothing
136 needs to be added for a given target or host.
137 @end itemize
138
139 @node Configurations
140 @section Configurations Supported by GNU CC
141 @cindex configurations supported by GNU CC
142
143 Here are the possible CPU types:
144
145 @quotation
146 @c gmicro, fx80, spur and tahoe omitted since they don't work.
147 1750a, a29k, alpha, arm, avr, c@var{n}, clipper, dsp16xx, elxsi, fr30, h8300,
148 hppa1.0, hppa1.1, i370, i386, i486, i586, i686, i786, i860, i960, m32r,
149 m68000, m68k, m6811, m6812, m88k, mcore, mips, mipsel, mips64, mips64el,
150 mn10200, mn10300, ns32k, pdp11, powerpc, powerpcle, romp, rs6000, sh, sparc,
151 sparclite, sparc64, v850, vax, we32k.
152 @end quotation
153
154 Here are the recognized company names.  As you can see, customary
155 abbreviations are used rather than the longer official names.
156
157 @c What should be done about merlin, tek*, dolphin?
158 @quotation
159 acorn, alliant, altos, apollo, apple, att, bull,
160 cbm, convergent, convex, crds, dec, dg, dolphin,
161 elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi,
162 mips, motorola, ncr, next, ns, omron, plexus,
163 sequent, sgi, sony, sun, tti, unicom, wrs.
164 @end quotation
165
166 The company name is meaningful only to disambiguate when the rest of
167 the information supplied is insufficient.  You can omit it, writing
168 just @samp{@var{cpu}-@var{system}}, if it is not needed.  For example,
169 @samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}.
170
171 Here is a list of system types:
172
173 @quotation
174 386bsd, aix, acis, amigaos, aos, aout, aux, bosx, bsd, clix, coff, ctix, cxux,
175 dgux, dynix, ebmon, ecoff, elf, esix, freebsd, hms, genix, gnu, linux,
176 linux-gnu, hiux, hpux, iris, irix, isc, luna, lynxos, mach, minix, msdos, mvs,
177 netbsd, newsos, nindy, ns, osf, osfrose, ptx, riscix, riscos, rtu, sco, sim,
178 solaris, sunos, sym, sysv, udi, ultrix, unicos, uniplus, unos, vms, vsta,
179 vxworks, winnt, xenix.
180 @end quotation
181
182 @noindent
183 You can omit the system type; then @file{configure} guesses the
184 operating system from the CPU and company.
185
186 You can add a version number to the system type; this may or may not
187 make a difference.  For example, you can write @samp{bsd4.3} or
188 @samp{bsd4.4} to distinguish versions of BSD.  In practice, the version
189 number is most needed for @samp{sysv3} and @samp{sysv4}, which are often
190 treated differently.
191
192 @samp{linux-gnu} is the canonical name for the GNU/Linux target; however
193 GNU CC will also accept @samp{linux}.  The version of the kernel in use is
194 not relevant on these systems.  A suffix such as @samp{libc1} or @samp{aout}
195 distinguishes major versions of the C library; all of the suffixed versions
196 are obsolete.
197
198 If you specify an impossible combination such as @samp{i860-dg-vms},
199 then you may get an error message from @file{configure}, or it may
200 ignore part of the information and do the best it can with the rest.
201 @file{configure} always prints the canonical name for the alternative
202 that it used.  GNU CC does not support all possible alternatives.
203
204 Often a particular model of machine has a name.  Many machine names are
205 recognized as aliases for CPU/company combinations.  Thus, the machine
206 name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}.
207 Sometimes we accept a company name as a machine name, when the name is
208 popularly used for a particular machine.  Here is a table of the known
209 machine names:
210
211 @quotation
212 3300, 3b1, 3b@var{n}, 7300, altos3068, altos,
213 apollo68, att-7300, balance,
214 convex-c@var{n}, crds, decstation-3100,
215 decstation, delta, encore,
216 fx2800, gmicro, hp7@var{nn}, hp8@var{nn},
217 hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn},
218 hp9k8@var{nn}, iris4d, iris, isi68,
219 m3230, magnum, merlin, miniframe,
220 mmax, news-3600, news800, news, next,
221 pbd, pc532, pmax, powerpc, powerpcle, ps2, risc-news,
222 rtpc, sun2, sun386i, sun386, sun3,
223 sun4, symmetry, tower-32, tower.
224 @end quotation
225
226 @noindent
227 Remember that a machine name specifies both the cpu type and the company
228 name.
229 If you want to install your own homemade configuration files, you can
230 use @samp{local} as the company name to access them.  If you use
231 configuration @samp{@var{cpu}-local}, the configuration name
232 without the cpu prefix
233 is used to form the configuration file names.
234
235 Thus, if you specify @samp{m68k-local}, configuration uses
236 files @file{m68k.md}, @file{local.h}, @file{m68k.c},
237 @file{xm-local.h}, @file{t-local}, and @file{x-local}, all in the
238 directory @file{config/m68k}.
239
240 Here is a list of configurations that have special treatment or special
241 things you must know:
242
243 @table @samp
244 @item vax-dec-vms
245 See @ref{VMS Install}, for details on how to install GNU CC on VMS.
246 @end table
247
248 @node Cross-Compiler
249 @section Building and Installing a Cross-Compiler
250 @cindex cross-compiler, installation
251
252 GNU CC can function as a cross-compiler for many machines, but not all.
253
254 @itemize @bullet
255 @item
256 Cross-compilers for the Mips as target using the Mips assembler
257 currently do not work, because the auxiliary programs
258 @file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled on
259 anything but a Mips.  It does work to cross compile for a Mips
260 if you use the GNU assembler and linker.
261
262 @item
263 Cross-compilers between machines with different floating point formats
264 have not all been made to work.  GNU CC now has a floating point
265 emulator with which these can work, but each target machine description
266 needs to be updated to take advantage of it.
267
268 @item
269 Cross-compilation between machines of different word sizes is
270 somewhat problematic and sometimes does not work.
271 @end itemize
272
273 Since GNU CC generates assembler code, you probably need a
274 cross-assembler that GNU CC can run, in order to produce object files.
275 If you want to link on other than the target machine, you need a
276 cross-linker as well.  You also need header files and libraries suitable
277 for the target machine that you can install on the host machine.
278
279 @menu
280 * Steps of Cross::      Using a cross-compiler involves several steps
281                           that may be carried out on different machines.
282 * Configure Cross::     Configuring a cross-compiler.
283 * Tools and Libraries:: Where to put the linker and assembler, and the C library.
284 * Cross Headers::       Finding and installing header files
285                           for a cross-compiler.
286 * Build Cross::         Actually compiling the cross-compiler.
287 @end menu
288
289 @node Steps of Cross
290 @subsection Steps of Cross-Compilation
291
292 To compile and run a program using a cross-compiler involves several
293 steps:
294
295 @itemize @bullet
296 @item
297 Run the cross-compiler on the host machine to produce assembler files
298 for the target machine.  This requires header files for the target
299 machine.
300
301 @item
302 Assemble the files produced by the cross-compiler.  You can do this
303 either with an assembler on the target machine, or with a
304 cross-assembler on the host machine.
305
306 @item
307 Link those files to make an executable.  You can do this either with a
308 linker on the target machine, or with a cross-linker on the host
309 machine.  Whichever machine you use, you need libraries and certain
310 startup files (typically @file{crt@dots{}.o}) for the target machine.
311 @end itemize
312
313 It is most convenient to do all of these steps on the same host machine,
314 since then you can do it all with a single invocation of GNU CC.  This
315 requires a suitable cross-assembler and cross-linker.  For some targets,
316 the GNU assembler and linker are available.
317
318 @node Configure Cross
319 @subsection Configuring a Cross-Compiler
320
321 To build GNU CC as a cross-compiler, you start out by running
322 @file{configure}.  Use the @option{--target=@var{target}} to specify the
323 target type.  If @file{configure} was unable to correctly identify the
324 system you are running on, also specify the @option{--build=@var{build}}
325 option.  For example, here is how to configure for a cross-compiler that
326 produces code for an HP 68030 system running BSD on a system that
327 @file{configure} can correctly identify:
328
329 @smallexample
330 ./configure --target=m68k-hp-bsd4.3
331 @end smallexample
332
333 @node Tools and Libraries
334 @subsection Tools and Libraries for a Cross-Compiler
335
336 If you have a cross-assembler and cross-linker available, you should
337 install them now.  Put them in the directory
338 @file{/usr/local/@var{target}/bin}.  Here is a table of the tools
339 you should put in this directory:
340
341 @table @file
342 @item as
343 This should be the cross-assembler.
344
345 @item ld
346 This should be the cross-linker.
347
348 @item ar
349 This should be the cross-archiver: a program which can manipulate
350 archive files (linker libraries) in the target machine's format.
351
352 @item ranlib
353 This should be a program to construct a symbol table in an archive file.
354 @end table
355
356 The installation of GNU CC will find these programs in that directory,
357 and copy or link them to the proper place to for the cross-compiler to
358 find them when run later.
359
360 The easiest way to provide these files is to build the Binutils package
361 and GAS.  Configure them with the same @option{--host} and @option{--target}
362 options that you use for configuring GNU CC, then build and install
363 them.  They install their executables automatically into the proper
364 directory.  Alas, they do not support all the targets that GNU CC
365 supports.
366
367 If you want to install libraries to use with the cross-compiler, such as
368 a standard C library, put them in the directory
369 @file{/usr/local/@var{target}/lib}; installation of GNU CC copies
370 all the files in that subdirectory into the proper place for GNU CC to
371 find them and link with them.  Here's an example of copying some
372 libraries from a target machine:
373
374 @example
375 ftp @var{target-machine}
376 lcd /usr/local/@var{target}/lib
377 cd /lib
378 get libc.a
379 cd /usr/lib
380 get libg.a
381 get libm.a
382 quit
383 @end example
384
385 @noindent
386 The precise set of libraries you'll need, and their locations on
387 the target machine, vary depending on its operating system.
388
389 @cindex start files
390 Many targets require ``start files'' such as @file{crt0.o} and
391 @file{crtn.o} which are linked into each executable; these too should be
392 placed in @file{/usr/local/@var{target}/lib}.  There may be several
393 alternatives for @file{crt0.o}, for use with profiling or other
394 compilation options.  Check your target's definition of
395 @code{STARTFILE_SPEC} to find out what start files it uses.
396 Here's an example of copying these files from a target machine:
397
398 @example
399 ftp @var{target-machine}
400 lcd /usr/local/@var{target}/lib
401 prompt
402 cd /lib
403 mget *crt*.o
404 cd /usr/lib
405 mget *crt*.o
406 quit
407 @end example
408
409 @node Cross Headers
410 @subsection Cross-Compilers and Header Files
411
412 If you are cross-compiling a standalone program or a program for an
413 embedded system, then you may not need any header files except the few
414 that are part of GNU CC (and those of your program).  However, if you
415 intend to link your program with a standard C library such as
416 @file{libc.a}, then you probably need to compile with the header files
417 that go with the library you use.
418
419 The GNU C compiler does not come with these files, because (1) they are
420 system-specific, and (2) they belong in a C library, not in a compiler.
421
422 If the GNU C library supports your target machine, then you can get the
423 header files from there (assuming you actually use the GNU library when
424 you link your program).
425
426 If your target machine comes with a C compiler, it probably comes with
427 suitable header files also.  If you make these files accessible from the host
428 machine, the cross-compiler can use them also.
429
430 Otherwise, you're on your own in finding header files to use when
431 cross-compiling.
432
433 When you have found suitable header files, put them in the directory
434 @file{/usr/local/@var{target}/include}, before building the cross
435 compiler.  Then installation will run fixincludes properly and install
436 the corrected versions of the header files where the compiler will use
437 them.
438
439 Provide the header files before you build the cross-compiler, because
440 the build stage actually runs the cross-compiler to produce parts of
441 @file{libgcc.a}.  (These are the parts that @emph{can} be compiled with
442 GNU CC.)  Some of them need suitable header files.
443
444 Here's an example showing how to copy the header files from a target
445 machine.  On the target machine, do this:
446
447 @example
448 (cd /usr/include; tar cf - .) > tarfile
449 @end example
450
451 Then, on the host machine, do this:
452
453 @example
454 ftp @var{target-machine}
455 lcd /usr/local/@var{target}/include
456 get tarfile
457 quit
458 tar xf tarfile
459 @end example
460
461 @node Build Cross
462 @subsection Actually Building the Cross-Compiler
463
464 Now you can proceed just as for compiling a single-machine compiler
465 through the step of building stage 1.
466
467 If your target is exotic, you may need to provide the header file
468 @file{float.h}.One way to do this is to compile @file{enquire} and run
469 it on your target machine.  The job of @file{enquire} is to run on the
470 target machine and figure out by experiment the nature of its floating
471 point representation.  @file{enquire} records its findings in the header
472 file @file{float.h}.  If you can't produce this file by running
473 @file{enquire} on the target machine, then you will need to come up with
474 a suitable @file{float.h} in some other way (or else, avoid using it in
475 your programs).
476
477 Do not try to build stage 2 for a cross-compiler.  It doesn't work to
478 rebuild GNU CC as a cross-compiler using the cross-compiler, because
479 that would produce a program that runs on the target machine, not on the
480 host.  For example, if you compile a 386-to-68030 cross-compiler with
481 itself, the result will not be right either for the 386 (because it was
482 compiled into 68030 code) or for the 68030 (because it was configured
483 for a 386 as the host).  If you want to compile GNU CC into 68030 code,
484 whether you compile it on a 68030 or with a cross-compiler on a 386, you
485 must specify a 68030 as the host when you configure it.
486
487 To install the cross-compiler, use @samp{make install}, as usual.
488
489 @node VMS Install
490 @section Installing GNU CC on VMS
491 @cindex VMS installation
492 @cindex installing GNU CC on VMS
493
494 The VMS version of GNU CC is distributed in a backup saveset containing
495 both source code and precompiled binaries.
496
497 To install the @file{gcc} command so you can use the compiler easily, in
498 the same manner as you use the VMS C compiler, you must install the VMS CLD
499 file for GNU CC as follows:
500
501 @enumerate
502 @item
503 Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
504 to point to the directories where the GNU CC executables
505 (@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are
506 kept respectively.  This should be done with the commands:@refill
507
508 @smallexample
509 $ assign /system /translation=concealed -
510   disk:[gcc.] gnu_cc
511 $ assign /system /translation=concealed -
512   disk:[gcc.include.] gnu_cc_include
513 @end smallexample
514
515 @noindent
516 with the appropriate disk and directory names.  These commands can be
517 placed in your system startup file so they will be executed whenever
518 the machine is rebooted.  You may, if you choose, do this via the
519 @file{GCC_INSTALL.COM} script in the @file{[GCC]} directory.
520
521 @item
522 Install the @file{GCC} command with the command line:
523
524 @smallexample
525 $ set command /table=sys$common:[syslib]dcltables -
526   /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
527 $ install replace sys$common:[syslib]dcltables
528 @end smallexample
529
530 @item
531 To install the help file, do the following:
532
533 @smallexample
534 $ library/help sys$library:helplib.hlb gcc.hlp
535 @end smallexample
536
537 @noindent
538 Now you can invoke the compiler with a command like @samp{gcc /verbose
539 file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
540 Unix.
541 @end enumerate
542
543 If you wish to use GNU C++ you must first install GNU CC, and then
544 perform the following steps:
545
546 @enumerate
547 @item
548 Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the
549 directory where the preprocessor will search for the C++ header files.
550 This can be done with the command:@refill
551
552 @smallexample
553 $ assign /system /translation=concealed -
554   disk:[gcc.gxx_include.] gnu_gxx_include
555 @end smallexample
556
557 @noindent
558 with the appropriate disk and directory name.  If you are going to be
559 using a C++ runtime library, this is where its install procedure will install
560 its header files.
561
562 @item
563 Obtain the file @file{gcc-cc1plus.exe}, and place this in the same
564 directory that @file{gcc-cc1.exe} is kept.
565
566 The GNU C++ compiler can be invoked with a command like @samp{gcc /plus
567 /verbose file.cc}, which is equivalent to the command @samp{g++ -v -c
568 file.cc} in Unix.
569 @end enumerate
570
571 We try to put corresponding binaries and sources on the VMS distribution
572 tape.  But sometimes the binaries will be from an older version than the
573 sources, because we don't always have time to update them.  (Use the
574 @samp{/version} option to determine the version number of the binaries and
575 compare it with the source file @file{version.c} to tell whether this is
576 so.)  In this case, you should use the binaries you get to recompile the
577 sources.  If you must recompile, here is how:
578
579 @enumerate
580 @item
581 Execute the command procedure @file{vmsconfig.com} to set up the files
582 @file{tm.h}, @file{config.h}, @file{aux-output.c}, and @file{md.}, and
583 to create files @file{tconfig.h} and @file{hconfig.h}.  This procedure
584 also creates several linker option files used by @file{make-cc1.com} and
585 a data file used by @file{make-l2.com}.@refill
586
587 @smallexample
588 $ @@vmsconfig.com
589 @end smallexample
590
591 @item
592 Setup the logical names and command tables as defined above.  In
593 addition, define the VMS logical name @samp{GNU_BISON} to point at the
594 to the directories where the Bison executable is kept.  This should be
595 done with the command:@refill
596
597 @smallexample
598 $ assign /system /translation=concealed -
599   disk:[bison.] gnu_bison
600 @end smallexample
601
602 You may, if you choose, use the @file{INSTALL_BISON.COM} script in the
603 @file{[BISON]} directory.
604
605 @item
606 Install the @samp{BISON} command with the command line:@refill
607
608 @smallexample
609 $ set command /table=sys$common:[syslib]dcltables -
610   /output=sys$common:[syslib]dcltables -
611   gnu_bison:[000000]bison
612 $ install replace sys$common:[syslib]dcltables
613 @end smallexample
614
615 @item
616 Type @samp{@@make-gcc} to recompile everything (alternatively, submit
617 the file @file{make-gcc.com} to a batch queue).  If you wish to build
618 the GNU C++ compiler as well as the GNU CC compiler, you must first edit
619 @file{make-gcc.com} and follow the instructions that appear in the
620 comments.@refill
621
622 @item
623 In order to use GCC, you need a library of functions which GCC compiled code
624 will call to perform certain tasks, and these functions are defined in the
625 file @file{libgcc2.c}.  To compile this you should use the command procedure
626 @file{make-l2.com}, which will generate the library @file{libgcc2.olb}.
627 @file{libgcc2.olb} should be built using the compiler built from
628 the same distribution that @file{libgcc2.c} came from, and
629 @file{make-gcc.com} will automatically do all of this for you.
630
631 To install the library, use the following commands:@refill
632
633 @smallexample
634 $ library gnu_cc:[000000]gcclib/delete=(new,eprintf)
635 $ library gnu_cc:[000000]gcclib/delete=L_*
636 $ library libgcc2/extract=*/output=libgcc2.obj
637 $ library gnu_cc:[000000]gcclib libgcc2.obj
638 @end smallexample
639
640 The first command simply removes old modules that will be replaced with
641 modules from @file{libgcc2} under different module names.  The modules
642 @code{new} and @code{eprintf} may not actually be present in your
643 @file{gcclib.olb}---if the VMS librarian complains about those modules
644 not being present, simply ignore the message and continue on with the
645 next command.  The second command removes the modules that came from the
646 previous version of the library @file{libgcc2.c}.
647
648 Whenever you update the compiler on your system, you should also update the
649 library with the above procedure.
650
651 @item
652 You may wish to build GCC in such a way that no files are written to the
653 directory where the source files reside.  An example would be the when
654 the source files are on a read-only disk.  In these cases, execute the
655 following DCL commands (substituting your actual path names):
656
657 @smallexample
658 $ assign dua0:[gcc.build_dir.]/translation=concealed, -
659          dua1:[gcc.source_dir.]/translation=concealed  gcc_build
660 $ set default gcc_build:[000000]
661 @end smallexample
662
663 @noindent
664 where the directory @file{dua1:[gcc.source_dir]} contains the source
665 code, and the directory @file{dua0:[gcc.build_dir]} is meant to contain
666 all of the generated object files and executables.  Once you have done
667 this, you can proceed building GCC as described above.  (Keep in mind
668 that @file{gcc_build} is a rooted logical name, and thus the device
669 names in each element of the search list must be an actual physical
670 device name rather than another rooted logical name).
671
672 @item
673 @strong{If you are building GNU CC with a previous version of GNU CC,
674 you also should check to see that you have the newest version of the
675 assembler}.  In particular, GNU CC version 2 treats global constant
676 variables slightly differently from GNU CC version 1, and GAS version
677 1.38.1 does not have the patches required to work with GCC version 2.
678 If you use GAS 1.38.1, then @code{extern const} variables will not have
679 the read-only bit set, and the linker will generate warning messages
680 about mismatched psect attributes for these variables.  These warning
681 messages are merely a nuisance, and can safely be ignored.
682
683 If you are compiling with a version of GNU CC older than 1.33, specify
684 @samp{/DEFINE=("inline=")} as an option in all the compilations.  This
685 requires editing all the @code{gcc} commands in @file{make-cc1.com}.
686 (The older versions had problems supporting @code{inline}.)  Once you
687 have a working 1.33 or newer GNU CC, you can change this file back.
688
689 @item
690 If you want to build GNU CC with the VAX C compiler, you will need to
691 make minor changes in @file{make-cccp.com} and @file{make-cc1.com}
692 to choose alternate definitions of @code{CC}, @code{CFLAGS}, and
693 @code{LIBS}.  See comments in those files.  However, you must
694 also have a working version of the GNU assembler (GNU as, aka GAS) as
695 it is used as the back end for GNU CC to produce binary object modules
696 and is not included in the GNU CC sources.  GAS is also needed to
697 compile @file{libgcc2} in order to build @file{gcclib} (see above);
698 @file{make-l2.com} expects to be able to find it operational in
699 @file{gnu_cc:[000000]gnu-as.exe}.
700
701 To use GNU CC on VMS, you need the VMS driver programs
702 @file{gcc.exe}, @file{gcc.com}, and @file{gcc.cld}.  They are
703 distributed with the VMS binaries (@file{gcc-vms}) rather than the
704 GNU CC sources.  GAS is also included in @file{gcc-vms}, as is Bison.
705
706 Once you have successfully built GNU CC with VAX C, you should use the
707 resulting compiler to rebuild itself.  Before doing this, be sure to
708 restore the @code{CC}, @code{CFLAGS}, and @code{LIBS} definitions in
709 @file{make-cccp.com} and @file{make-cc1.com}.  The second generation
710 compiler will be able to take advantage of many optimizations that must
711 be suppressed when building with other compilers.
712 @end enumerate
713
714 Under previous versions of GNU CC, the generated code would occasionally
715 give strange results when linked with the sharable @file{VAXCRTL} library.
716 Now this should work.
717
718 Even with this version, however, GNU CC itself should not be linked with
719 the sharable @file{VAXCRTL}.  The version of @code{qsort} in
720 @file{VAXCRTL} has a bug (known to be present in VMS versions V4.6
721 through V5.5) which causes the compiler to fail.
722
723 The executables are generated by @file{make-cc1.com} and
724 @file{make-cccp.com} use the object library version of @file{VAXCRTL} in
725 order to make use of the @code{qsort} routine in @file{gcclib.olb}.  If
726 you wish to link the compiler executables with the shareable image
727 version of @file{VAXCRTL}, you should edit the file @file{tm.h} (created
728 by @file{vmsconfig.com}) to define the macro @code{QSORT_WORKAROUND}.
729
730 @code{QSORT_WORKAROUND} is always defined when GNU CC is compiled with
731 VAX C, to avoid a problem in case @file{gcclib.olb} is not yet
732 available.
733
734 @node Collect2
735 @section @code{collect2}
736
737 GNU CC uses a utility called @code{collect2} on nearly all systems to arrange
738 to call various initialization functions at start time.
739
740 The program @code{collect2} works by linking the program once and
741 looking through the linker output file for symbols with particular names
742 indicating they are constructor functions.  If it finds any, it
743 creates a new temporary @samp{.c} file containing a table of them,
744 compiles it, and links the program a second time including that file.
745
746 @findex __main
747 @cindex constructors, automatic calls
748 The actual calls to the constructors are carried out by a subroutine
749 called @code{__main}, which is called (automatically) at the beginning
750 of the body of @code{main} (provided @code{main} was compiled with GNU
751 CC).  Calling @code{__main} is necessary, even when compiling C code, to
752 allow linking C and C++ object code together.  (If you use
753 @option{-nostdlib}, you get an unresolved reference to @code{__main},
754 since it's defined in the standard GCC library.  Include @option{-lgcc} at
755 the end of your compiler command line to resolve this reference.)
756
757 The program @code{collect2} is installed as @code{ld} in the directory
758 where the passes of the compiler are installed.  When @code{collect2}
759 needs to find the @emph{real} @code{ld}, it tries the following file
760 names:
761
762 @itemize @bullet
763 @item
764 @file{real-ld} in the directories listed in the compiler's search
765 directories.
766
767 @item
768 @file{real-ld} in the directories listed in the environment variable
769 @code{PATH}.
770
771 @item
772 The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
773 if specified.
774
775 @item
776 @file{ld} in the compiler's search directories, except that
777 @code{collect2} will not execute itself recursively.
778
779 @item
780 @file{ld} in @code{PATH}.
781 @end itemize
782
783 ``The compiler's search directories'' means all the directories where
784 @code{gcc} searches for passes of the compiler.  This includes
785 directories that you specify with @option{-B}.
786
787 Cross-compilers search a little differently:
788
789 @itemize @bullet
790 @item
791 @file{real-ld} in the compiler's search directories.
792
793 @item
794 @file{@var{target}-real-ld} in @code{PATH}.
795
796 @item
797 The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
798 if specified.
799
800 @item
801 @file{ld} in the compiler's search directories.
802
803 @item
804 @file{@var{target}-ld} in @code{PATH}.
805 @end itemize
806
807 @code{collect2} explicitly avoids running @code{ld} using the file name
808 under which @code{collect2} itself was invoked.  In fact, it remembers
809 up a list of such names---in case one copy of @code{collect2} finds
810 another copy (or version) of @code{collect2} installed as @code{ld} in a
811 second place in the search path.
812
813 @code{collect2} searches for the utilities @code{nm} and @code{strip}
814 using the same algorithm as above for @code{ld}.
815
816 @node Header Dirs
817 @section Standard Header File Directories
818
819 @code{GCC_INCLUDE_DIR} means the same thing for native and cross.  It is
820 where GNU CC stores its private include files, and also where GNU CC
821 stores the fixed include files.  A cross compiled GNU CC runs
822 @code{fixincludes} on the header files in @file{$(tooldir)/include}.
823 (If the cross compilation header files need to be fixed, they must be
824 installed before GNU CC is built.  If the cross compilation header files
825 are already suitable for ISO C and GNU CC, nothing special need be
826 done).
827
828 @code{GPLUSPLUS_INCLUDE_DIR} means the same thing for native and cross.  It
829 is where @code{g++} looks first for header files.  The C++ library
830 installs only target independent header files in that directory.
831
832 @code{LOCAL_INCLUDE_DIR} is used only for a native compiler.  It is
833 normally @file{/usr/local/include}.  GNU CC searches this directory so
834 that users can install header files in @file{/usr/local/include}.
835
836 @code{CROSS_INCLUDE_DIR} is used only for a cross compiler.  GNU CC
837 doesn't install anything there.
838
839 @code{TOOL_INCLUDE_DIR} is used for both native and cross compilers.  It
840 is the place for other packages to install header files that GNU CC will
841 use.  For a cross-compiler, this is the equivalent of
842 @file{/usr/include}.  When you build a cross-compiler,
843 @code{fixincludes} processes any header files in this directory.