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