OSDN Git Service

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