OSDN Git Service

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