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