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