OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / install.texi
1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 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 @c The text of this file appears in the file INSTALL
6 @c in the GCC distribution, as well as in the GCC manual.
7
8 Note most of this information is out of date and superseded by the
9 online GCC install procedures @uref{http://gcc.gnu.org/install/}.  It is
10 provided for historical reference only.
11
12 @ifclear INSTALLONLY
13 @node Installation
14 @chapter Installing GNU CC
15 @end ifclear
16 @cindex installing GNU CC
17
18 @menu
19 * Configuration Files::  Files created by running @code{configure}.
20 * Configurations::    Configurations Supported by GNU CC.
21 * Other Dir::     Compiling in a separate directory (not where the source is).
22 * Cross-Compiler::   Building and installing a cross-compiler.
23 * Sun Install::   See below for installation on the Sun.
24 * VMS Install::   See below for installation on VMS.
25 * Collect2::      How @code{collect2} works; how it finds @code{ld}.
26 * Header Dirs::   Understanding the standard header file directories.
27 @end menu
28
29 Here is the procedure for installing GNU CC on a GNU or Unix system.
30 See @ref{VMS Install}, for VMS systems.  In this section we assume you
31 compile in the same directory that contains the source files; see
32 @ref{Other Dir}, to find out how to compile in a separate directory on
33 Unix systems.
34
35 You cannot install GNU C by itself on MSDOS; it will not compile under
36 any MSDOS compiler except itself.  You need to get the complete
37 compilation package DJGPP, which includes binaries as well as sources,
38 and includes all the necessary compilation tools and libraries.
39
40 @enumerate
41 @item
42 If you have built GNU CC previously in the same directory for a
43 different target machine, do @samp{make distclean} to delete all files
44 that might be invalid.  One of the files this deletes is
45 @file{Makefile}; if @samp{make distclean} complains that @file{Makefile}
46 does not exist, it probably means that the directory is already suitably
47 clean.
48
49 @item
50 On a System V release 4 system, make sure @file{/usr/bin} precedes
51 @file{/usr/ucb} in @code{PATH}.  The @code{cc} command in
52 @file{/usr/ucb} uses libraries which have bugs.
53
54 @cindex Bison parser generator
55 @cindex parser generator, Bison
56 @item
57 Make sure the Bison parser generator is installed.  (This is unnecessary
58 if the Bison output file @file{c-parse.c} is more recent than
59 @file{c-parse.y},and you do not plan to change the @samp{.y} file.)
60
61 Bison versions older than Sept 8, 1988 will produce incorrect output
62 for @file{c-parse.c}.
63
64 @item
65 If you have chosen a configuration for GNU CC which requires other GNU
66 tools (such as GAS or the GNU linker) instead of the standard system
67 tools, install the required tools in the build directory under the names
68 @file{as}, @file{ld} or whatever is appropriate.  This will enable the
69 compiler to find the proper tools for compilation of the program
70 @file{enquire}.
71
72 Alternatively, you can do subsequent compilation using a value of the
73 @code{PATH} environment variable such that the necessary GNU tools come
74 before the standard system tools.
75
76 @item
77 Specify the host, build and target machine configurations.  You do this
78 when you run the @file{configure} script.
79
80 The @dfn{build} machine is the system which you are using, the
81 @dfn{host} machine is the system where you want to run the resulting
82 compiler (normally the build machine), and the @dfn{target} machine is
83 the system for which you want the compiler to generate code.
84
85 If you are building a compiler to produce code for the machine it runs
86 on (a native compiler), you normally do not need to specify any operands
87 to @file{configure}; it will try to guess the type of machine you are on
88 and use that as the build, host and target machines.  So you don't need
89 to specify a configuration when building a native compiler unless
90 @file{configure} cannot figure out what your configuration is or guesses
91 wrong.
92
93 In those cases, specify the build machine's @dfn{configuration name}
94 with the @samp{--host} option; the host and target will default to be
95 the same as the host machine.  (If you are building a cross-compiler,
96 see @ref{Cross-Compiler}.)
97
98 Here is an example:
99
100 @smallexample
101 ./configure --host=sparc-sun-sunos4.1
102 @end smallexample
103
104 A configuration name may be canonical or it may be more or less
105 abbreviated.
106
107 A canonical configuration name has three parts, separated by dashes.
108 It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}.
109 (The three parts may themselves contain dashes; @file{configure}
110 can figure out which dashes serve which purpose.)  For example,
111 @samp{m68k-sun-sunos4.1} specifies a Sun 3.
112
113 You can also replace parts of the configuration by nicknames or aliases.
114 For example, @samp{sun3} stands for @samp{m68k-sun}, so
115 @samp{sun3-sunos4.1} is another way to specify a Sun 3.  You can also
116 use simply @samp{sun3-sunos}, since the version of SunOS is assumed by
117 default to be version 4.
118
119 You can specify a version number after any of the system types, and some
120 of the CPU types.  In most cases, the version is irrelevant, and will be
121 ignored.  So you might as well specify the version if you know it.
122
123 See @ref{Configurations}, for a list of supported configuration names and
124 notes on many of the configurations.  You should check the notes in that
125 section before proceeding any further with the installation of GNU CC.
126
127 @item
128 When running @code{configure}, you may also need to specify certain
129 additional options that describe variant hardware and software
130 configurations.  These are @samp{--with-gnu-as}, @samp{--with-gnu-ld},
131 @samp{--with-stabs} and @samp{--nfp}.
132
133 @table @samp
134 @item --with-gnu-as
135 If you will use GNU CC with the GNU assembler (GAS), you should declare
136 this by using the @samp{--with-gnu-as} option when you run
137 @file{configure}.
138
139 Using this option does not install GAS.  It only modifies the output of
140 GNU CC to work with GAS.  Building and installing GAS is up to you.
141
142 Conversely, if you @emph{do not} wish to use GAS and do not specify
143 @samp{--with-gnu-as} when building GNU CC, it is up to you to make sure
144 that GAS is not installed.  GNU CC searches for a program named
145 @code{as} in various directories; if the program it finds is GAS, then
146 it runs GAS.  If you are not sure where GNU CC finds the assembler it is
147 using, try specifying @samp{-v} when you run it.
148
149 The systems where it makes a difference whether you use GAS are@*
150 @samp{hppa1.0-@var{any}-@var{any}}, @samp{hppa1.1-@var{any}-@var{any}},
151 @samp{i386-@var{any}-sysv}, @samp{i386-@var{any}-isc},@*
152 @samp{i860-@var{any}-bsd}, @samp{m68k-bull-sysv},@*
153 @samp{m68k-hp-hpux}, @samp{m68k-sony-bsd},@*
154 @samp{m68k-altos-sysv}, @samp{m68000-hp-hpux},@*
155 @samp{m68000-att-sysv}, @samp{@var{any}-lynx-lynxos},
156 and @samp{mips-@var{any}}).
157 On any other system, @samp{--with-gnu-as} has no effect.
158
159 On the systems listed above (except for the HP-PA, for ISC on the
160 386, and for @samp{mips-sgi-irix5.*}), if you use GAS, you should also
161 use the GNU linker (and specify @samp{--with-gnu-ld}).
162
163 @item --with-gnu-ld
164 Specify the option @samp{--with-gnu-ld} if you plan to use the GNU
165 linker with GNU CC.
166
167 This option does not cause the GNU linker to be installed; it just
168 modifies the behavior of GNU CC to work with the GNU linker.
169 @c Specifically, it inhibits the installation of @code{collect2}, a program
170 @c which otherwise serves as a front-end for the system's linker on most
171 @c configurations.
172
173 @item --with-stabs
174 On MIPS based systems and on Alphas, you must specify whether you want
175 GNU CC to create the normal ECOFF debugging format, or to use BSD-style
176 stabs passed through the ECOFF symbol table.  The normal ECOFF debug
177 format cannot fully handle languages other than C.  BSD stabs format can
178 handle other languages, but it only works with the GNU debugger GDB.
179
180 Normally, GNU CC uses the ECOFF debugging format by default; if you
181 prefer BSD stabs, specify @samp{--with-stabs} when you configure GNU
182 CC.
183
184 No matter which default you choose when you configure GNU CC, the user
185 can use the @samp{-gcoff} and @samp{-gstabs+} options to specify explicitly
186 the debug format for a particular compilation.
187
188 @samp{--with-stabs} is meaningful on the ISC system on the 386, also, if
189 @samp{--with-gas} is used.  It selects use of stabs debugging
190 information embedded in COFF output.  This kind of debugging information
191 supports C++ well; ordinary COFF debugging information does not.
192
193 @samp{--with-stabs} is also meaningful on 386 systems running SVR4.  It
194 selects use of stabs debugging information embedded in ELF output.  The
195 C++ compiler currently (2.6.0) does not support the DWARF debugging
196 information normally used on 386 SVR4 platforms; stabs provide a
197 workable alternative.  This requires gas and gdb, as the normal SVR4
198 tools can not generate or interpret stabs.
199
200 @item --nfp
201 On certain systems, you must specify whether the machine has a floating
202 point unit.  These systems include @samp{m68k-sun-sunos@var{n}} and
203 @samp{m68k-isi-bsd}.  On any other system, @samp{--nfp} currently has no
204 effect, though perhaps there are other systems where it could usefully
205 make a difference.
206
207 @cindex Haifa scheduler
208 @cindex scheduler, experimental
209 @item --enable-haifa
210 @itemx --disable-haifa
211 Use @samp{--enable-haifa} to enable use of an experimental instruction
212 scheduler (from IBM Haifa).  This may or may not produce better code.
213 Some targets on which it is known to be a win enable it by default; use
214 @samp{--disable-haifa} to disable it in these cases.  @code{configure}
215 will print out whether the Haifa scheduler is enabled when it is run.
216
217 @cindex Objective C threads
218 @cindex threads, Objective C
219 @item --enable-threads=@var{type}
220 Certain systems, notably Linux-based GNU systems, can't be relied on to
221 supply a threads facility for the Objective C runtime and so will
222 default to single-threaded runtime.  They may, however, have a library
223 threads implementation available, in which case threads can be enabled
224 with this option by supplying a suitable @var{type}, probably
225 @samp{posix}.  The possibilities for @var{type} are @samp{single},
226 @samp{posix}, @samp{win32}, @samp{solaris}, @samp{irix} and @samp{mach}.
227
228 @cindex Internal Compiler Checking
229 @item --enable-checking
230 When you specify this option, the compiler is built to perform checking
231 of tree node types when referencing fields of that node.  This does not
232 change the generated code, but adds error checking within the compiler.
233 This will slow down the compiler and may only work properly if you
234 are building the compiler with GNU C.
235
236 The @file{configure} script searches subdirectories of the source
237 directory for other compilers that are to be integrated into GNU CC.
238 The GNU compiler for C++, called G++ is in a subdirectory named
239 @file{cp}.  @file{configure} inserts rules into @file{Makefile} to build
240 all of those compilers.
241
242 Here we spell out what files will be set up by @code{configure}.  Normally
243 you need not be concerned with these files.
244
245 @itemize @bullet
246 @item
247 @ifset INTERNALS
248 A file named @file{config.h} is created that contains a @samp{#include}
249 of the top-level config file for the machine you will run the compiler
250 on (@pxref{Config}).  This file is responsible for defining information
251 about the host machine.  It includes @file{tm.h}.
252 @end ifset
253 @ifclear INTERNALS
254 A file named @file{config.h} is created that contains a @samp{#include}
255 of the top-level config file for the machine you will run the compiler
256 on (@pxref{Config,,The Configuration File, gcc.info, Using and Porting
257 GCC}).  This file is responsible for defining information about the host
258 machine.  It includes @file{tm.h}.
259 @end ifclear
260
261 The top-level config file is located in the subdirectory @file{config}.
262 Its name is always @file{xm-@var{something}.h}; usually
263 @file{xm-@var{machine}.h}, but there are some exceptions.
264
265 If your system does not support symbolic links, you might want to
266 set up @file{config.h} to contain a @samp{#include} command which
267 refers to the appropriate file.
268
269 @item
270 A file named @file{tconfig.h} is created which includes the top-level config
271 file for your target machine.  This is used for compiling certain
272 programs to run on that machine.
273
274 @item
275 A file named @file{tm.h} is created which includes the
276 machine-description macro file for your target machine.  It should be in
277 the subdirectory @file{config} and its name is often
278 @file{@var{machine}.h}.
279 @end itemize
280
281 @cindex Native Language Support
282 @cindex NLS
283 @item --enable-nls
284 @itemx --disable-nls
285 The @samp{--enable-nls} option enables Native Language Support (NLS),
286 which lets GCC output diagnostics in languages other than American
287 English. Native Language Support is enabled by default if not doing a 
288 canadian cross build. The @samp{--disable-nls} option disables NLS.
289
290 @cindex @code{gettext}
291 @item --with-included-gettext
292 If NLS is enbled, the @samp{--with-included-gettext} option causes the build
293 procedure to prefer its copy of GNU @code{gettext}. This is the default. If
294 you want the GCC build procedure to prefer the host's @code{gettext}
295 libraries, use @samp{--without-included-gettext}.
296
297 @cindex @code{catgets}
298 @item --with-catgets
299 If NLS is enabled, and if the host lacks @code{gettext} but has the
300 inferior @code{catgets} interface, the GCC build procedure normally
301 ignores @code{catgets} and instead uses GCC's copy of the GNU
302 @code{gettext} library.  The @samp{--with-catgets} option causes the
303 build procedure to use the host's @code{catgets} in this situation.
304
305 @cindex @code{maintainer-mode}
306 @item --enable-maintainer-mode
307 The build rules that regenerate the GCC master message catalog
308 @code{gcc.pot} are normally disabled. This is because it can only be rebuilt
309 if the complete source tree is present. If you have changed the sources and
310 want to rebuild the catalog, configuring with
311 @samp{--enable-maintainer-mode} will enable this. Note that you need a
312 special version of the @code{gettext} tools to do so.
313
314 @cindex Windows32 Registry support
315 @item --enable-win32-registry
316 @itemx --enable-win32-registry=@var{KEY}
317 @itemx --disable-win32-registry
318 The @samp{--enable-win32-registry} option enables Windows-hosted GCC
319 to look up installations paths in the registry using the following key:
320
321 @smallexample
322 @code{HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\<KEY>}
323 @end smallexample
324
325 <KEY> defaults to GCC version number, and can be overridden by the
326 @code{--enable-win32-registry=KEY} option. Vendors and distributors
327 who use custom installers are encouraged to provide a different key,
328 perhaps one comprised of vendor name and GCC version number, to
329 avoid conflict with existing installations. This feature is enabled
330 by default, and can be disabled by @code{--disable-win32-registry}
331 option.  This option has no effect on the other hosts.
332 @end table
333
334 @item
335 In certain cases, you should specify certain other options when you run
336 @code{configure}.
337
338 @itemize @bullet
339 @item
340 The standard directory for installing GNU CC is @file{/usr/local/lib}.
341 If you want to install its files somewhere else, specify
342 @samp{--prefix=@var{dir}} when you run @file{configure}.  Here @var{dir}
343 is a directory name to use instead of @file{/usr/local} for all purposes
344 with one exception: the directory @file{/usr/local/include} is searched
345 for header files no matter where you install the compiler.  To override
346 this name, use the @code{--with-local-prefix} option below.  The directory
347 you specify need not exist, but its parent directory must exist.
348
349 @item
350 Specify @samp{--with-local-prefix=@var{dir}} if you want the compiler to
351 search directory @file{@var{dir}/include} for locally installed header
352 files @emph{instead} of @file{/usr/local/include}.
353
354 You should specify @samp{--with-local-prefix} @strong{only} if your site has
355 a different convention (not @file{/usr/local}) for where to put
356 site-specific files.
357
358 The default value for @samp{--with-local-prefix} is @file{/usr/local}
359 regardless of the value of @samp{--prefix}.  Specifying @samp{--prefix}
360 has no effect on which directory GNU CC searches for local header files.
361 This may seem counterintuitive, but actually it is logical.
362
363 The purpose of @samp{--prefix} is to specify where to @emph{install GNU
364 CC}.  The local header files in @file{/usr/local/include}---if you put
365 any in that directory---are not part of GNU CC.  They are part of other
366 programs---perhaps many others.  (GNU CC installs its own header files
367 in another directory which is based on the @samp{--prefix} value.)
368
369 @strong{Do not} specify @file{/usr} as the @samp{--with-local-prefix}!  The
370 directory you use for @samp{--with-local-prefix} @strong{must not} contain
371 any of the system's standard header files.  If it did contain them,
372 certain programs would be miscompiled (including GNU Emacs, on certain
373 targets), because this would override and nullify the header file
374 corrections made by the @code{fixincludes} script.
375
376 Indications are that people who use this option use it based on
377 mistaken ideas of what it is for.  People use it as if it specified
378 where to install part of GNU CC.  Perhaps they make this assumption
379 because installing GNU CC creates the directory.
380 @end itemize
381
382 @item
383 Build the compiler.  Just type @samp{make LANGUAGES=c} in the compiler
384 directory.
385
386 @samp{LANGUAGES=c} specifies that only the C compiler should be
387 compiled.  The makefile normally builds compilers for all the supported
388 languages; currently, C, C++, Objective C, Java, FORTRAN, and CHILL.
389 However, C is the only language that is sure to work when you build with
390 other non-GNU C compilers.  In addition, building anything but C at this
391 stage is a waste of time.
392
393 In general, you can specify the languages to build by typing the
394 argument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or more
395 words from the list @samp{c}, @samp{c++}, @samp{objective-c},
396 @samp{java}, @samp{f77}, and @samp{CHILL}.  If you have any additional
397 GNU compilers as subdirectories of the GNU CC source directory, you may
398 also specify their names in this list.
399
400 Ignore any warnings you may see about ``statement not reached'' in
401 @file{insn-emit.c}; they are normal.  Also, warnings about ``unknown
402 escape sequence'' are normal in @file{genopinit.c} and perhaps some
403 other files.  Likewise, you should ignore warnings about ``constant is
404 so large that it is unsigned'' in @file{insn-emit.c} and
405 @file{insn-recog.c}, and a warning about a comparison always being zero
406 in @file{enquire.o}.  Any other compilation errors may represent bugs in
407 the port to your machine or operating system, and
408 @ifclear INSTALLONLY
409 should be investigated and reported (@pxref{Bugs}).
410 @end ifclear
411 @ifset INSTALLONLY
412 should be investigated and reported.
413 @end ifset
414
415 Some compilers fail to compile GNU CC because they have bugs or
416 limitations.  For example, the Microsoft compiler is said to run out of
417 macro space.  Some Ultrix compilers run out of expression space; then
418 you need to break up the statement where the problem happens.
419
420 @item
421 If you are building a cross-compiler, stop here.  @xref{Cross-Compiler}.
422
423 @cindex stage1
424 @item
425 Move the first-stage object files and executables into a subdirectory
426 with this command:
427
428 @smallexample
429 make stage1
430 @end smallexample
431
432 The files are moved into a subdirectory named @file{stage1}.
433 Once installation is complete, you may wish to delete these files
434 with @code{rm -r stage1}.
435
436 @item
437 If you have chosen a configuration for GNU CC which requires other GNU
438 tools (such as GAS or the GNU linker) instead of the standard system
439 tools, install the required tools in the @file{stage1} subdirectory
440 under the names @file{as}, @file{ld} or whatever is appropriate.  This
441 will enable the stage 1 compiler to find the proper tools in the
442 following stage.
443
444 Alternatively, you can do subsequent compilation using a value of the
445 @code{PATH} environment variable such that the necessary GNU tools come
446 before the standard system tools.
447
448 @item
449 Recompile the compiler with itself, with this command:
450
451 @smallexample
452 make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2"
453 @end smallexample
454
455 This is called making the stage 2 compiler.
456
457 The command shown above builds compilers for all the supported
458 languages.  If you don't want them all, you can specify the languages to
459 build by typing the argument @samp{LANGUAGES="@var{list}"}.  @var{list}
460 should contain one or more words from the list @samp{c}, @samp{c++},
461 @samp{objective-c}, and @samp{proto}.  Separate the words with spaces.
462 @samp{proto} stands for the programs @code{protoize} and
463 @code{unprotoize}; they are not a separate language, but you use
464 @code{LANGUAGES} to enable or disable their installation.
465
466 If you are going to build the stage 3 compiler, then you might want to
467 build only the C language in stage 2.
468
469 Once you have built the stage 2 compiler, if you are short of disk
470 space, you can delete the subdirectory @file{stage1}.
471
472 On a 68000 or 68020 system lacking floating point hardware,
473 unless you have selected a @file{tm.h} file that expects by default
474 that there is no such hardware, do this instead:
475
476 @smallexample
477 make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2 -msoft-float"
478 @end smallexample
479
480 @item
481 If you wish to test the compiler by compiling it with itself one more
482 time, install any other necessary GNU tools (such as GAS or the GNU
483 linker) in the @file{stage2} subdirectory as you did in the
484 @file{stage1} subdirectory, then do this:
485
486 @smallexample
487 make stage2
488 make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2"
489 @end smallexample
490
491 @noindent
492 This is called making the stage 3 compiler.  Aside from the @samp{-B}
493 option, the compiler options should be the same as when you made the
494 stage 2 compiler.  But the @code{LANGUAGES} option need not be the
495 same.  The command shown above builds compilers for all the supported
496 languages; if you don't want them all, you can specify the languages to
497 build by typing the argument @samp{LANGUAGES="@var{list}"}, as described
498 above.
499
500 If you do not have to install any additional GNU tools, you may use the
501 command
502
503 @smallexample
504 make bootstrap LANGUAGES=@var{language-list} BOOT_CFLAGS=@var{option-list}
505 @end smallexample
506
507 @noindent
508 instead of making @file{stage1}, @file{stage2}, and performing
509 the two compiler builds.
510
511 @item
512 Compare the latest object files with the stage 2 object files---they
513 ought to be identical, aside from time stamps (if any).
514
515 On some systems, meaningful comparison of object files is impossible;
516 they always appear ``different.''  This is currently true on Solaris and
517 some systems that use ELF object file format.  On some versions of Irix
518 on SGI machines and DEC Unix (OSF/1) on Alpha systems, you will not be
519 able to compare the files without specifying @file{-save-temps}; see the
520 description of individual systems above to see if you get comparison
521 failures.  You may have similar problems on other systems.
522
523 Use this command to compare the files:
524
525 @smallexample
526 make compare
527 @end smallexample
528
529 This will mention any object files that differ between stage 2 and stage
530 3.  Any difference, no matter how innocuous, indicates that the stage 2
531 compiler has compiled GNU CC incorrectly, and is therefore a potentially
532 @ifclear INSTALLONLY
533 serious bug which you should investigate and report (@pxref{Bugs}).
534 @end ifclear
535 @ifset INSTALLONLY
536 serious bug which you should investigate and report.
537 @end ifset
538
539 If your system does not put time stamps in the object files, then this
540 is a faster way to compare them (using the Bourne shell):
541
542 @smallexample
543 for file in *.o; do
544 cmp $file stage2/$file
545 done
546 @end smallexample
547
548 If you have built the compiler with the @samp{-mno-mips-tfile} option on
549 MIPS machines, you will not be able to compare the files.
550
551 @item
552 Install the compiler driver, the compiler's passes and run-time support
553 with @samp{make install}.  Use the same value for @code{CC},
554 @code{CFLAGS} and @code{LANGUAGES} that you used when compiling the
555 files that are being installed.  One reason this is necessary is that
556 some versions of Make have bugs and recompile files gratuitously when
557 you do this step.  If you use the same variable values, those files will
558 be recompiled properly.
559
560 For example, if you have built the stage 2 compiler, you can use the
561 following command:
562
563 @smallexample
564 make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES="@var{list}"
565 @end smallexample
566
567 @noindent
568 This copies the files @file{cc1}, @file{cpp} and @file{libgcc.a} to
569 files @file{cc1}, @file{cpp} and @file{libgcc.a} in the directory
570 @file{/usr/local/lib/gcc-lib/@var{target}/@var{version}}, which is where
571 the compiler driver program looks for them.  Here @var{target} is the
572 canonicalized form of target machine type specified when you ran
573 @file{configure}, and @var{version} is the version number of GNU CC.
574 This naming scheme permits various versions and/or cross-compilers to
575 coexist.  It also copies the executables for compilers for other
576 languages (e.g., @file{cc1plus} for C++) to the same directory.
577
578 This also copies the driver program @file{xgcc} into
579 @file{/usr/local/bin/gcc}, so that it appears in typical execution
580 search paths.  It also copies @file{gcc.1} into
581 @file{/usr/local/man/man1} and info pages into @file{/usr/local/info}.
582
583 On some systems, this command causes recompilation of some files.  This
584 is usually due to bugs in @code{make}.  You should either ignore this
585 problem, or use GNU Make.
586
587 @cindex @code{alloca} and SunOS
588 @strong{Warning: there is a bug in @code{alloca} in the Sun library.  To
589 avoid this bug, be sure to install the executables of GNU CC that were
590 compiled by GNU CC.  (That is, the executables from stage 2 or 3, not
591 stage 1.)  They use @code{alloca} as a built-in function and never the
592 one in the library.}
593
594 (It is usually better to install GNU CC executables from stage 2 or 3,
595 since they usually run faster than the ones compiled with some other
596 compiler.)
597
598 @item
599 GNU CC includes a runtime library for Objective-C because it is an
600 integral part of the language.  You can find the files associated with
601 the library in the subdirectory @file{objc}.  The GNU Objective-C
602 Runtime Library requires header files for the target's C library in
603 order to be compiled,and also requires the header files for the target's
604 thread library if you want thread support.  @xref{Cross Headers,
605 Cross-Compilers and Header Files, Cross-Compilers and Header Files}, for
606 discussion about header files issues for cross-compilation.
607
608 When you run @file{configure}, it picks the appropriate Objective-C
609 thread implementation file for the target platform.  In some situations,
610 you may wish to choose a different back-end as some platforms support
611 multiple thread implementations or you may wish to disable thread
612 support completely.  You do this by specifying a value for the
613 @var{OBJC_THREAD_FILE} makefile variable on the command line when you
614 run make, for example:
615
616 @smallexample
617 make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" OBJC_THREAD_FILE=thr-single
618 @end smallexample
619
620 @noindent
621 Below is a list of the currently available back-ends.
622
623 @itemize @bullet
624 @item thr-single
625 Disable thread support, should work for all platforms.
626 @item thr-decosf1
627 DEC OSF/1 thread support.
628 @item thr-irix
629 SGI IRIX thread support.
630 @item thr-mach
631 Generic MACH thread support, known to work on NEXTSTEP.
632 @item thr-os2
633 IBM OS/2 thread support.
634 @item thr-posix
635 Generix POSIX thread support.
636 @item thr-pthreads
637 PCThreads on Linux-based GNU systems.
638 @item thr-solaris
639 SUN Solaris thread support.
640 @item thr-win32
641 Microsoft Win32 API thread support.
642 @end itemize
643 @end enumerate
644
645 @node Configuration Files
646 @section Files Created by @code{configure}
647
648 Here we spell out what files will be set up by @code{configure}.  Normally
649 you need not be concerned with these files.
650
651 @itemize @bullet
652 @item
653 @ifset INTERNALS
654 A file named @file{config.h} is created that contains a @samp{#include}
655 of the top-level config file for the machine you will run the compiler
656 on (@pxref{Config}).  This file is responsible for defining information
657 about the host machine.  It includes @file{tm.h}.
658 @end ifset
659 @ifclear INTERNALS
660 A file named @file{config.h} is created that contains a @samp{#include}
661 of the top-level config file for the machine you will run the compiler
662 on (@pxref{Config,,The Configuration File, gcc.info, Using and Porting
663 GCC}).  This file is responsible for defining information about the host
664 machine.  It includes @file{tm.h}.
665 @end ifclear
666
667 The top-level config file is located in the subdirectory @file{config}.
668 Its name is always @file{xm-@var{something}.h}; usually
669 @file{xm-@var{machine}.h}, but there are some exceptions.
670
671 If your system does not support symbolic links, you might want to
672 set up @file{config.h} to contain a @samp{#include} command which
673 refers to the appropriate file.
674
675 @item
676 A file named @file{tconfig.h} is created which includes the top-level config
677 file for your target machine.  This is used for compiling certain
678 programs to run on that machine.
679
680 @item
681 A file named @file{tm.h} is created which includes the
682 machine-description macro file for your target machine.  It should be in
683 the subdirectory @file{config} and its name is often
684 @file{@var{machine}.h}.
685
686 @item
687 The command file @file{configure} also constructs the file
688 @file{Makefile} by adding some text to the template file
689 @file{Makefile.in}.  The additional text comes from files in the
690 @file{config} directory, named @file{t-@var{target}} and
691 @file{x-@var{host}}.  If these files do not exist, it means nothing
692 needs to be added for a given target or host.
693 @end itemize
694
695 @node Configurations
696 @section Configurations Supported by GNU CC
697 @cindex configurations supported by GNU CC
698
699 Here are the possible CPU types:
700
701 @quotation
702 @c gmicro, fx80, spur and tahoe omitted since they don't work.
703 1750a, a29k, alpha, arm, avr, c@var{n}, clipper, dsp16xx, elxsi, fr30, h8300,
704 hppa1.0, hppa1.1, i370, i386, i486, i586, i686, i786, i860, i960, m32r,
705 m68000, m68k, m6811, m6812, m88k, mcore, mips, mipsel, mips64, mips64el,
706 mn10200, mn10300, ns32k, pdp11, powerpc, powerpcle, romp, rs6000, sh, sparc,
707 sparclite, sparc64, v850, vax, we32k.
708 @end quotation
709
710 Here are the recognized company names.  As you can see, customary
711 abbreviations are used rather than the longer official names.
712
713 @c What should be done about merlin, tek*, dolphin?
714 @quotation
715 acorn, alliant, altos, apollo, apple, att, bull,
716 cbm, convergent, convex, crds, dec, dg, dolphin,
717 elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi,
718 mips, motorola, ncr, next, ns, omron, plexus,
719 sequent, sgi, sony, sun, tti, unicom, wrs.
720 @end quotation
721
722 The company name is meaningful only to disambiguate when the rest of
723 the information supplied is insufficient.  You can omit it, writing
724 just @samp{@var{cpu}-@var{system}}, if it is not needed.  For example,
725 @samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}.
726
727 Here is a list of system types:
728
729 @quotation
730 386bsd, aix, acis, amigaos, aos, aout, aux, bosx, bsd, clix, coff, ctix, cxux,
731 dgux, dynix, ebmon, ecoff, elf, esix, freebsd, hms, genix, gnu, linux,
732 linux-gnu, hiux, hpux, iris, irix, isc, luna, lynxos, mach, minix, msdos, mvs,
733 netbsd, newsos, nindy, ns, osf, osfrose, ptx, riscix, riscos, rtu, sco, sim,
734 solaris, sunos, sym, sysv, udi, ultrix, unicos, uniplus, unos, vms, vsta,
735 vxworks, winnt, xenix.
736 @end quotation
737
738 @noindent
739 You can omit the system type; then @file{configure} guesses the
740 operating system from the CPU and company.
741
742 You can add a version number to the system type; this may or may not
743 make a difference.  For example, you can write @samp{bsd4.3} or
744 @samp{bsd4.4} to distinguish versions of BSD.  In practice, the version
745 number is most needed for @samp{sysv3} and @samp{sysv4}, which are often
746 treated differently.
747
748 @samp{linux-gnu} is the canonical name for the GNU/Linux target; however
749 GNU CC will also accept @samp{linux}.  The version of the kernel in use is
750 not relevant on these systems.  A suffix such as @samp{libc1} or @samp{aout}
751 distinguishes major versions of the C library; all of the suffixed versions
752 are obsolete.
753
754 If you specify an impossible combination such as @samp{i860-dg-vms},
755 then you may get an error message from @file{configure}, or it may
756 ignore part of the information and do the best it can with the rest.
757 @file{configure} always prints the canonical name for the alternative
758 that it used.  GNU CC does not support all possible alternatives.
759
760 Often a particular model of machine has a name.  Many machine names are
761 recognized as aliases for CPU/company combinations.  Thus, the machine
762 name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}.
763 Sometimes we accept a company name as a machine name, when the name is
764 popularly used for a particular machine.  Here is a table of the known
765 machine names:
766
767 @quotation
768 3300, 3b1, 3b@var{n}, 7300, altos3068, altos,
769 apollo68, att-7300, balance,
770 convex-c@var{n}, crds, decstation-3100,
771 decstation, delta, encore,
772 fx2800, gmicro, hp7@var{nn}, hp8@var{nn},
773 hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn},
774 hp9k8@var{nn}, iris4d, iris, isi68,
775 m3230, magnum, merlin, miniframe,
776 mmax, news-3600, news800, news, next,
777 pbd, pc532, pmax, powerpc, powerpcle, ps2, risc-news,
778 rtpc, sun2, sun386i, sun386, sun3,
779 sun4, symmetry, tower-32, tower.
780 @end quotation
781
782 @noindent
783 Remember that a machine name specifies both the cpu type and the company
784 name.
785 If you want to install your own homemade configuration files, you can
786 use @samp{local} as the company name to access them.  If you use
787 configuration @samp{@var{cpu}-local}, the configuration name
788 without the cpu prefix
789 is used to form the configuration file names.
790
791 Thus, if you specify @samp{m68k-local}, configuration uses
792 files @file{m68k.md}, @file{local.h}, @file{m68k.c},
793 @file{xm-local.h}, @file{t-local}, and @file{x-local}, all in the
794 directory @file{config/m68k}.
795
796 Here is a list of configurations that have special treatment or special
797 things you must know:
798
799 @table @samp
800 @item 1750a-*-*
801 MIL-STD-1750A processors.
802
803 The MIL-STD-1750A cross configuration produces output for
804 @code{as1750}, an assembler/linker available under the GNU Public
805 License for the 1750A. @code{as1750} can be obtained at 
806 @uref{ftp://ftp.fta-berlin.de/pub/crossgcc/1750gals/}.
807 A similarly licensed simulator for
808 the 1750A is available from same address.
809
810 You should ignore a fatal error during the building of libgcc (libgcc is
811 not yet implemented for the 1750A.)
812
813 The @code{as1750} assembler requires the file @file{ms1750.inc}, which is
814 found in the directory @file{config/1750a}.
815
816 GNU CC produced the same sections as the Fairchild F9450 C Compiler,
817 namely:
818
819 @table @code
820 @item Normal
821 The program code section.
822
823 @item Static
824 The read/write (RAM) data section.
825
826 @item Konst
827 The read-only (ROM) constants section.
828
829 @item Init
830 Initialization section (code to copy KREL to SREL).
831 @end table
832
833 The smallest addressable unit is 16 bits (BITS_PER_UNIT is 16).  This
834 means that type `char' is represented with a 16-bit word per character.
835 The 1750A's "Load/Store Upper/Lower Byte" instructions are not used by
836 GNU CC.
837
838 @item alpha-*-osf1
839 Systems using processors that implement the DEC Alpha architecture and
840 are running the DEC Unix (OSF/1) operating system, for example the DEC
841 Alpha AXP systems.CC.)
842
843 GNU CC writes a @samp{.verstamp} directive to the assembler output file
844 unless it is built as a cross-compiler.  It gets the version to use from
845 the system header file @file{/usr/include/stamp.h}.  If you install a
846 new version of DEC Unix, you should rebuild GCC to pick up the new version
847 stamp.
848
849 Note that since the Alpha is a 64-bit architecture, cross-compilers from
850 32-bit machines will not generate code as efficient as that generated
851 when the compiler is running on a 64-bit machine because many
852 optimizations that depend on being able to represent a word on the
853 target in an integral value on the host cannot be performed.  Building
854 cross-compilers on the Alpha for 32-bit machines has only been tested in
855 a few cases and may not work properly.
856
857 @code{make compare} may fail on old versions of DEC Unix unless you add
858 @samp{-save-temps} to @code{CFLAGS}.  On these systems, the name of the
859 assembler input file is stored in the object file, and that makes
860 comparison fail if it differs between the @code{stage1} and
861 @code{stage2} compilations.  The option @samp{-save-temps} forces a
862 fixed name to be used for the assembler input file, instead of a
863 randomly chosen name in @file{/tmp}.  Do not add @samp{-save-temps}
864 unless the comparisons fail without that option.  If you add
865 @samp{-save-temps}, you will have to manually delete the @samp{.i} and
866 @samp{.s} files after each series of compilations.
867
868 GNU CC now supports both the native (ECOFF) debugging format used by DBX
869 and GDB and an encapsulated STABS format for use only with GDB.  See the
870 discussion of the @samp{--with-stabs} option of @file{configure} above
871 for more information on these formats and how to select them.
872
873 There is a bug in DEC's assembler that produces incorrect line numbers
874 for ECOFF format when the @samp{.align} directive is used.  To work
875 around this problem, GNU CC will not emit such alignment directives
876 while writing ECOFF format debugging information even if optimization is
877 being performed.  Unfortunately, this has the very undesirable
878 side-effect that code addresses when @samp{-O} is specified are
879 different depending on whether or not @samp{-g} is also specified.
880
881 To avoid this behavior, specify @samp{-gstabs+} and use GDB instead of
882 DBX.  DEC is now aware of this problem with the assembler and hopes to
883 provide a fix shortly.
884
885 @item arc-*-elf
886 Argonaut ARC processor.
887 This configuration is intended for embedded systems.
888
889 @item arm-*-aout
890 Advanced RISC Machines ARM-family processors.  These are often used in
891 embedded applications.  There are no standard Unix configurations.
892 This configuration corresponds to the basic instruction sequences and will
893 produce @file{a.out} format object modules.
894
895 You may need to make a variant of the file @file{arm.h} for your particular
896 configuration.
897
898 @item arm-*-elf
899 This configuration is intended for embedded systems.
900
901 @item arm-*-linux*aout
902 Any of the ARM-family processors running the Linux-based GNU system with
903 the @file{a.out} binary format.  This is an obsolete configuration.
904
905 @item arm-*-linux
906 @itemx arm-*-linux-gnu
907 @itemx arm-*-linux*oldld
908 Any of the ARM-family processors running the Linux-based GNU system with
909 the @file{ELF} binary format.  You must use version 2.9.1.0.22 or later
910 of the GNU/Linux binutils, which you can download from
911 @uref{ftp://ftp.varesearch.com/pub/support/hjl/binutils/}.
912
913 These two configurations differ only in the required version of GNU
914 binutils.  For binutils 2.9.1.0.x, use @samp{arm-*-linux-gnuoldld}.  For 
915 newer versions of binutils, use @samp{arm-*-linux-gnu}.
916
917 @item arm-*-riscix
918 The ARM2 or ARM3 processor running RISC iX, Acorn's port of BSD Unix.
919 If you are running a version of RISC iX prior to 1.2 then you must
920 specify the version number during configuration.  Note that the
921 assembler shipped with RISC iX does not support stabs debugging
922 information; a new version of the assembler, with stabs support
923 included, is now available from Acorn and via ftp
924 @uref{ftp://ftp.acorn.com/pub/riscix/as+xterm.tar.Z}.  To enable stabs
925 debugging, pass @samp{--with-gnu-as} to configure.
926
927 You will need to install GNU @file{sed} before you can run configure.
928
929 @item a29k
930 AMD Am29k-family processors.  These are normally used in embedded
931 applications.  There are no standard Unix configurations.
932 This configuration
933 corresponds to AMD's standard calling sequence and binary interface
934 and is compatible with other 29k tools.
935
936 You may need to make a variant of the file @file{a29k.h} for your
937 particular configuration.
938
939 @item a29k-*-bsd
940 AMD Am29050 used in a system running a variant of BSD Unix.
941
942 @item avr
943 ATMEL AVR-family micro controllers.  These are used in embedded
944 applications.  There are no standard Unix configurations.
945 See @xref{AVR Options} for the list of supported MCU types.
946
947 @item decstation-*
948 MIPS-based DECstations can support three different personalities:
949 Ultrix, DEC OSF/1, and OSF/rose.  (Alpha-based DECstation products have
950 a configuration name beginning with @samp{alpha-dec}.)  To configure GCC
951 for these platforms use the following configurations:
952
953 @table @samp
954 @item decstation-ultrix
955 Ultrix configuration.
956
957 @item decstation-osf1
958 Dec's version of OSF/1.
959
960 @item decstation-osfrose
961 Open Software Foundation reference port of OSF/1 which uses the
962 OSF/rose object file format instead of ECOFF.  Normally, you
963 would not select this configuration.
964 @end table
965
966 The MIPS C compiler needs to be told to increase its table size
967 for switch statements with the @samp{-Wf,-XNg1500} option in
968 order to compile @file{cp/parse.c}.  If you use the @samp{-O2}
969 optimization option, you also need to use @samp{-Olimit 3000}.
970 Both of these options are automatically generated in the
971 @file{Makefile} that the shell script @file{configure} builds.
972 If you override the @code{CC} make variable and use the MIPS
973 compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}.
974
975 @item elxsi-elxsi-bsd
976 The Elxsi's C compiler has known limitations that prevent it from
977 compiling GNU C.  Please contact @email{mrs@@cygnus.com} for more details.
978
979 @item dsp16xx
980 A port to the AT&T DSP1610 family of processors.
981
982 @ignore
983 @item fx80
984 Alliant FX/8 computer.  Note that the standard installed C compiler in
985 Concentrix 5.0 has a bug which prevent it from compiling GNU CC
986 correctly.  You can patch the compiler bug as follows:
987
988 @smallexample
989 cp /bin/pcc ./pcc
990 adb -w ./pcc - << EOF
991 15f6?w 6610
992 EOF
993 @end smallexample
994
995 Then you must use the @samp{-ip12} option when compiling GNU CC
996 with the patched compiler, as shown here:
997
998 @smallexample
999 make CC="./pcc -ip12" CFLAGS=-w
1000 @end smallexample
1001
1002 Note also that Alliant's version of DBX does not manage to work with the
1003 output from GNU CC.
1004 @end ignore
1005
1006 @item h8300-*-*
1007 Hitachi H8/300 series of processors.
1008
1009 The calling convention and structure layout has changed in release 2.6.
1010 All code must be recompiled.  The calling convention now passes the
1011 first three arguments in function calls in registers.  Structures are no
1012 longer a multiple of 2 bytes.
1013
1014 @item i370-*-*
1015 This port is very preliminary and has many known bugs.  We hope to
1016 have a higher-quality port for this machine soon.
1017
1018 @item i386-*-linux*oldld
1019 Use this configuration to generate @file{a.out} binaries on Linux-based
1020 GNU systems if you do not have gas/binutils version 2.5.2 or later
1021 installed. This is an obsolete configuration.
1022
1023 @item i386-*-linux*aout
1024 Use this configuration to generate @file{a.out} binaries on Linux-based
1025 GNU systems. This configuration is being superseded. You must use
1026 gas/binutils version 2.5.2 or later.
1027
1028 @item i386-*-linux
1029 @itemx i386-*-linux-gnu
1030 Use this configuration to generate ELF binaries on Linux-based GNU
1031 systems.  You must use gas/binutils version 2.5.2 or later.
1032
1033 @item i386-*-sco
1034 Compilation with RCC is recommended.  Also, it may be a good idea to
1035 link with GNU malloc instead of the malloc that comes with the system.
1036
1037 @item i386-*-sco3.2v4
1038 Use this configuration for SCO release 3.2 version 4.
1039
1040 @item i386-*-sco3.2v5*
1041 Use this for the SCO OpenServer Release family including 5.0.0, 5.0.2, 
1042 5.0.4, 5.0.5, Internet FastStart 1.0, and Internet FastStart 1.1.
1043
1044 GNU CC can generate COFF binaries if you specify @samp{-mcoff} or ELF
1045 binaries, the default.    A full @samp{make bootstrap} is recommended
1046 so that an ELF compiler that builds ELF is generated.                   
1047
1048 You must have TLS597 from @uref{ftp://ftp.sco.com/TLS} installed for ELF
1049 C++ binaries to work correctly on releases before 5.0.4. 
1050
1051 The native SCO assembler that is provided with the OS at no charge
1052 is normally required.  If, however, you must be able to use the GNU
1053 assembler (perhaps you have complex asms) you must configure this
1054 package @samp{--with-gnu-as}.  To do this, install (cp or symlink)
1055 gcc/as to your copy of the GNU assembler.  You must use a recent version
1056 of GNU binutils; version 2.9.1 seems to work well.  If you select this
1057 option, you will be unable to build COFF images.  Trying to do so will
1058 result in non-obvious failures.  In general, the "--with-gnu-as" option
1059 isn't as well tested as the native assembler.
1060
1061 @emph{NOTE:} If you are building C++, you must follow the instructions
1062 about invoking @samp{make bootstrap} because the native OpenServer
1063 compiler may build a @file{cc1plus} that will not correctly parse many
1064 valid C++ programs.  You must do a @samp{make bootstrap} if you are
1065 building with the native compiler.
1066
1067 @item i386-*-isc
1068 It may be a good idea to link with GNU malloc instead of the malloc that
1069 comes with the system.
1070
1071 In ISC version 4.1, @file{sed} core dumps when building
1072 @file{deduced.h}.  Use the version of @file{sed} from version 4.0.
1073
1074 @item i386-*-esix
1075 It may be good idea to link with GNU malloc instead of the malloc that
1076 comes with the system.
1077
1078 @item i386-ibm-aix
1079 You need to use GAS version 2.1 or later, and LD from
1080 GNU binutils version 2.2 or later.
1081
1082 @item i386-sequent-bsd
1083 Go to the Berkeley universe before compiling.
1084
1085 @item i386-sequent-ptx1*
1086 @itemx i386-sequent-ptx2*
1087 You must install GNU @file{sed} before running @file{configure}.
1088
1089 @item i386-sun-sunos4
1090 You may find that you need another version of GNU CC to begin
1091 bootstrapping with, since the current version when built with the
1092 system's own compiler seems to get an infinite loop compiling part of
1093 @file{libgcc2.c}.  GNU CC version 2 compiled with GNU CC (any version)
1094 seems not to have this problem.
1095
1096 See @ref{Sun Install}, for information on installing GNU CC on Sun
1097 systems.
1098
1099 @item i[345]86-*-winnt3.5
1100 This version requires a GAS that has not yet been released.  Until it
1101 is, you can get a prebuilt binary version via anonymous ftp from
1102 @uref{ftp://cs.washington.edu/pub/gnat} or @uref{ftp://cs.nyu.edu/pub/gnat}. You
1103 must also use the Microsoft header files from the Windows NT 3.5 SDK.
1104 Find these on the CDROM in the @file{/mstools/h} directory dated 9/4/94.  You
1105 must use a fixed version of Microsoft linker made especially for NT 3.5,
1106 which is also is available on the NT 3.5 SDK CDROM.  If you do not have
1107 this linker, can you also use the linker from Visual C/C++ 1.0 or 2.0.
1108
1109 Installing GNU CC for NT builds a wrapper linker, called @file{ld.exe},
1110 which mimics the behaviour of Unix @file{ld} in the specification of
1111 libraries (@samp{-L} and @samp{-l}).  @file{ld.exe} looks for both Unix
1112 and Microsoft named libraries.  For example, if you specify
1113 @samp{-lfoo}, @file{ld.exe} will look first for @file{libfoo.a}
1114 and then for @file{foo.lib}.
1115
1116 You may install GNU CC for Windows NT in one of two ways, depending on
1117 whether or not you have a Unix-like shell and various Unix-like
1118 utilities.
1119
1120 @enumerate
1121 @item
1122 If you do not have a Unix-like shell and few Unix-like utilities, you
1123 will use a DOS style batch script called @file{configure.bat}.  Invoke
1124 it as @code{configure winnt} from an MSDOS console window or from the
1125 program manager dialog box.  @file{configure.bat} assumes you have
1126 already installed and have in your path a Unix-like @file{sed} program
1127 which is used to create a working @file{Makefile} from @file{Makefile.in}.
1128
1129 @file{Makefile} uses the Microsoft Nmake program maintenance utility and
1130 the Visual C/C++ V8.00 compiler to build GNU CC.  You need only have the
1131 utilities @file{sed} and @file{touch} to use this installation method,
1132 which only automatically builds the compiler itself.  You must then
1133 examine what @file{fixinc.winnt} does, edit the header files by hand and
1134 build @file{libgcc.a} manually.
1135
1136 @item
1137 The second type of installation assumes you are running a Unix-like
1138 shell, have a complete suite of Unix-like utilities in your path, and
1139 have a previous version of GNU CC already installed, either through
1140 building it via the above installation method or acquiring a pre-built
1141 binary.  In this case, use the @file{configure} script in the normal
1142 fashion.
1143 @end enumerate
1144
1145 @item i860-intel-osf1
1146 This is the Paragon.
1147 @ifset INSTALLONLY
1148 If you have version 1.0 of the operating system, you need to take
1149 special steps to build GNU CC due to peculiarities of the system.  Newer
1150 system versions have no problem.  See the section `Installation Problems'
1151 in the GNU CC Manual.
1152 @end ifset
1153 @ifclear INSTALLONLY
1154 If you have version 1.0 of the operating system,
1155 see @ref{Installation Problems}, for special things you need to do to
1156 compensate for peculiarities in the system.
1157 @end ifclear
1158
1159 @item *-lynx-lynxos
1160 LynxOS 2.2 and earlier comes with GNU CC 1.x already installed as
1161 @file{/bin/gcc}.  You should compile with this instead of @file{/bin/cc}.
1162 You can tell GNU CC to use the GNU assembler and linker, by specifying
1163 @samp{--with-gnu-as --with-gnu-ld} when configuring.  These will produce
1164 COFF format object files and executables;  otherwise GNU CC will use the
1165 installed tools, which produce @file{a.out} format executables.
1166
1167 @item m32r-*-elf
1168 Mitsubishi M32R processor.
1169 This configuration is intended for embedded systems.
1170
1171 @item m68000-hp-bsd
1172 HP 9000 series 200 running BSD.  Note that the C compiler that comes
1173 with this system cannot compile GNU CC; contact @email{law@@cygnus.com}
1174 to get binaries of GNU CC for bootstrapping.
1175
1176 @item m68k-altos
1177 Altos 3068.  You must use the GNU assembler, linker and debugger.
1178 Also, you must fix a kernel bug.  Details in the file @file{README.ALTOS}.
1179
1180 @item m68k-apple-aux
1181 Apple Macintosh running A/UX.
1182 You may configure GCC  to use either the system assembler and
1183 linker or the GNU assembler and linker.  You should use the GNU configuration
1184 if you can, especially if you also want to use GNU C++.  You enabled
1185 that configuration with + the @samp{--with-gnu-as} and @samp{--with-gnu-ld}
1186 options to @code{configure}.
1187
1188 Note the C compiler that comes
1189 with this system cannot compile GNU CC.  You can find binaries of GNU CC
1190 for bootstrapping on @code{jagubox.gsfc.nasa.gov}.
1191 You will also a patched version of @file{/bin/ld} there that
1192 raises some of the arbitrary limits found in the original.
1193
1194 @item m68k-att-sysv
1195 AT&T 3b1, a.k.a. 7300 PC.  This version of GNU CC cannot
1196 be compiled with the system C compiler, which is too buggy.
1197 You will need to get a previous version of GCC and use it to
1198 bootstrap.  Binaries are available from the OSU-CIS archive, at
1199 @uref{ftp://archive.cis.ohio-state.edu/pub/att7300/}.
1200
1201 @item m68k-bull-sysv
1202 Bull DPX/2 series 200 and 300 with BOS-2.00.45 up to BOS-2.01. GNU CC works
1203 either with native assembler or GNU assembler. You can use
1204 GNU assembler with native coff generation by providing @samp{--with-gnu-as} to
1205 the configure script or use GNU assembler with dbx-in-coff encapsulation
1206 by providing @samp{--with-gnu-as --stabs}. For any problem with native
1207 assembler or for availability of the DPX/2 port of GAS, contact
1208 @email{F.Pierresteguy@@frcl.bull.fr}.
1209
1210 @item m68k-crds-unox
1211 Use @samp{configure unos} for building on Unos.
1212
1213 The Unos assembler is named @code{casm} instead of @code{as}.  For some
1214 strange reason linking @file{/bin/as} to @file{/bin/casm} changes the
1215 behavior, and does not work.  So, when installing GNU CC, you should
1216 install the following script as @file{as} in the subdirectory where
1217 the passes of GCC are installed:
1218
1219 @example
1220 #!/bin/sh
1221 casm $*
1222 @end example
1223
1224 The default Unos library is named @file{libunos.a} instead of
1225 @file{libc.a}.  To allow GNU CC to function, either change all
1226 references to @samp{-lc} in @file{gcc.c} to @samp{-lunos} or link
1227 @file{/lib/libc.a} to @file{/lib/libunos.a}.
1228
1229 @cindex @code{alloca}, for Unos
1230 When compiling GNU CC with the standard compiler, to overcome bugs in
1231 the support of @code{alloca}, do not use @samp{-O} when making stage 2.
1232 Then use the stage 2 compiler with @samp{-O} to make the stage 3
1233 compiler.  This compiler will have the same characteristics as the usual
1234 stage 2 compiler on other systems.  Use it to make a stage 4 compiler
1235 and compare that with stage 3 to verify proper compilation.
1236
1237 (Perhaps simply defining @code{ALLOCA} in @file{x-crds} as described in
1238 the comments there will make the above paragraph superfluous.  Please
1239 inform us of whether this works.)
1240
1241 Unos uses memory segmentation instead of demand paging, so you will need
1242 a lot of memory.  5 Mb is barely enough if no other tasks are running.
1243 If linking @file{cc1} fails, try putting the object files into a library
1244 and linking from that library.
1245
1246 @item m68k-hp-hpux
1247 HP 9000 series 300 or 400 running HP-UX.  HP-UX version 8.0 has a bug in
1248 the assembler that prevents compilation of GNU CC.  To fix it, get patch
1249 PHCO_4484 from HP.
1250
1251 In addition, if you wish to use gas @samp{--with-gnu-as} you must use
1252 gas version 2.1 or later, and you must use the GNU linker version 2.1 or
1253 later.  Earlier versions of gas relied upon a program which converted the
1254 gas output into the native HP-UX format, but that program has not been
1255 kept up to date.  gdb does not understand that native HP-UX format, so
1256 you must use gas if you wish to use gdb.
1257
1258 @item m68k-sun
1259 Sun 3.  We do not provide a configuration file to use the Sun FPA by
1260 default, because programs that establish signal handlers for floating
1261 point traps inherently cannot work with the FPA.
1262
1263 See @ref{Sun Install}, for information on installing GNU CC on Sun
1264 systems.
1265
1266 @item m6811-elf
1267 Motorola 68HC11 family micro controllers.  These are used in embedded
1268 applications.  There are no standard Unix configurations.
1269
1270 @item m6812-elf
1271 Motorola 68HC12 family micro controllers.  These are used in embedded
1272 applications.  There are no standard Unix configurations.
1273
1274 @item m88k-*-svr3
1275 Motorola m88k running the AT&T/Unisoft/Motorola V.3 reference port.
1276 These systems tend to use the Green Hills C, revision 1.8.5, as the
1277 standard C compiler.  There are apparently bugs in this compiler that
1278 result in object files differences between stage 2 and stage 3.  If this
1279 happens, make the stage 4 compiler and compare it to the stage 3
1280 compiler.  If the stage 3 and stage 4 object files are identical, this
1281 suggests you encountered a problem with the standard C compiler; the
1282 stage 3 and 4 compilers may be usable.
1283
1284 It is best, however, to use an older version of GNU CC for bootstrapping
1285 if you have one.
1286
1287 @item m88k-*-dgux
1288 Motorola m88k running DG/UX.  To build 88open BCS native or cross
1289 compilers on DG/UX, specify the configuration name as
1290 @samp{m88k-*-dguxbcs} and build in the 88open BCS software development
1291 environment.  To build ELF native or cross compilers on DG/UX, specify
1292 @samp{m88k-*-dgux} and build in the DG/UX ELF development environment.
1293 You set the software development environment by issuing
1294 @samp{sde-target} command and specifying either @samp{m88kbcs} or
1295 @samp{m88kdguxelf} as the operand.
1296
1297 If you do not specify a configuration name, @file{configure} guesses the
1298 configuration based on the current software development environment.
1299
1300 @item m88k-tektronix-sysv3
1301 Tektronix XD88 running UTekV 3.2e.  Do not turn on
1302 optimization while building stage1 if you bootstrap with
1303 the buggy Green Hills compiler.  Also, The bundled LAI
1304 System V NFS is buggy so if you build in an NFS mounted
1305 directory, start from a fresh reboot, or avoid NFS all together.
1306 Otherwise you may have trouble getting clean comparisons
1307 between stages.
1308
1309 @item mips-mips-bsd
1310 MIPS machines running the MIPS operating system in BSD mode.  It's
1311 possible that some old versions of the system lack the functions
1312 @code{memcpy}, @code{memcmp}, and @code{memset}.  If your system lacks
1313 these, you must remove or undo the definition of
1314 @code{TARGET_MEM_FUNCTIONS} in @file{mips-bsd.h}.
1315
1316 The MIPS C compiler needs to be told to increase its table size
1317 for switch statements with the @samp{-Wf,-XNg1500} option in
1318 order to compile @file{cp/parse.c}.  If you use the @samp{-O2}
1319 optimization option, you also need to use @samp{-Olimit 3000}.
1320 Both of these options are automatically generated in the
1321 @file{Makefile} that the shell script @file{configure} builds.
1322 If you override the @code{CC} make variable and use the MIPS
1323 compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}.
1324
1325 @item mips-mips-riscos*
1326 The MIPS C compiler needs to be told to increase its table size
1327 for switch statements with the @samp{-Wf,-XNg1500} option in
1328 order to compile @file{cp/parse.c}.  If you use the @samp{-O2}
1329 optimization option, you also need to use @samp{-Olimit 3000}.
1330 Both of these options are automatically generated in the
1331 @file{Makefile} that the shell script @file{configure} builds.
1332 If you override the @code{CC} make variable and use the MIPS
1333 compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}.
1334
1335 MIPS computers running RISC-OS can support four different
1336 personalities: default, BSD 4.3, System V.3, and System V.4
1337 (older versions of RISC-OS don't support V.4).  To configure GCC
1338 for these platforms use the following configurations:
1339
1340 @table @samp
1341 @item mips-mips-riscos@code{rev}
1342 Default configuration for RISC-OS, revision @code{rev}.
1343
1344 @item mips-mips-riscos@code{rev}bsd
1345 BSD 4.3 configuration for RISC-OS, revision @code{rev}.
1346
1347 @item mips-mips-riscos@code{rev}sysv4
1348 System V.4 configuration for RISC-OS, revision @code{rev}.
1349
1350 @item mips-mips-riscos@code{rev}sysv
1351 System V.3 configuration for RISC-OS, revision @code{rev}.
1352 @end table
1353
1354 The revision @code{rev} mentioned above is the revision of
1355 RISC-OS to use.  You must reconfigure GCC when going from a
1356 RISC-OS revision 4 to RISC-OS revision 5.  This has the effect of
1357 avoiding a linker
1358 @ifclear INSTALLONLY
1359 bug (see @ref{Installation Problems}, for more details).
1360 @end ifclear
1361 @ifset INSTALLONLY
1362 bug.
1363 @end ifset
1364
1365 @item mips-sgi-*
1366 In order to compile GCC on an SGI running IRIX 4, the "c.hdr.lib"
1367 option must be installed from the CD-ROM supplied from Silicon Graphics.
1368 This is found on the 2nd CD in release 4.0.1.
1369
1370 In order to compile GCC on an SGI running IRIX 5, the "compiler_dev.hdr"
1371 subsystem must be installed from the IDO CD-ROM supplied by Silicon
1372 Graphics.
1373
1374 @code{make compare} may fail on version 5 of IRIX unless you add
1375 @samp{-save-temps} to @code{CFLAGS}.  On these systems, the name of the
1376 assembler input file is stored in the object file, and that makes
1377 comparison fail if it differs between the @code{stage1} and
1378 @code{stage2} compilations.  The option @samp{-save-temps} forces a
1379 fixed name to be used for the assembler input file, instead of a
1380 randomly chosen name in @file{/tmp}.  Do not add @samp{-save-temps}
1381 unless the comparisons fail without that option.  If you do you
1382 @samp{-save-temps}, you will have to manually delete the @samp{.i} and
1383 @samp{.s} files after each series of compilations.
1384
1385 The MIPS C compiler needs to be told to increase its table size
1386 for switch statements with the @samp{-Wf,-XNg1500} option in
1387 order to compile @file{cp/parse.c}.  If you use the @samp{-O2}
1388 optimization option, you also need to use @samp{-Olimit 3000}.
1389 Both of these options are automatically generated in the
1390 @file{Makefile} that the shell script @file{configure} builds.
1391 If you override the @code{CC} make variable and use the MIPS
1392 compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}.
1393
1394 On Irix version 4.0.5F, and perhaps on some other versions as well,
1395 there is an assembler bug that reorders instructions incorrectly.  To
1396 work around it, specify the target configuration
1397 @samp{mips-sgi-irix4loser}.  This configuration inhibits assembler
1398 optimization.
1399
1400 In a compiler configured with target @samp{mips-sgi-irix4}, you can turn
1401 off assembler optimization by using the @samp{-noasmopt} option.  This
1402 compiler option passes the option @samp{-O0} to the assembler, to
1403 inhibit reordering.
1404
1405 The @samp{-noasmopt} option can be useful for testing whether a problem
1406 is due to erroneous assembler reordering.  Even if a problem does not go
1407 away with @samp{-noasmopt}, it may still be due to assembler
1408 reordering---perhaps GNU CC itself was miscompiled as a result.
1409
1410 To enable debugging under Irix 5, you must use GNU as 2.5 or later,
1411 and use the @samp{--with-gnu-as} configure option when configuring gcc.
1412 GNU as is distributed as part of the binutils package.
1413
1414 @item mips-sony-sysv
1415 Sony MIPS NEWS.  This works in NEWSOS 5.0.1, but not in 5.0.2 (which
1416 uses ELF instead of COFF).  Support for 5.0.2 will probably be provided
1417 soon by volunteers.  In particular, the linker does not like the
1418 code generated by GCC when shared libraries are linked in.
1419
1420 @item ns32k-encore
1421 Encore ns32000 system.  Encore systems are supported only under BSD.
1422
1423 @item ns32k-*-genix
1424 National Semiconductor ns32000 system.  Genix has bugs in @code{alloca}
1425 and @code{malloc}; you must get the compiled versions of these from GNU
1426 Emacs.
1427
1428 @item ns32k-sequent
1429 Go to the Berkeley universe before compiling.
1430
1431 @item ns32k-utek
1432 UTEK ns32000 system (``merlin'').  The C compiler that comes with this
1433 system cannot compile GNU CC; contact @samp{tektronix!reed!mason} to get
1434 binaries of GNU CC for bootstrapping.
1435
1436 @item romp-*-aos
1437 @itemx romp-*-mach
1438 The only operating systems supported for the IBM RT PC are AOS and
1439 MACH.  GNU CC does not support AIX running on the RT.  We recommend you
1440 compile GNU CC with an earlier version of itself; if you compile GNU CC
1441 with @code{hc}, the Metaware compiler, it will work, but you will get
1442 mismatches between the stage 2 and stage 3 compilers in various files.
1443 These errors are minor differences in some floating-point constants and
1444 can be safely ignored; the stage 3 compiler is correct.
1445
1446 @item rs6000-*-aix
1447 @itemx powerpc-*-aix
1448 Various early versions of each release of the IBM XLC compiler will not
1449 bootstrap GNU CC.  Symptoms include differences between the stage2 and
1450 stage3 object files, and errors when compiling @file{libgcc.a} or
1451 @file{enquire}.  Known problematic releases include: xlc-1.2.1.8,
1452 xlc-1.3.0.0 (distributed with AIX 3.2.5), and xlc-1.3.0.19.  Both
1453 xlc-1.2.1.28 and xlc-1.3.0.24 (PTF 432238) are known to produce working
1454 versions of GNU CC, but most other recent releases correctly bootstrap
1455 GNU CC.
1456
1457 Release 4.3.0 of AIX and ones prior to AIX 3.2.4 include a version of
1458 the IBM assembler which does not accept debugging directives: assembler
1459 updates are available as PTFs.  Also, if you are using AIX 3.2.5 or
1460 greater and the GNU assembler, you must have a version modified after
1461 October 16th, 1995 in order for the GNU C compiler to build.  See the
1462 file @file{README.RS6000} for more details on any of these problems.
1463
1464 GNU CC does not yet support the 64-bit PowerPC instructions.
1465
1466 Objective C does not work on this architecture because it makes assumptions
1467 that are incompatible with the calling conventions.
1468
1469 AIX on the RS/6000 provides support (NLS) for environments outside of
1470 the United States.  Compilers and assemblers use NLS to support
1471 locale-specific representations of various objects including
1472 floating-point numbers ("." vs "," for separating decimal fractions).
1473 There have been problems reported where the library linked with GNU CC
1474 does not produce the same floating-point formats that the assembler
1475 accepts.  If you have this problem, set the LANG environment variable to
1476 "C" or "En_US".
1477
1478 Due to changes in the way that GNU CC invokes the binder (linker) for AIX
1479 4.1, you may now receive warnings of duplicate symbols from the link step
1480 that were not reported before.  The assembly files generated by GNU CC for
1481 AIX have always included multiple symbol definitions for certain global
1482 variable and function declarations in the original program.  The warnings
1483 should not prevent the linker from producing a correct library or runnable
1484 executable.
1485
1486 By default, AIX 4.1 produces code that can be used on either Power or
1487 PowerPC processors.
1488
1489 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1490 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1491
1492 @item powerpc-*-elf
1493 @itemx powerpc-*-sysv4
1494 PowerPC system in big endian mode, running System V.4.
1495
1496 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1497 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1498
1499 @item powerpc-*-linux
1500 @itemx powerpc-*-linux-gnu
1501 PowerPC system in big endian mode, running the Linux-based GNU system.
1502
1503 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1504 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1505
1506 @item powerpc-*-eabiaix
1507 Embedded PowerPC system in big endian mode with -mcall-aix selected as
1508 the default.
1509
1510 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1511 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1512
1513 @item powerpc-*-eabisim
1514 Embedded PowerPC system in big endian mode for use in running under the
1515 PSIM simulator.
1516
1517 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1518 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1519
1520 @item powerpc-*-eabi
1521 Embedded PowerPC system in big endian mode.
1522
1523 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1524 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1525
1526 @item powerpcle-*-elf
1527 @itemx powerpcle-*-sysv4
1528 PowerPC system in little endian mode, running System V.4.
1529
1530 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1531 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1532
1533 @item powerpcle-*-solaris2*
1534 PowerPC system in little endian mode, running Solaris 2.5.1 or higher.
1535
1536 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1537 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1538 Beta versions of the Sun 4.0 compiler do not seem to be able to build
1539 GNU CC correctly.  There are also problems with the host assembler and
1540 linker that are fixed by using the GNU versions of these tools.
1541
1542 @item powerpcle-*-eabisim
1543 Embedded PowerPC system in little endian mode for use in running under
1544 the PSIM simulator.
1545
1546 @itemx powerpcle-*-eabi
1547 Embedded PowerPC system in little endian mode.
1548
1549 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1550 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1551
1552 @item powerpcle-*-winnt
1553 @itemx powerpcle-*-pe
1554 PowerPC system in little endian mode running Windows NT.
1555
1556 You can specify a default version for the @samp{-mcpu=}@var{cpu_type}
1557 switch by using the configure option @samp{--with-cpu-}@var{cpu_type}.
1558
1559 @item vax-dec-ultrix
1560 Don't try compiling with Vax C (@code{vcc}).  It produces incorrect code
1561 in some cases (for example, when @code{alloca} is used).
1562
1563 Meanwhile, compiling @file{cp/parse.c} with pcc does not work because of
1564 an internal table size limitation in that compiler.  To avoid this
1565 problem, compile just the GNU C compiler first, and use it to recompile
1566 building all the languages that you want to run.
1567
1568 @item sparc-sun-*
1569 See @ref{Sun Install}, for information on installing GNU CC on Sun
1570 systems.
1571
1572 @item vax-dec-vms
1573 See @ref{VMS Install}, for details on how to install GNU CC on VMS.
1574
1575 @item we32k-*-*
1576 These computers are also known as the 3b2, 3b5, 3b20 and other similar
1577 names.  (However, the 3b1 is actually a 68000; see
1578 @ref{Configurations}.)
1579
1580 Don't use @samp{-g} when compiling with the system's compiler.  The
1581 system's linker seems to be unable to handle such a large program with
1582 debugging information.
1583
1584 The system's compiler runs out of capacity when compiling @file{stmt.c}
1585 in GNU CC.  You can work around this by building @file{cpp} in GNU CC
1586 first, then use that instead of the system's preprocessor with the
1587 system's C compiler to compile @file{stmt.c}.  Here is how:
1588
1589 @smallexample
1590 mv /lib/cpp /lib/cpp.att
1591 cp cpp /lib/cpp.gnu
1592 echo '/lib/cpp.gnu -traditional $@{1+"$@@"@}' > /lib/cpp
1593 chmod +x /lib/cpp
1594 @end smallexample
1595
1596 The system's compiler produces bad code for some of the GNU CC
1597 optimization files.  So you must build the stage 2 compiler without
1598 optimization.  Then build a stage 3 compiler with optimization.
1599 That executable should work.  Here are the necessary commands:
1600
1601 @smallexample
1602 make LANGUAGES=c CC=stage1/xgcc CFLAGS="-Bstage1/ -g"
1603 make stage2
1604 make CC=stage2/xgcc CFLAGS="-Bstage2/ -g -O"
1605 @end smallexample
1606
1607 You may need to raise the ULIMIT setting to build a C++ compiler,
1608 as the file @file{cc1plus} is larger than one megabyte.
1609 @end table
1610
1611 @node Other Dir
1612 @section Compilation in a Separate Directory
1613 @cindex other directory, compilation in
1614 @cindex compilation in a separate directory
1615 @cindex separate directory, compilation in
1616
1617 If you wish to build the object files and executables in a directory
1618 other than the one containing the source files, here is what you must
1619 do differently:
1620
1621 @enumerate
1622 @item
1623 Make sure you have a version of Make that supports the @code{VPATH}
1624 feature.  (GNU Make supports it, as do Make versions on most BSD
1625 systems.)
1626
1627 @item
1628 If you have ever run @file{configure} in the source directory, you must undo
1629 the configuration.  Do this by running:
1630
1631 @example
1632 make distclean
1633 @end example
1634
1635 @item
1636 Go to the directory in which you want to build the compiler before
1637 running @file{configure}:
1638
1639 @example
1640 mkdir gcc-sun3
1641 cd gcc-sun3
1642 @end example
1643
1644 On systems that do not support symbolic links, this directory must be
1645 on the same file system as the source code directory.
1646
1647 @item
1648 Specify where to find @file{configure} when you run it:
1649
1650 @example
1651 ../gcc/configure @dots{}
1652 @end example
1653
1654 This also tells @code{configure} where to find the compiler sources;
1655 @code{configure} takes the directory from the file name that was used to
1656 invoke it.  But if you want to be sure, you can specify the source
1657 directory with the @samp{--srcdir} option, like this:
1658
1659 @example
1660 ../gcc/configure --srcdir=../gcc @var{other options}
1661 @end example
1662
1663 The directory you specify with @samp{--srcdir} need not be the same
1664 as the one that @code{configure} is found in.
1665 @end enumerate
1666
1667 Now, you can run @code{make} in that directory.  You need not repeat the
1668 configuration steps shown above, when ordinary source files change.  You
1669 must, however, run @code{configure} again when the configuration files
1670 change, if your system does not support symbolic links.
1671
1672 @node Cross-Compiler
1673 @section Building and Installing a Cross-Compiler
1674 @cindex cross-compiler, installation
1675
1676 GNU CC can function as a cross-compiler for many machines, but not all.
1677
1678 @itemize @bullet
1679 @item
1680 Cross-compilers for the Mips as target using the Mips assembler
1681 currently do not work, because the auxiliary programs
1682 @file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled on
1683 anything but a Mips.  It does work to cross compile for a Mips
1684 if you use the GNU assembler and linker.
1685
1686 @item
1687 Cross-compilers between machines with different floating point formats
1688 have not all been made to work.  GNU CC now has a floating point
1689 emulator with which these can work, but each target machine description
1690 needs to be updated to take advantage of it.
1691
1692 @item
1693 Cross-compilation between machines of different word sizes is
1694 somewhat problematic and sometimes does not work.
1695 @end itemize
1696
1697 Since GNU CC generates assembler code, you probably need a
1698 cross-assembler that GNU CC can run, in order to produce object files.
1699 If you want to link on other than the target machine, you need a
1700 cross-linker as well.  You also need header files and libraries suitable
1701 for the target machine that you can install on the host machine.
1702
1703 @menu
1704 * Steps of Cross::      Using a cross-compiler involves several steps
1705                           that may be carried out on different machines.
1706 * Configure Cross::     Configuring a cross-compiler.
1707 * Tools and Libraries:: Where to put the linker and assembler, and the C library.
1708 * Cross Headers::       Finding and installing header files
1709                           for a cross-compiler.
1710 * Cross Runtime::       Supplying arithmetic runtime routines (@file{libgcc1.a}).
1711 * Build Cross::         Actually compiling the cross-compiler.
1712 @end menu
1713
1714 @node Steps of Cross
1715 @subsection Steps of Cross-Compilation
1716
1717 To compile and run a program using a cross-compiler involves several
1718 steps:
1719
1720 @itemize @bullet
1721 @item
1722 Run the cross-compiler on the host machine to produce assembler files
1723 for the target machine.  This requires header files for the target
1724 machine.
1725
1726 @item
1727 Assemble the files produced by the cross-compiler.  You can do this
1728 either with an assembler on the target machine, or with a
1729 cross-assembler on the host machine.
1730
1731 @item
1732 Link those files to make an executable.  You can do this either with a
1733 linker on the target machine, or with a cross-linker on the host
1734 machine.  Whichever machine you use, you need libraries and certain
1735 startup files (typically @file{crt@dots{}.o}) for the target machine.
1736 @end itemize
1737
1738 It is most convenient to do all of these steps on the same host machine,
1739 since then you can do it all with a single invocation of GNU CC.  This
1740 requires a suitable cross-assembler and cross-linker.  For some targets,
1741 the GNU assembler and linker are available.
1742
1743 @node Configure Cross
1744 @subsection Configuring a Cross-Compiler
1745
1746 To build GNU CC as a cross-compiler, you start out by running
1747 @file{configure}.  Use the @samp{--target=@var{target}} to specify the
1748 target type.  If @file{configure} was unable to correctly identify the
1749 system you are running on, also specify the @samp{--build=@var{build}}
1750 option.  For example, here is how to configure for a cross-compiler that
1751 produces code for an HP 68030 system running BSD on a system that
1752 @file{configure} can correctly identify:
1753
1754 @smallexample
1755 ./configure --target=m68k-hp-bsd4.3
1756 @end smallexample
1757
1758 @node Tools and Libraries
1759 @subsection Tools and Libraries for a Cross-Compiler
1760
1761 If you have a cross-assembler and cross-linker available, you should
1762 install them now.  Put them in the directory
1763 @file{/usr/local/@var{target}/bin}.  Here is a table of the tools
1764 you should put in this directory:
1765
1766 @table @file
1767 @item as
1768 This should be the cross-assembler.
1769
1770 @item ld
1771 This should be the cross-linker.
1772
1773 @item ar
1774 This should be the cross-archiver: a program which can manipulate
1775 archive files (linker libraries) in the target machine's format.
1776
1777 @item ranlib
1778 This should be a program to construct a symbol table in an archive file.
1779 @end table
1780
1781 The installation of GNU CC will find these programs in that directory,
1782 and copy or link them to the proper place to for the cross-compiler to
1783 find them when run later.
1784
1785 The easiest way to provide these files is to build the Binutils package
1786 and GAS.  Configure them with the same @samp{--host} and @samp{--target}
1787 options that you use for configuring GNU CC, then build and install
1788 them.  They install their executables automatically into the proper
1789 directory.  Alas, they do not support all the targets that GNU CC
1790 supports.
1791
1792 If you want to install libraries to use with the cross-compiler, such as
1793 a standard C library, put them in the directory
1794 @file{/usr/local/@var{target}/lib}; installation of GNU CC copies
1795 all the files in that subdirectory into the proper place for GNU CC to
1796 find them and link with them.  Here's an example of copying some
1797 libraries from a target machine:
1798
1799 @example
1800 ftp @var{target-machine}
1801 lcd /usr/local/@var{target}/lib
1802 cd /lib
1803 get libc.a
1804 cd /usr/lib
1805 get libg.a
1806 get libm.a
1807 quit
1808 @end example
1809
1810 @noindent
1811 The precise set of libraries you'll need, and their locations on
1812 the target machine, vary depending on its operating system.
1813
1814 @cindex start files
1815 Many targets require ``start files'' such as @file{crt0.o} and
1816 @file{crtn.o} which are linked into each executable; these too should be
1817 placed in @file{/usr/local/@var{target}/lib}.  There may be several
1818 alternatives for @file{crt0.o}, for use with profiling or other
1819 compilation options.  Check your target's definition of
1820 @code{STARTFILE_SPEC} to find out what start files it uses.
1821 Here's an example of copying these files from a target machine:
1822
1823 @example
1824 ftp @var{target-machine}
1825 lcd /usr/local/@var{target}/lib
1826 prompt
1827 cd /lib
1828 mget *crt*.o
1829 cd /usr/lib
1830 mget *crt*.o
1831 quit
1832 @end example
1833
1834 @node Cross Runtime
1835 @subsection @file{libgcc.a} and Cross-Compilers
1836
1837 Code compiled by GNU CC uses certain runtime support functions
1838 implicitly.  Some of these functions can be compiled successfully with
1839 GNU CC itself, but a few cannot be.  These problem functions are in the
1840 source file @file{libgcc1.c}; the library made from them is called
1841 @file{libgcc1.a}.
1842
1843 When you build a native compiler, these functions are compiled with some
1844 other compiler--the one that you use for bootstrapping GNU CC.
1845 Presumably it knows how to open code these operations, or else knows how
1846 to call the run-time emulation facilities that the machine comes with.
1847 But this approach doesn't work for building a cross-compiler.  The
1848 compiler that you use for building knows about the host system, not the
1849 target system.
1850
1851 So, when you build a cross-compiler you have to supply a suitable
1852 library @file{libgcc1.a} that does the job it is expected to do.
1853
1854 To compile @file{libgcc1.c} with the cross-compiler itself does not
1855 work.  The functions in this file are supposed to implement arithmetic
1856 operations that GNU CC does not know how to open code for your target
1857 machine.  If these functions are compiled with GNU CC itself, they
1858 will compile into infinite recursion.
1859
1860 On any given target, most of these functions are not needed.  If GNU CC
1861 can open code an arithmetic operation, it will not call these functions
1862 to perform the operation.  It is possible that on your target machine,
1863 none of these functions is needed.  If so, you can supply an empty
1864 library as @file{libgcc1.a}.
1865
1866 Many targets need library support only for multiplication and division.
1867 If you are linking with a library that contains functions for
1868 multiplication and division, you can tell GNU CC to call them directly
1869 by defining the macros @code{MULSI3_LIBCALL}, and the like.  These
1870 macros need to be defined in the target description macro file.  For
1871 some targets, they are defined already.  This may be sufficient to
1872 avoid the need for libgcc1.a; if so, you can supply an empty library.
1873
1874 Some targets do not have floating point instructions; they need other
1875 functions in @file{libgcc1.a}, which do floating arithmetic.
1876 Recent versions of GNU CC have a file which emulates floating point.
1877 With a certain amount of work, you should be able to construct a
1878 floating point emulator that can be used as @file{libgcc1.a}.  Perhaps
1879 future versions will contain code to do this automatically and
1880 conveniently.  That depends on whether someone wants to implement it.
1881
1882 Some embedded targets come with all the necessary @file{libgcc1.a}
1883 routines written in C or assembler.  These targets build
1884 @file{libgcc1.a} automatically and you do not need to do anything
1885 special for them.  Other embedded targets do not need any
1886 @file{libgcc1.a} routines since all the necessary operations are
1887 supported by the hardware.
1888
1889 If your target system has another C compiler, you can configure GNU CC
1890 as a native compiler on that machine, build just @file{libgcc1.a} with
1891 @samp{make libgcc1.a} on that machine, and use the resulting file with
1892 the cross-compiler.  To do this, execute the following on the target
1893 machine:
1894
1895 @example
1896 cd @var{target-build-dir}
1897 ./configure --host=sparc --target=sun3
1898 make libgcc1.a
1899 @end example
1900
1901 @noindent
1902 And then this on the host machine:
1903
1904 @example
1905 ftp @var{target-machine}
1906 binary
1907 cd @var{target-build-dir}
1908 get libgcc1.a
1909 quit
1910 @end example
1911
1912 Another way to provide the functions you need in @file{libgcc1.a} is to
1913 define the appropriate @code{perform_@dots{}} macros for those
1914 functions.  If these definitions do not use the C arithmetic operators
1915 that they are meant to implement, you should be able to compile them
1916 with the cross-compiler you are building.  (If these definitions already
1917 exist for your target file, then you are all set.)
1918
1919 To build @file{libgcc1.a} using the perform macros, use
1920 @samp{LIBGCC1=libgcc1.a OLDCC=./xgcc} when building the compiler.
1921 Otherwise, you should place your replacement library under the name
1922 @file{libgcc1.a} in the directory in which you will build the
1923 cross-compiler, before you run @code{make}.
1924
1925 @node Cross Headers
1926 @subsection Cross-Compilers and Header Files
1927
1928 If you are cross-compiling a standalone program or a program for an
1929 embedded system, then you may not need any header files except the few
1930 that are part of GNU CC (and those of your program).  However, if you
1931 intend to link your program with a standard C library such as
1932 @file{libc.a}, then you probably need to compile with the header files
1933 that go with the library you use.
1934
1935 The GNU C compiler does not come with these files, because (1) they are
1936 system-specific, and (2) they belong in a C library, not in a compiler.
1937
1938 If the GNU C library supports your target machine, then you can get the
1939 header files from there (assuming you actually use the GNU library when
1940 you link your program).
1941
1942 If your target machine comes with a C compiler, it probably comes with
1943 suitable header files also.  If you make these files accessible from the host
1944 machine, the cross-compiler can use them also.
1945
1946 Otherwise, you're on your own in finding header files to use when
1947 cross-compiling.
1948
1949 When you have found suitable header files, put them in the directory
1950 @file{/usr/local/@var{target}/include}, before building the cross
1951 compiler.  Then installation will run fixincludes properly and install
1952 the corrected versions of the header files where the compiler will use
1953 them.
1954
1955 Provide the header files before you build the cross-compiler, because
1956 the build stage actually runs the cross-compiler to produce parts of
1957 @file{libgcc.a}.  (These are the parts that @emph{can} be compiled with
1958 GNU CC.)  Some of them need suitable header files.
1959
1960 Here's an example showing how to copy the header files from a target
1961 machine.  On the target machine, do this:
1962
1963 @example
1964 (cd /usr/include; tar cf - .) > tarfile
1965 @end example
1966
1967 Then, on the host machine, do this:
1968
1969 @example
1970 ftp @var{target-machine}
1971 lcd /usr/local/@var{target}/include
1972 get tarfile
1973 quit
1974 tar xf tarfile
1975 @end example
1976
1977 @node Build Cross
1978 @subsection Actually Building the Cross-Compiler
1979
1980 Now you can proceed just as for compiling a single-machine compiler
1981 through the step of building stage 1.  If you have not provided some
1982 sort of @file{libgcc1.a}, then compilation will give up at the point
1983 where it needs that file, printing a suitable error message.  If you
1984 do provide @file{libgcc1.a}, then building the compiler will automatically
1985 compile and link a test program called @file{libgcc1-test}; if you get
1986 errors in the linking, it means that not all of the necessary routines
1987 in @file{libgcc1.a} are available.
1988
1989 You must provide the header file @file{float.h}.  One way to do this is
1990 to compile @file{enquire} and run it on your target machine.  The job of
1991 @file{enquire} is to run on the target machine and figure out by
1992 experiment the nature of its floating point representation.
1993 @file{enquire} records its findings in the header file @file{float.h}.
1994 If you can't produce this file by running @file{enquire} on the target
1995 machine, then you will need to come up with a suitable @file{float.h} in
1996 some other way (or else, avoid using it in your programs).
1997
1998 Do not try to build stage 2 for a cross-compiler.  It doesn't work to
1999 rebuild GNU CC as a cross-compiler using the cross-compiler, because
2000 that would produce a program that runs on the target machine, not on the
2001 host.  For example, if you compile a 386-to-68030 cross-compiler with
2002 itself, the result will not be right either for the 386 (because it was
2003 compiled into 68030 code) or for the 68030 (because it was configured
2004 for a 386 as the host).  If you want to compile GNU CC into 68030 code,
2005 whether you compile it on a 68030 or with a cross-compiler on a 386, you
2006 must specify a 68030 as the host when you configure it.
2007
2008 To install the cross-compiler, use @samp{make install}, as usual.
2009
2010 @node Sun Install
2011 @section Installing GNU CC on the Sun
2012 @cindex Sun installation
2013 @cindex installing GNU CC on the Sun
2014
2015 On Solaris, do not use the linker or other tools in
2016 @file{/usr/ucb} to build GNU CC.  Use @code{/usr/ccs/bin}.
2017
2018 If the assembler reports @samp{Error: misaligned data} when bootstrapping,
2019 you are probably using an obsolete version of the GNU assembler.  Upgrade
2020 to the latest version of GNU @code{binutils}, or use the Solaris assembler.
2021
2022 Make sure the environment variable @code{FLOAT_OPTION} is not set when
2023 you compile @file{libgcc.a}.  If this option were set to @code{f68881}
2024 when @file{libgcc.a} is compiled, the resulting code would demand to be
2025 linked with a special startup file and would not link properly without
2026 special pains.
2027
2028 @cindex @code{alloca}, for SunOS
2029 There is a bug in @code{alloca} in certain versions of the Sun library.
2030 To avoid this bug, install the binaries of GNU CC that were compiled by
2031 GNU CC.  They use @code{alloca} as a built-in function and never the one
2032 in the library.
2033
2034 Some versions of the Sun compiler crash when compiling GNU CC.  The
2035 problem is a segmentation fault in cpp.  This problem seems to be due to
2036 the bulk of data in the environment variables.  You may be able to avoid
2037 it by using the following command to compile GNU CC with Sun CC:
2038
2039 @example
2040 make CC="TERMCAP=x OBJS=x LIBFUNCS=x STAGESTUFF=x cc"
2041 @end example
2042
2043 SunOS 4.1.3 and 4.1.3_U1 have bugs that can cause intermittent core
2044 dumps when compiling GNU CC.  A common symptom is an
2045 internal compiler error which does not recur if you run it again.
2046 To fix the problem, install Sun recommended patch 100726 (for SunOS 4.1.3)
2047 or 101508 (for SunOS 4.1.3_U1), or upgrade to a later SunOS release.
2048
2049 @node VMS Install
2050 @section Installing GNU CC on VMS
2051 @cindex VMS installation
2052 @cindex installing GNU CC on VMS
2053
2054 The VMS version of GNU CC is distributed in a backup saveset containing
2055 both source code and precompiled binaries.
2056
2057 To install the @file{gcc} command so you can use the compiler easily, in
2058 the same manner as you use the VMS C compiler, you must install the VMS CLD
2059 file for GNU CC as follows:
2060
2061 @enumerate
2062 @item
2063 Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
2064 to point to the directories where the GNU CC executables
2065 (@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are
2066 kept respectively.  This should be done with the commands:@refill
2067
2068 @smallexample
2069 $ assign /system /translation=concealed -
2070   disk:[gcc.] gnu_cc
2071 $ assign /system /translation=concealed -
2072   disk:[gcc.include.] gnu_cc_include
2073 @end smallexample
2074
2075 @noindent
2076 with the appropriate disk and directory names.  These commands can be
2077 placed in your system startup file so they will be executed whenever
2078 the machine is rebooted.  You may, if you choose, do this via the
2079 @file{GCC_INSTALL.COM} script in the @file{[GCC]} directory.
2080
2081 @item
2082 Install the @file{GCC} command with the command line:
2083
2084 @smallexample
2085 $ set command /table=sys$common:[syslib]dcltables -
2086   /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
2087 $ install replace sys$common:[syslib]dcltables
2088 @end smallexample
2089
2090 @item
2091 To install the help file, do the following:
2092
2093 @smallexample
2094 $ library/help sys$library:helplib.hlb gcc.hlp
2095 @end smallexample
2096
2097 @noindent
2098 Now you can invoke the compiler with a command like @samp{gcc /verbose
2099 file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
2100 Unix.
2101 @end enumerate
2102
2103 If you wish to use GNU C++ you must first install GNU CC, and then
2104 perform the following steps:
2105
2106 @enumerate
2107 @item
2108 Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the
2109 directory where the preprocessor will search for the C++ header files.
2110 This can be done with the command:@refill
2111
2112 @smallexample
2113 $ assign /system /translation=concealed -
2114   disk:[gcc.gxx_include.] gnu_gxx_include
2115 @end smallexample
2116
2117 @noindent
2118 with the appropriate disk and directory name.  If you are going to be
2119 using a C++ runtime library, this is where its install procedure will install
2120 its header files.
2121
2122 @item
2123 Obtain the file @file{gcc-cc1plus.exe}, and place this in the same
2124 directory that @file{gcc-cc1.exe} is kept.
2125
2126 The GNU C++ compiler can be invoked with a command like @samp{gcc /plus
2127 /verbose file.cc}, which is equivalent to the command @samp{g++ -v -c
2128 file.cc} in Unix.
2129 @end enumerate
2130
2131 We try to put corresponding binaries and sources on the VMS distribution
2132 tape.  But sometimes the binaries will be from an older version than the
2133 sources, because we don't always have time to update them.  (Use the
2134 @samp{/version} option to determine the version number of the binaries and
2135 compare it with the source file @file{version.c} to tell whether this is
2136 so.)  In this case, you should use the binaries you get to recompile the
2137 sources.  If you must recompile, here is how:
2138
2139 @enumerate
2140 @item
2141 Execute the command procedure @file{vmsconfig.com} to set up the files
2142 @file{tm.h}, @file{config.h}, @file{aux-output.c}, and @file{md.}, and
2143 to create files @file{tconfig.h} and @file{hconfig.h}.  This procedure
2144 also creates several linker option files used by @file{make-cc1.com} and
2145 a data file used by @file{make-l2.com}.@refill
2146
2147 @smallexample
2148 $ @@vmsconfig.com
2149 @end smallexample
2150
2151 @item
2152 Setup the logical names and command tables as defined above.  In
2153 addition, define the VMS logical name @samp{GNU_BISON} to point at the
2154 to the directories where the Bison executable is kept.  This should be
2155 done with the command:@refill
2156
2157 @smallexample
2158 $ assign /system /translation=concealed -
2159   disk:[bison.] gnu_bison
2160 @end smallexample
2161
2162 You may, if you choose, use the @file{INSTALL_BISON.COM} script in the
2163 @file{[BISON]} directory.
2164
2165 @item
2166 Install the @samp{BISON} command with the command line:@refill
2167
2168 @smallexample
2169 $ set command /table=sys$common:[syslib]dcltables -
2170   /output=sys$common:[syslib]dcltables -
2171   gnu_bison:[000000]bison
2172 $ install replace sys$common:[syslib]dcltables
2173 @end smallexample
2174
2175 @item
2176 Type @samp{@@make-gcc} to recompile everything (alternatively, submit
2177 the file @file{make-gcc.com} to a batch queue).  If you wish to build
2178 the GNU C++ compiler as well as the GNU CC compiler, you must first edit
2179 @file{make-gcc.com} and follow the instructions that appear in the
2180 comments.@refill
2181
2182 @item
2183 In order to use GCC, you need a library of functions which GCC compiled code
2184 will call to perform certain tasks, and these functions are defined in the
2185 file @file{libgcc2.c}.  To compile this you should use the command procedure
2186 @file{make-l2.com}, which will generate the library @file{libgcc2.olb}.
2187 @file{libgcc2.olb} should be built using the compiler built from
2188 the same distribution that @file{libgcc2.c} came from, and
2189 @file{make-gcc.com} will automatically do all of this for you.
2190
2191 To install the library, use the following commands:@refill
2192
2193 @smallexample
2194 $ library gnu_cc:[000000]gcclib/delete=(new,eprintf)
2195 $ library gnu_cc:[000000]gcclib/delete=L_*
2196 $ library libgcc2/extract=*/output=libgcc2.obj
2197 $ library gnu_cc:[000000]gcclib libgcc2.obj
2198 @end smallexample
2199
2200 The first command simply removes old modules that will be replaced with
2201 modules from @file{libgcc2} under different module names.  The modules
2202 @code{new} and @code{eprintf} may not actually be present in your
2203 @file{gcclib.olb}---if the VMS librarian complains about those modules
2204 not being present, simply ignore the message and continue on with the
2205 next command.  The second command removes the modules that came from the
2206 previous version of the library @file{libgcc2.c}.
2207
2208 Whenever you update the compiler on your system, you should also update the
2209 library with the above procedure.
2210
2211 @item
2212 You may wish to build GCC in such a way that no files are written to the
2213 directory where the source files reside.  An example would be the when
2214 the source files are on a read-only disk.  In these cases, execute the
2215 following DCL commands (substituting your actual path names):
2216
2217 @smallexample
2218 $ assign dua0:[gcc.build_dir.]/translation=concealed, -
2219          dua1:[gcc.source_dir.]/translation=concealed  gcc_build
2220 $ set default gcc_build:[000000]
2221 @end smallexample
2222
2223 @noindent
2224 where the directory @file{dua1:[gcc.source_dir]} contains the source
2225 code, and the directory @file{dua0:[gcc.build_dir]} is meant to contain
2226 all of the generated object files and executables.  Once you have done
2227 this, you can proceed building GCC as described above.  (Keep in mind
2228 that @file{gcc_build} is a rooted logical name, and thus the device
2229 names in each element of the search list must be an actual physical
2230 device name rather than another rooted logical name).
2231
2232 @item
2233 @strong{If you are building GNU CC with a previous version of GNU CC,
2234 you also should check to see that you have the newest version of the
2235 assembler}.  In particular, GNU CC version 2 treats global constant
2236 variables slightly differently from GNU CC version 1, and GAS version
2237 1.38.1 does not have the patches required to work with GCC version 2.
2238 If you use GAS 1.38.1, then @code{extern const} variables will not have
2239 the read-only bit set, and the linker will generate warning messages
2240 about mismatched psect attributes for these variables.  These warning
2241 messages are merely a nuisance, and can safely be ignored.
2242
2243 If you are compiling with a version of GNU CC older than 1.33, specify
2244 @samp{/DEFINE=("inline=")} as an option in all the compilations.  This
2245 requires editing all the @code{gcc} commands in @file{make-cc1.com}.
2246 (The older versions had problems supporting @code{inline}.)  Once you
2247 have a working 1.33 or newer GNU CC, you can change this file back.
2248
2249 @item
2250 If you want to build GNU CC with the VAX C compiler, you will need to
2251 make minor changes in @file{make-cccp.com} and @file{make-cc1.com}
2252 to choose alternate definitions of @code{CC}, @code{CFLAGS}, and
2253 @code{LIBS}.  See comments in those files.  However, you must
2254 also have a working version of the GNU assembler (GNU as, aka GAS) as
2255 it is used as the back-end for GNU CC to produce binary object modules
2256 and is not included in the GNU CC sources.  GAS is also needed to
2257 compile @file{libgcc2} in order to build @file{gcclib} (see above);
2258 @file{make-l2.com} expects to be able to find it operational in
2259 @file{gnu_cc:[000000]gnu-as.exe}.
2260
2261 To use GNU CC on VMS, you need the VMS driver programs
2262 @file{gcc.exe}, @file{gcc.com}, and @file{gcc.cld}.  They are
2263 distributed with the VMS binaries (@file{gcc-vms}) rather than the
2264 GNU CC sources.  GAS is also included in @file{gcc-vms}, as is Bison.
2265
2266 Once you have successfully built GNU CC with VAX C, you should use the
2267 resulting compiler to rebuild itself.  Before doing this, be sure to
2268 restore the @code{CC}, @code{CFLAGS}, and @code{LIBS} definitions in
2269 @file{make-cccp.com} and @file{make-cc1.com}.  The second generation
2270 compiler will be able to take advantage of many optimizations that must
2271 be suppressed when building with other compilers.
2272 @end enumerate
2273
2274 Under previous versions of GNU CC, the generated code would occasionally
2275 give strange results when linked with the sharable @file{VAXCRTL} library.
2276 Now this should work.
2277
2278 Even with this version, however, GNU CC itself should not be linked with
2279 the sharable @file{VAXCRTL}.  The version of @code{qsort} in
2280 @file{VAXCRTL} has a bug (known to be present in VMS versions V4.6
2281 through V5.5) which causes the compiler to fail.
2282
2283 The executables are generated by @file{make-cc1.com} and
2284 @file{make-cccp.com} use the object library version of @file{VAXCRTL} in
2285 order to make use of the @code{qsort} routine in @file{gcclib.olb}.  If
2286 you wish to link the compiler executables with the shareable image
2287 version of @file{VAXCRTL}, you should edit the file @file{tm.h} (created
2288 by @file{vmsconfig.com}) to define the macro @code{QSORT_WORKAROUND}.
2289
2290 @code{QSORT_WORKAROUND} is always defined when GNU CC is compiled with
2291 VAX C, to avoid a problem in case @file{gcclib.olb} is not yet
2292 available.
2293
2294 @node Collect2
2295 @section @code{collect2}
2296
2297 GNU CC uses a utility called @code{collect2} on nearly all systems to arrange
2298 to call various initialization functions at start time.
2299
2300 The program @code{collect2} works by linking the program once and
2301 looking through the linker output file for symbols with particular names
2302 indicating they are constructor functions.  If it finds any, it
2303 creates a new temporary @samp{.c} file containing a table of them,
2304 compiles it, and links the program a second time including that file.
2305
2306 @findex __main
2307 @cindex constructors, automatic calls
2308 The actual calls to the constructors are carried out by a subroutine
2309 called @code{__main}, which is called (automatically) at the beginning
2310 of the body of @code{main} (provided @code{main} was compiled with GNU
2311 CC).  Calling @code{__main} is necessary, even when compiling C code, to
2312 allow linking C and C++ object code together.  (If you use
2313 @samp{-nostdlib}, you get an unresolved reference to @code{__main},
2314 since it's defined in the standard GCC library.  Include @samp{-lgcc} at
2315 the end of your compiler command line to resolve this reference.)
2316
2317 The program @code{collect2} is installed as @code{ld} in the directory
2318 where the passes of the compiler are installed.  When @code{collect2}
2319 needs to find the @emph{real} @code{ld}, it tries the following file
2320 names:
2321
2322 @itemize @bullet
2323 @item
2324 @file{real-ld} in the directories listed in the compiler's search
2325 directories.
2326
2327 @item
2328 @file{real-ld} in the directories listed in the environment variable
2329 @code{PATH}.
2330
2331 @item
2332 The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
2333 if specified.
2334
2335 @item
2336 @file{ld} in the compiler's search directories, except that
2337 @code{collect2} will not execute itself recursively.
2338
2339 @item
2340 @file{ld} in @code{PATH}.
2341 @end itemize
2342
2343 ``The compiler's search directories'' means all the directories where
2344 @code{gcc} searches for passes of the compiler.  This includes
2345 directories that you specify with @samp{-B}.
2346
2347 Cross-compilers search a little differently:
2348
2349 @itemize @bullet
2350 @item
2351 @file{real-ld} in the compiler's search directories.
2352
2353 @item
2354 @file{@var{target}-real-ld} in @code{PATH}.
2355
2356 @item
2357 The file specified in the @code{REAL_LD_FILE_NAME} configuration macro,
2358 if specified.
2359
2360 @item
2361 @file{ld} in the compiler's search directories.
2362
2363 @item
2364 @file{@var{target}-ld} in @code{PATH}.
2365 @end itemize
2366
2367 @code{collect2} explicitly avoids running @code{ld} using the file name
2368 under which @code{collect2} itself was invoked.  In fact, it remembers
2369 up a list of such names---in case one copy of @code{collect2} finds
2370 another copy (or version) of @code{collect2} installed as @code{ld} in a
2371 second place in the search path.
2372
2373 @code{collect2} searches for the utilities @code{nm} and @code{strip}
2374 using the same algorithm as above for @code{ld}.
2375
2376 @node Header Dirs
2377 @section Standard Header File Directories
2378
2379 @code{GCC_INCLUDE_DIR} means the same thing for native and cross.  It is
2380 where GNU CC stores its private include files, and also where GNU CC
2381 stores the fixed include files.  A cross compiled GNU CC runs
2382 @code{fixincludes} on the header files in @file{$(tooldir)/include}.
2383 (If the cross compilation header files need to be fixed, they must be
2384 installed before GNU CC is built.  If the cross compilation header files
2385 are already suitable for ANSI C and GNU CC, nothing special need be
2386 done).
2387
2388 @code{GPLUSPLUS_INCLUDE_DIR} means the same thing for native and cross.  It
2389 is where @code{g++} looks first for header files.  The C++ library
2390 installs only target independent header files in that directory.
2391
2392 @code{LOCAL_INCLUDE_DIR} is used only for a native compiler.  It is
2393 normally @file{/usr/local/include}.  GNU CC searches this directory so
2394 that users can install header files in @file{/usr/local/include}.
2395
2396 @code{CROSS_INCLUDE_DIR} is used only for a cross compiler.  GNU CC
2397 doesn't install anything there.
2398
2399 @code{TOOL_INCLUDE_DIR} is used for both native and cross compilers.  It
2400 is the place for other packages to install header files that GNU CC will
2401 use.  For a cross-compiler, this is the equivalent of
2402 @file{/usr/include}.  When you build a cross-compiler,
2403 @code{fixincludes} processes any header files in this directory.