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.
6 @chapter Installing GNU CC
7 @cindex installing GNU CC
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.
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.
22 Here is the procedure for installing GNU CC on a GNU or Unix system.
23 See @ref{VMS Install}, for VMS systems.
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
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.
39 Specify the host, build and target machine configurations. You do this
40 when you run the @file{configure} script.
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.
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
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}.)
63 ./configure --host=sparc-sun-sunos4.1
66 A configuration name may be canonical or it may be more or less
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.
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.
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.
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.
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}.
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
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.
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.
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.
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}).
124 Specify the option @samp{--with-gnu-ld} if you plan to use the GNU
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
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.
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
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.
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.
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.
163 Build the compiler. Just type @samp{make LANGUAGES=c} in the compiler
166 @samp{LANGUAGES=c} specifies that only the C compiler should be
167 compiled. The makefile normally builds compilers for all the supported
168 languages; currently, C, C++, Objective C, Java, FORTRAN, and CHILL.
169 However, C is the only language that is sure to work when you build with
170 other non-GNU C compilers. In addition, building anything but C at this
171 stage is a waste of time.
173 In general, you can specify the languages to build by typing the
174 argument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or more
175 words from the list @samp{c}, @samp{c++}, @samp{objective-c},
176 @samp{java}, @samp{f77}, and @samp{CHILL}. If you have any additional
177 GNU compilers as subdirectories of the GNU CC source directory, you may
178 also specify their names in this list.
182 @node Configuration Files
183 @section Files Created by @code{configure}
185 Here we spell out what files will be set up by @code{configure}. Normally
186 you need not be concerned with these files.
191 A file named @file{config.h} is created that contains a @samp{#include}
192 of the top-level config file for the machine you will run the compiler
193 on (@pxref{Config}). This file is responsible for defining information
194 about the host machine. It includes @file{tm.h}.
197 A file named @file{config.h} is created that contains a @samp{#include}
198 of the top-level config file for the machine you will run the compiler
199 on (@pxref{Config,,The Configuration File, gcc.info, Using and Porting
200 GCC}). This file is responsible for defining information about the host
201 machine. It includes @file{tm.h}.
204 The top-level config file is located in the subdirectory @file{config}.
205 Its name is always @file{xm-@var{something}.h}; usually
206 @file{xm-@var{machine}.h}, but there are some exceptions.
208 If your system does not support symbolic links, you might want to
209 set up @file{config.h} to contain a @samp{#include} command which
210 refers to the appropriate file.
213 A file named @file{tconfig.h} is created which includes the top-level config
214 file for your target machine. This is used for compiling certain
215 programs to run on that machine.
218 A file named @file{tm.h} is created which includes the
219 machine-description macro file for your target machine. It should be in
220 the subdirectory @file{config} and its name is often
221 @file{@var{machine}.h}.
224 The command file @file{configure} also constructs the file
225 @file{Makefile} by adding some text to the template file
226 @file{Makefile.in}. The additional text comes from files in the
227 @file{config} directory, named @file{t-@var{target}} and
228 @file{x-@var{host}}. If these files do not exist, it means nothing
229 needs to be added for a given target or host.
233 @section Configurations Supported by GNU CC
234 @cindex configurations supported by GNU CC
236 Here are the possible CPU types:
239 @c gmicro, fx80, spur and tahoe omitted since they don't work.
240 1750a, a29k, alpha, arm, avr, c@var{n}, clipper, dsp16xx, elxsi, fr30, h8300,
241 hppa1.0, hppa1.1, i370, i386, i486, i586, i686, i786, i860, i960, m32r,
242 m68000, m68k, m6811, m6812, m88k, mcore, mips, mipsel, mips64, mips64el,
243 mn10200, mn10300, ns32k, pdp11, powerpc, powerpcle, romp, rs6000, sh, sparc,
244 sparclite, sparc64, v850, vax, we32k.
247 Here are the recognized company names. As you can see, customary
248 abbreviations are used rather than the longer official names.
250 @c What should be done about merlin, tek*, dolphin?
252 acorn, alliant, altos, apollo, apple, att, bull,
253 cbm, convergent, convex, crds, dec, dg, dolphin,
254 elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi,
255 mips, motorola, ncr, next, ns, omron, plexus,
256 sequent, sgi, sony, sun, tti, unicom, wrs.
259 The company name is meaningful only to disambiguate when the rest of
260 the information supplied is insufficient. You can omit it, writing
261 just @samp{@var{cpu}-@var{system}}, if it is not needed. For example,
262 @samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}.
264 Here is a list of system types:
267 386bsd, aix, acis, amigaos, aos, aout, aux, bosx, bsd, clix, coff, ctix, cxux,
268 dgux, dynix, ebmon, ecoff, elf, esix, freebsd, hms, genix, gnu, linux,
269 linux-gnu, hiux, hpux, iris, irix, isc, luna, lynxos, mach, minix, msdos, mvs,
270 netbsd, newsos, nindy, ns, osf, osfrose, ptx, riscix, riscos, rtu, sco, sim,
271 solaris, sunos, sym, sysv, udi, ultrix, unicos, uniplus, unos, vms, vsta,
272 vxworks, winnt, xenix.
276 You can omit the system type; then @file{configure} guesses the
277 operating system from the CPU and company.
279 You can add a version number to the system type; this may or may not
280 make a difference. For example, you can write @samp{bsd4.3} or
281 @samp{bsd4.4} to distinguish versions of BSD. In practice, the version
282 number is most needed for @samp{sysv3} and @samp{sysv4}, which are often
285 @samp{linux-gnu} is the canonical name for the GNU/Linux target; however
286 GNU CC will also accept @samp{linux}. The version of the kernel in use is
287 not relevant on these systems. A suffix such as @samp{libc1} or @samp{aout}
288 distinguishes major versions of the C library; all of the suffixed versions
291 If you specify an impossible combination such as @samp{i860-dg-vms},
292 then you may get an error message from @file{configure}, or it may
293 ignore part of the information and do the best it can with the rest.
294 @file{configure} always prints the canonical name for the alternative
295 that it used. GNU CC does not support all possible alternatives.
297 Often a particular model of machine has a name. Many machine names are
298 recognized as aliases for CPU/company combinations. Thus, the machine
299 name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}.
300 Sometimes we accept a company name as a machine name, when the name is
301 popularly used for a particular machine. Here is a table of the known
305 3300, 3b1, 3b@var{n}, 7300, altos3068, altos,
306 apollo68, att-7300, balance,
307 convex-c@var{n}, crds, decstation-3100,
308 decstation, delta, encore,
309 fx2800, gmicro, hp7@var{nn}, hp8@var{nn},
310 hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn},
311 hp9k8@var{nn}, iris4d, iris, isi68,
312 m3230, magnum, merlin, miniframe,
313 mmax, news-3600, news800, news, next,
314 pbd, pc532, pmax, powerpc, powerpcle, ps2, risc-news,
315 rtpc, sun2, sun386i, sun386, sun3,
316 sun4, symmetry, tower-32, tower.
320 Remember that a machine name specifies both the cpu type and the company
322 If you want to install your own homemade configuration files, you can
323 use @samp{local} as the company name to access them. If you use
324 configuration @samp{@var{cpu}-local}, the configuration name
325 without the cpu prefix
326 is used to form the configuration file names.
328 Thus, if you specify @samp{m68k-local}, configuration uses
329 files @file{m68k.md}, @file{local.h}, @file{m68k.c},
330 @file{xm-local.h}, @file{t-local}, and @file{x-local}, all in the
331 directory @file{config/m68k}.
333 Here is a list of configurations that have special treatment or special
334 things you must know:
338 See @ref{VMS Install}, for details on how to install GNU CC on VMS.
342 @section Building and Installing a Cross-Compiler
343 @cindex cross-compiler, installation
345 GNU CC can function as a cross-compiler for many machines, but not all.
349 Cross-compilers for the Mips as target using the Mips assembler
350 currently do not work, because the auxiliary programs
351 @file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled on
352 anything but a Mips. It does work to cross compile for a Mips
353 if you use the GNU assembler and linker.
356 Cross-compilers between machines with different floating point formats
357 have not all been made to work. GNU CC now has a floating point
358 emulator with which these can work, but each target machine description
359 needs to be updated to take advantage of it.
362 Cross-compilation between machines of different word sizes is
363 somewhat problematic and sometimes does not work.
366 Since GNU CC generates assembler code, you probably need a
367 cross-assembler that GNU CC can run, in order to produce object files.
368 If you want to link on other than the target machine, you need a
369 cross-linker as well. You also need header files and libraries suitable
370 for the target machine that you can install on the host machine.
373 * Steps of Cross:: Using a cross-compiler involves several steps
374 that may be carried out on different machines.
375 * Configure Cross:: Configuring a cross-compiler.
376 * Tools and Libraries:: Where to put the linker and assembler, and the C library.
377 * Cross Headers:: Finding and installing header files
378 for a cross-compiler.
379 * Build Cross:: Actually compiling the cross-compiler.
383 @subsection Steps of Cross-Compilation
385 To compile and run a program using a cross-compiler involves several
390 Run the cross-compiler on the host machine to produce assembler files
391 for the target machine. This requires header files for the target
395 Assemble the files produced by the cross-compiler. You can do this
396 either with an assembler on the target machine, or with a
397 cross-assembler on the host machine.
400 Link those files to make an executable. You can do this either with a
401 linker on the target machine, or with a cross-linker on the host
402 machine. Whichever machine you use, you need libraries and certain
403 startup files (typically @file{crt@dots{}.o}) for the target machine.
406 It is most convenient to do all of these steps on the same host machine,
407 since then you can do it all with a single invocation of GNU CC. This
408 requires a suitable cross-assembler and cross-linker. For some targets,
409 the GNU assembler and linker are available.
411 @node Configure Cross
412 @subsection Configuring a Cross-Compiler
414 To build GNU CC as a cross-compiler, you start out by running
415 @file{configure}. Use the @samp{--target=@var{target}} to specify the
416 target type. If @file{configure} was unable to correctly identify the
417 system you are running on, also specify the @samp{--build=@var{build}}
418 option. For example, here is how to configure for a cross-compiler that
419 produces code for an HP 68030 system running BSD on a system that
420 @file{configure} can correctly identify:
423 ./configure --target=m68k-hp-bsd4.3
426 @node Tools and Libraries
427 @subsection Tools and Libraries for a Cross-Compiler
429 If you have a cross-assembler and cross-linker available, you should
430 install them now. Put them in the directory
431 @file{/usr/local/@var{target}/bin}. Here is a table of the tools
432 you should put in this directory:
436 This should be the cross-assembler.
439 This should be the cross-linker.
442 This should be the cross-archiver: a program which can manipulate
443 archive files (linker libraries) in the target machine's format.
446 This should be a program to construct a symbol table in an archive file.
449 The installation of GNU CC will find these programs in that directory,
450 and copy or link them to the proper place to for the cross-compiler to
451 find them when run later.
453 The easiest way to provide these files is to build the Binutils package
454 and GAS. Configure them with the same @samp{--host} and @samp{--target}
455 options that you use for configuring GNU CC, then build and install
456 them. They install their executables automatically into the proper
457 directory. Alas, they do not support all the targets that GNU CC
460 If you want to install libraries to use with the cross-compiler, such as
461 a standard C library, put them in the directory
462 @file{/usr/local/@var{target}/lib}; installation of GNU CC copies
463 all the files in that subdirectory into the proper place for GNU CC to
464 find them and link with them. Here's an example of copying some
465 libraries from a target machine:
468 ftp @var{target-machine}
469 lcd /usr/local/@var{target}/lib
479 The precise set of libraries you'll need, and their locations on
480 the target machine, vary depending on its operating system.
483 Many targets require ``start files'' such as @file{crt0.o} and
484 @file{crtn.o} which are linked into each executable; these too should be
485 placed in @file{/usr/local/@var{target}/lib}. There may be several
486 alternatives for @file{crt0.o}, for use with profiling or other
487 compilation options. Check your target's definition of
488 @code{STARTFILE_SPEC} to find out what start files it uses.
489 Here's an example of copying these files from a target machine:
492 ftp @var{target-machine}
493 lcd /usr/local/@var{target}/lib
503 @subsection Cross-Compilers and Header Files
505 If you are cross-compiling a standalone program or a program for an
506 embedded system, then you may not need any header files except the few
507 that are part of GNU CC (and those of your program). However, if you
508 intend to link your program with a standard C library such as
509 @file{libc.a}, then you probably need to compile with the header files
510 that go with the library you use.
512 The GNU C compiler does not come with these files, because (1) they are
513 system-specific, and (2) they belong in a C library, not in a compiler.
515 If the GNU C library supports your target machine, then you can get the
516 header files from there (assuming you actually use the GNU library when
517 you link your program).
519 If your target machine comes with a C compiler, it probably comes with
520 suitable header files also. If you make these files accessible from the host
521 machine, the cross-compiler can use them also.
523 Otherwise, you're on your own in finding header files to use when
526 When you have found suitable header files, put them in the directory
527 @file{/usr/local/@var{target}/include}, before building the cross
528 compiler. Then installation will run fixincludes properly and install
529 the corrected versions of the header files where the compiler will use
532 Provide the header files before you build the cross-compiler, because
533 the build stage actually runs the cross-compiler to produce parts of
534 @file{libgcc.a}. (These are the parts that @emph{can} be compiled with
535 GNU CC.) Some of them need suitable header files.
537 Here's an example showing how to copy the header files from a target
538 machine. On the target machine, do this:
541 (cd /usr/include; tar cf - .) > tarfile
544 Then, on the host machine, do this:
547 ftp @var{target-machine}
548 lcd /usr/local/@var{target}/include
555 @subsection Actually Building the Cross-Compiler
557 Now you can proceed just as for compiling a single-machine compiler
558 through the step of building stage 1.
560 If your target is exotic, you may need to provide the header file
561 @file{float.h}.One way to do this is to compile @file{enquire} and run
562 it on your target machine. The job of @file{enquire} is to run on the
563 target machine and figure out by experiment the nature of its floating
564 point representation. @file{enquire} records its findings in the header
565 file @file{float.h}. If you can't produce this file by running
566 @file{enquire} on the target machine, then you will need to come up with
567 a suitable @file{float.h} in some other way (or else, avoid using it in
570 Do not try to build stage 2 for a cross-compiler. It doesn't work to
571 rebuild GNU CC as a cross-compiler using the cross-compiler, because
572 that would produce a program that runs on the target machine, not on the
573 host. For example, if you compile a 386-to-68030 cross-compiler with
574 itself, the result will not be right either for the 386 (because it was
575 compiled into 68030 code) or for the 68030 (because it was configured
576 for a 386 as the host). If you want to compile GNU CC into 68030 code,
577 whether you compile it on a 68030 or with a cross-compiler on a 386, you
578 must specify a 68030 as the host when you configure it.
580 To install the cross-compiler, use @samp{make install}, as usual.
583 @section Installing GNU CC on VMS
584 @cindex VMS installation
585 @cindex installing GNU CC on VMS
587 The VMS version of GNU CC is distributed in a backup saveset containing
588 both source code and precompiled binaries.
590 To install the @file{gcc} command so you can use the compiler easily, in
591 the same manner as you use the VMS C compiler, you must install the VMS CLD
592 file for GNU CC as follows:
596 Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
597 to point to the directories where the GNU CC executables
598 (@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are
599 kept respectively. This should be done with the commands:@refill
602 $ assign /system /translation=concealed -
604 $ assign /system /translation=concealed -
605 disk:[gcc.include.] gnu_cc_include
609 with the appropriate disk and directory names. These commands can be
610 placed in your system startup file so they will be executed whenever
611 the machine is rebooted. You may, if you choose, do this via the
612 @file{GCC_INSTALL.COM} script in the @file{[GCC]} directory.
615 Install the @file{GCC} command with the command line:
618 $ set command /table=sys$common:[syslib]dcltables -
619 /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
620 $ install replace sys$common:[syslib]dcltables
624 To install the help file, do the following:
627 $ library/help sys$library:helplib.hlb gcc.hlp
631 Now you can invoke the compiler with a command like @samp{gcc /verbose
632 file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
636 If you wish to use GNU C++ you must first install GNU CC, and then
637 perform the following steps:
641 Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the
642 directory where the preprocessor will search for the C++ header files.
643 This can be done with the command:@refill
646 $ assign /system /translation=concealed -
647 disk:[gcc.gxx_include.] gnu_gxx_include
651 with the appropriate disk and directory name. If you are going to be
652 using a C++ runtime library, this is where its install procedure will install
656 Obtain the file @file{gcc-cc1plus.exe}, and place this in the same
657 directory that @file{gcc-cc1.exe} is kept.
659 The GNU C++ compiler can be invoked with a command like @samp{gcc /plus
660 /verbose file.cc}, which is equivalent to the command @samp{g++ -v -c
664 We try to put corresponding binaries and sources on the VMS distribution
665 tape. But sometimes the binaries will be from an older version than the
666 sources, because we don't always have time to update them. (Use the
667 @samp{/version} option to determine the version number of the binaries and
668 compare it with the source file @file{version.c} to tell whether this is
669 so.) In this case, you should use the binaries you get to recompile the
670 sources. If you must recompile, here is how:
674 Execute the command procedure @file{vmsconfig.com} to set up the files
675 @file{tm.h}, @file{config.h}, @file{aux-output.c}, and @file{md.}, and
676 to create files @file{tconfig.h} and @file{hconfig.h}. This procedure
677 also creates several linker option files used by @file{make-cc1.com} and
678 a data file used by @file{make-l2.com}.@refill
685 Setup the logical names and command tables as defined above. In
686 addition, define the VMS logical name @samp{GNU_BISON} to point at the
687 to the directories where the Bison executable is kept. This should be
688 done with the command:@refill
691 $ assign /system /translation=concealed -
692 disk:[bison.] gnu_bison
695 You may, if you choose, use the @file{INSTALL_BISON.COM} script in the
696 @file{[BISON]} directory.
699 Install the @samp{BISON} command with the command line:@refill
702 $ set command /table=sys$common:[syslib]dcltables -
703 /output=sys$common:[syslib]dcltables -
704 gnu_bison:[000000]bison
705 $ install replace sys$common:[syslib]dcltables
709 Type @samp{@@make-gcc} to recompile everything (alternatively, submit
710 the file @file{make-gcc.com} to a batch queue). If you wish to build
711 the GNU C++ compiler as well as the GNU CC compiler, you must first edit
712 @file{make-gcc.com} and follow the instructions that appear in the
716 In order to use GCC, you need a library of functions which GCC compiled code
717 will call to perform certain tasks, and these functions are defined in the
718 file @file{libgcc2.c}. To compile this you should use the command procedure
719 @file{make-l2.com}, which will generate the library @file{libgcc2.olb}.
720 @file{libgcc2.olb} should be built using the compiler built from
721 the same distribution that @file{libgcc2.c} came from, and
722 @file{make-gcc.com} will automatically do all of this for you.
724 To install the library, use the following commands:@refill
727 $ library gnu_cc:[000000]gcclib/delete=(new,eprintf)
728 $ library gnu_cc:[000000]gcclib/delete=L_*
729 $ library libgcc2/extract=*/output=libgcc2.obj
730 $ library gnu_cc:[000000]gcclib libgcc2.obj
733 The first command simply removes old modules that will be replaced with
734 modules from @file{libgcc2} under different module names. The modules
735 @code{new} and @code{eprintf} may not actually be present in your
736 @file{gcclib.olb}---if the VMS librarian complains about those modules
737 not being present, simply ignore the message and continue on with the
738 next command. The second command removes the modules that came from the
739 previous version of the library @file{libgcc2.c}.
741 Whenever you update the compiler on your system, you should also update the
742 library with the above procedure.
745 You may wish to build GCC in such a way that no files are written to the
746 directory where the source files reside. An example would be the when
747 the source files are on a read-only disk. In these cases, execute the
748 following DCL commands (substituting your actual path names):
751 $ assign dua0:[gcc.build_dir.]/translation=concealed, -
752 dua1:[gcc.source_dir.]/translation=concealed gcc_build
753 $ set default gcc_build:[000000]
757 where the directory @file{dua1:[gcc.source_dir]} contains the source
758 code, and the directory @file{dua0:[gcc.build_dir]} is meant to contain
759 all of the generated object files and executables. Once you have done
760 this, you can proceed building GCC as described above. (Keep in mind
761 that @file{gcc_build} is a rooted logical name, and thus the device
762 names in each element of the search list must be an actual physical
763 device name rather than another rooted logical name).
766 @strong{If you are building GNU CC with a previous version of GNU CC,
767 you also should check to see that you have the newest version of the
768 assembler}. In particular, GNU CC version 2 treats global constant
769 variables slightly differently from GNU CC version 1, and GAS version
770 1.38.1 does not have the patches required to work with GCC version 2.
771 If you use GAS 1.38.1, then @code{extern const} variables will not have
772 the read-only bit set, and the linker will generate warning messages
773 about mismatched psect attributes for these variables. These warning
774 messages are merely a nuisance, and can safely be ignored.
776 If you are compiling with a version of GNU CC older than 1.33, specify
777 @samp{/DEFINE=("inline=")} as an option in all the compilations. This
778 requires editing all the @code{gcc} commands in @file{make-cc1.com}.
779 (The older versions had problems supporting @code{inline}.) Once you
780 have a working 1.33 or newer GNU CC, you can change this file back.
783 If you want to build GNU CC with the VAX C compiler, you will need to
784 make minor changes in @file{make-cccp.com} and @file{make-cc1.com}
785 to choose alternate definitions of @code{CC}, @code{CFLAGS}, and
786 @code{LIBS}. See comments in those files. However, you must
787 also have a working version of the GNU assembler (GNU as, aka GAS) as
788 it is used as the back-end for GNU CC to produce binary object modules
789 and is not included in the GNU CC sources. GAS is also needed to
790 compile @file{libgcc2} in order to build @file{gcclib} (see above);
791 @file{make-l2.com} expects to be able to find it operational in
792 @file{gnu_cc:[000000]gnu-as.exe}.
794 To use GNU CC on VMS, you need the VMS driver programs
795 @file{gcc.exe}, @file{gcc.com}, and @file{gcc.cld}. They are
796 distributed with the VMS binaries (@file{gcc-vms}) rather than the
797 GNU CC sources. GAS is also included in @file{gcc-vms}, as is Bison.
799 Once you have successfully built GNU CC with VAX C, you should use the
800 resulting compiler to rebuild itself. Before doing this, be sure to
801 restore the @code{CC}, @code{CFLAGS}, and @code{LIBS} definitions in
802 @file{make-cccp.com} and @file{make-cc1.com}. The second generation
803 compiler will be able to take advantage of many optimizations that must
804 be suppressed when building with other compilers.
807 Under previous versions of GNU CC, the generated code would occasionally
808 give strange results when linked with the sharable @file{VAXCRTL} library.
809 Now this should work.
811 Even with this version, however, GNU CC itself should not be linked with
812 the sharable @file{VAXCRTL}. The version of @code{qsort} in
813 @file{VAXCRTL} has a bug (known to be present in VMS versions V4.6
814 through V5.5) which causes the compiler to fail.
816 The executables are generated by @file{make-cc1.com} and
817 @file{make-cccp.com} use the object library version of @file{VAXCRTL} in
818 order to make use of the @code{qsort} routine in @file{gcclib.olb}. If
819 you wish to link the compiler executables with the shareable image
820 version of @file{VAXCRTL}, you should edit the file @file{tm.h} (created
821 by @file{vmsconfig.com}) to define the macro @code{QSORT_WORKAROUND}.
823 @code{QSORT_WORKAROUND} is always defined when GNU CC is compiled with
824 VAX C, to avoid a problem in case @file{gcclib.olb} is not yet
828 @section @code{collect2}
830 GNU CC uses a utility called @code{collect2} on nearly all systems to arrange
831 to call various initialization functions at start time.
833 The program @code{collect2} works by linking the program once and
834 looking through the linker output file for symbols with particular names
835 indicating they are constructor functions. If it finds any, it
836 creates a new temporary @samp{.c} file containing a table of them,
837 compiles it, and links the program a second time including that file.
840 @cindex constructors, automatic calls
841 The actual calls to the constructors are carried out by a subroutine
842 called @code{__main}, which is called (automatically) at the beginning
843 of the body of @code{main} (provided @code{main} was compiled with GNU
844 CC). Calling @code{__main} is necessary, even when compiling C code, to
845 allow linking C and C++ object code together. (If you use
846 @samp{-nostdlib}, you get an unresolved reference to @code{__main},
847 since it's defined in the standard GCC library. Include @samp{-lgcc} at
848 the end of your compiler command line to resolve this reference.)
850 The program @code{collect2} is installed as @code{ld} in the directory
851 where the passes of the compiler are installed. When @code{collect2}
852 needs to find the @emph{real} @code{ld}, it tries the following file
857 @file{real-ld} in the directories listed in the compiler's search
861 @file{real-ld} in the directories listed in the environment variable
865 The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
869 @file{ld} in the compiler's search directories, except that
870 @code{collect2} will not execute itself recursively.
873 @file{ld} in @code{PATH}.
876 ``The compiler's search directories'' means all the directories where
877 @code{gcc} searches for passes of the compiler. This includes
878 directories that you specify with @samp{-B}.
880 Cross-compilers search a little differently:
884 @file{real-ld} in the compiler's search directories.
887 @file{@var{target}-real-ld} in @code{PATH}.
890 The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
894 @file{ld} in the compiler's search directories.
897 @file{@var{target}-ld} in @code{PATH}.
900 @code{collect2} explicitly avoids running @code{ld} using the file name
901 under which @code{collect2} itself was invoked. In fact, it remembers
902 up a list of such names---in case one copy of @code{collect2} finds
903 another copy (or version) of @code{collect2} installed as @code{ld} in a
904 second place in the search path.
906 @code{collect2} searches for the utilities @code{nm} and @code{strip}
907 using the same algorithm as above for @code{ld}.
910 @section Standard Header File Directories
912 @code{GCC_INCLUDE_DIR} means the same thing for native and cross. It is
913 where GNU CC stores its private include files, and also where GNU CC
914 stores the fixed include files. A cross compiled GNU CC runs
915 @code{fixincludes} on the header files in @file{$(tooldir)/include}.
916 (If the cross compilation header files need to be fixed, they must be
917 installed before GNU CC is built. If the cross compilation header files
918 are already suitable for ISO C and GNU CC, nothing special need be
921 @code{GPLUSPLUS_INCLUDE_DIR} means the same thing for native and cross. It
922 is where @code{g++} looks first for header files. The C++ library
923 installs only target independent header files in that directory.
925 @code{LOCAL_INCLUDE_DIR} is used only for a native compiler. It is
926 normally @file{/usr/local/include}. GNU CC searches this directory so
927 that users can install header files in @file{/usr/local/include}.
929 @code{CROSS_INCLUDE_DIR} is used only for a cross compiler. GNU CC
930 doesn't install anything there.
932 @code{TOOL_INCLUDE_DIR} is used for both native and cross compilers. It
933 is the place for other packages to install header files that GNU CC will
934 use. For a cross-compiler, this is the equivalent of
935 @file{/usr/include}. When you build a cross-compiler,
936 @code{fixincludes} processes any header files in this directory.