home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / msdos / djgpp / docs / gcc / install.tex < prev    next >
Encoding:
Text File  |  1993-05-29  |  57.9 KB  |  1,506 lines

  1. @c Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  2. @c This is part of the GCC manual.
  3. @c For copying conditions, see the file gcc.texi.
  4.  
  5. @c The text of this file appears in the file INSTALL
  6. @c in the GCC distribution, as well as in the GCC manual.
  7.  
  8. @ifclear INSTALLONLY
  9. @node Installation
  10. @chapter Installing GNU CC
  11. @end ifclear
  12. @cindex installing GNU CC
  13.  
  14. Here is the procedure for installing GNU CC on a Unix system.
  15.  
  16. @menu
  17. * Other Dir::     Compiling in a separate directory (not where the source is).
  18. * Cross-Compiler::   Building and installing a cross-compiler.
  19. * PA Install::    See below for installation on the HP Precision Architecture.
  20. * Sun Install::   See below for installation on the Sun.
  21. * 3b1 Install::   See below for installation on the 3b1.
  22. * Unos Install::  See below for installation on Unos (from CRDS).
  23. * VMS Install::   See below for installation on VMS.
  24. * WE32K Install:: See below for installation on the 3b* aside from the 3b1.
  25. * MIPS Install::  See below for installation on the MIPS Architecture.
  26. * Collect2::      How @code{collect2} works; how it finds @code{ld}.
  27. @end menu
  28. @iftex
  29. See below for VMS systems, and modified procedures needed on other
  30. systems including HP, Sun, 3b1, SCO Unix and Unos.  The following section
  31. says how to compile in a separate directory on Unix; here we assume you
  32. compile in the same directory that contains the source files.
  33. @end iftex
  34.  
  35. @enumerate
  36. @item
  37. If you have built GNU CC previously in the same directory for a
  38. different target machine, do @samp{make distclean} to delete all files
  39. that might be invalid.  One of the files this deletes is
  40. @file{Makefile}; if @samp{make distclean} complains that @file{Makefile}
  41. does not exist, it probably means that the directory is already suitably
  42. clean.
  43.  
  44. @item
  45. On a System V release 4 system, make sure @file{/usr/bin} precedes
  46. @file{/usr/ucb} in @code{PATH}.  The @code{cc} command in
  47. @file{/usr/ucb} uses libraries which have bugs.
  48.  
  49. @item
  50. Specify the host and target machine configurations.  You do this by
  51. running the file @file{configure} with appropriate arguments.
  52.  
  53. If you are building a compiler to produce code for the machine it runs
  54. on, specify just one machine type.  Use the @samp{--target} option; the
  55. host type will default to be the same as the target.  (For information
  56. on building a cross-compiler, see @ref{Cross-Compiler}.)  The command
  57. looks like this:
  58.  
  59. @smallexample
  60. configure --target=sparc-sun-sunos4.1
  61. @end smallexample
  62.  
  63. A configuration name may be canonical or it may be more or less
  64. abbreviated.
  65.  
  66. A canonical configuration name has three parts, separated by dashes.
  67. It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}.
  68. (The three parts may themselves contain dashes; @file{configure}
  69. can figure out which dashes serve which purpose.)  For example,
  70. @samp{m68k-sun-sunos4.1} specifies a Sun 3.
  71.  
  72. You can also replace parts of the configuration by nicknames or aliases.
  73. For example, @samp{sun3} stands for @samp{m68k-sun}, so
  74. @samp{sun3-sunos4.1} is another way to specify a Sun 3.  You can also
  75. use simply @samp{sun3-sunos}, since the version of SunOS is assumed by
  76. default to be version 4.  @samp{sun3-bsd} also works, since
  77. @file{configure} knows that the only BSD variant on a Sun 3 is SunOS.
  78.  
  79. You can specify a version number after any of the system types, and some
  80. of the CPU types.  In most cases, the version is irrelevant, and will be
  81. ignored.  So you might as well specify the version if you know it.
  82.  
  83. Here are the possible CPU types:
  84.  
  85. @quotation
  86. @c gmicro, alliant, spur and tahoe omitted since they don't work.
  87. a29k, alpha, arm, c@var{n}, clipper, elxsi, h8300, hppa1.0, hppa1.1,
  88. i386, i860, i960, m68000, m68k, m88k, mips,
  89. ns32k, pyramid, romp, rs6000, sh, sparc, sparclite, vax, we32k.
  90. @end quotation
  91.  
  92. Here are the recognized company names.  As you can see, customary
  93. abbreviations are used rather than the longer official names.
  94.  
  95. @c What should be done about merlin, tek*, dolphin?
  96. @quotation
  97. alliant, altos, apollo, att, bull,
  98. cbm, convergent, convex, crds, dec, dg, dolphin,
  99. elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi,
  100. mips, motorola, ncr, next, ns, omron, plexus,
  101. sequent, sgi, sony, sun, tti, unicom.
  102. @end quotation
  103.  
  104. The company name is meaningful only to disambiguate when the rest of
  105. the information supplied is insufficient.  You can omit it, writing
  106. just @samp{@var{cpu}-@var{system}}, if it is not needed.  For example,
  107. @samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}.
  108.  
  109. Here is a list of system types:
  110.  
  111. @quotation
  112. aix, acis, aos, bsd, clix, ctix, dgux, dynix,
  113. genix, hpux, isc, linux, luna, mach,
  114. minix, newsos, osf, osfrose, riscos,
  115. sco, solaris, sunos, sysv, ultrix, unos, vms.
  116. @end quotation
  117.  
  118. @noindent
  119. You can omit the system type; then @file{configure} guesses the
  120. operating system from the CPU and company.
  121.  
  122. You can add a version number to the system type; this may or may not
  123. make a difference.  For example, you can write @samp{bsd4.3} or
  124. @samp{bsd4.4} to distinguish versions of BSD.  In practice, the version
  125. number is most needed for @samp{sysv3} and @samp{sysv4}, which are often
  126. treated differently.
  127.  
  128. If you specify an impossible combination such as @samp{i860-dg-vms},
  129. then you may get an error message from @file{configure}, or it may
  130. ignore part of the information and do the best it can with the rest.
  131. @file{configure} always prints the canonical name for the alternative
  132. that it used.
  133.  
  134. Often a particular model of machine has a name.  Many machine names are
  135. recognized as aliases for CPU/company combinations.  Thus, the machine
  136. name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}.
  137. Sometimes we accept a company name as a machine name, when the name is
  138. popularly used for a particular machine.  Here is a table of the known
  139. machine names:
  140.  
  141. @quotation
  142. 3300, 3b1, 3b@var{n}, 7300, altos3068, altos,
  143. apollo68, att-7300, balance,
  144. convex-c@var{n}, crds, decstation-3100,
  145. decstation, delta, encore,
  146. fx2800, gmicro, hp7@var{nn}, hp8@var{nn},
  147. hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn},
  148. hp9k8@var{nn}, iris4d, iris, isi68,
  149. m3230, magnum, merlin, miniframe,
  150. mmax, news-3600, news800, news, next,
  151. pbd, pc532, pmax, ps2, risc-news,
  152. rtpc, sun2, sun386i, sun386, sun3,
  153. sun4, symmetry, tower-32, tower.
  154. @end quotation 
  155.  
  156. @noindent
  157. Remember that a machine name specifies both the cpu type and the company
  158. name.
  159.  
  160. There are four additional options you can specify independently to 
  161. describe variant hardware and software configurations.  These are
  162. @samp{--with-gnu-as}, @samp{--with-gnu-ld}, @samp{--with-stabs} and
  163. @samp{--nfp}.
  164.  
  165. @table @samp
  166. @item --with-gnu-as
  167. On certain systems, you must specify whether you want GNU CC to work
  168. with the usual compilation tools or with the GNU compilation tools
  169. (including GAS).  Use the @samp{--with-gnu-as} argument when you run
  170. @file{configure}, if you want to use the GNU tools.  (Specify
  171. @samp{--with-gnu-ld} as well, since on these systems GAS works only with
  172. the GNU linker.)  The systems where this makes a difference are
  173. @samp{i386-@var{anything}-sysv}, @samp{i860-@var{anything}-bsd},
  174. @samp{m68k-hp-hpux}, @samp{m68k-sony-bsd}, @samp{m68k-altos-sysv},
  175. @samp{m68000-hp-hpux}, @samp{m68000-att-sysv}, and
  176. @samp{mips-@var{any}}).  On any other system, @samp{--with-gnu-as} has
  177. no effect.
  178.  
  179. @c the above needs some serious help.. rearrange the systems names, or
  180. @c something.. :-( --mew
  181.  
  182. @item --with-gnu-ld
  183. Specify the option @samp{--with-gnu-ld} if you plan to use the GNU
  184. linker.  This inhibits the installation of @code{collect2}, a program
  185. which otherwise serves as a front-end for the system's linker on most
  186. configurations.
  187.  
  188. @item --with-stabs
  189. On MIPS based systems, you must specify whether you want GNU CC to
  190. create the normal ECOFF debugging format, or to use BSD-style stabs
  191. passed through the ECOFF symbol table.  The normal ECOFF debug format
  192. cannot fully handle languages other than C.  BSD stabs format can handle
  193. other languages, but it only works with the GNU debugger GDB.
  194.  
  195. Normally, GNU CC uses the ECOFF debugging format by default; if you
  196. prefer BSD stabs, specify @samp{--with-stabs} when you configure GNU
  197. CC.
  198.  
  199. No matter which default you choose when you configure GNU CC, the user
  200. can use the @samp{-gcoff} and @samp{-gstabs+} options to specify explicitly
  201. the debug format for a particular compilation.
  202.  
  203. @item --nfp
  204. On certain systems, you must specify whether the machine has a floating
  205. point unit.  These systems are @samp{m68k-sun-sunos@var{n}} and
  206. @samp{m68k-isi-bsd}.  On any other system, @samp{--nfp} currently has no
  207. effect, though perhaps there are other systems where it could usefully
  208. make a difference.
  209. @end table
  210.  
  211. If you want to install your own homemade configuration files, you can
  212. use @samp{local} as the company name to access them.  If you use 
  213. configuration @samp{@var{cpu}-local}, the configuration name
  214. without the cpu prefix 
  215. is used to form the configuration file names.
  216.  
  217. Thus, if you specify @samp{m68k-local}, then the files
  218. @file{m68k/local.md}, @file{m68k/local.h}, @file{m68k/local.c},
  219. @file{m68k/xm-local.h}, @file{m68k/t-local}, and @file{m68k/x-local}
  220. will be used.
  221.  
  222. Here is a list of configurations that have special treatment or special
  223. things you must know:
  224.  
  225. @table @samp
  226. @item alpha-*-osf1
  227. Systems using processors that implement the DEC Alpha architecture and
  228. are running the OSF/1 operating system, for example the DEC Alpha AXP
  229. systems.  (VMS on the Alpha is not currently supported by GNU CC.)
  230.  
  231. GNU CC writes a @samp{.verstamp} directive to the assembler output file
  232. unless it is built as a cross-compiler.  It gets the version to use from
  233. the file @file{/usr/include/stamp.h}.  If you install a new version of
  234. OSF/1, you should rebuild GCC to pick up the new version stamp.
  235.  
  236. Note that since the Alpha is a 64-bit architecture, cross-compilers
  237. from 32-bit machines will not generate as efficient code as that
  238. generated when the compiler is running on a 64-bit machine because many
  239. optimizations that depend on being able to represent a word on the
  240. target in an integral value on the host cannot be performed.
  241. Building cross-compilers for 32-bit machines that run on the Alpha
  242. has not been tested and may not work properly.
  243.  
  244. @item a29k
  245. AMD Am29K-family processors.  These are normally used in embedded
  246. applications.  There are no standard Unix configurations.
  247. This configuration
  248. corresponds to AMD's standard calling sequence and binary interface
  249. and is compatible with other 29K tools.  
  250.  
  251. You may need to make a variant of the file @file{a29k.h} for your
  252. particular configuration.
  253.  
  254. @item a29k-*-bsd
  255. AMD Am29050 used in a system running a variant of BSD Unix.
  256.  
  257. @item elxsi-elxsi-bsd
  258. The Elxsi's C compiler has known limitations that prevent it from
  259. compiling GNU C.  Please contact @code{mrs@@cygnus.com} for more details.
  260.  
  261. @ignore
  262. @item fx80
  263. Alliant FX/8 computer.  Note that the standard installed C compiler in
  264. Concentrix 5.0 has a bug which prevent it from compiling GNU CC
  265. correctly.  You can patch the compiler bug as follows:
  266.  
  267. @smallexample
  268. cp /bin/pcc ./pcc
  269. adb -w ./pcc - << EOF
  270. 15f6?w 6610
  271. EOF
  272. @end smallexample
  273.  
  274. Then you must use the @samp{-ip12} option when compiling GNU CC
  275. with the patched compiler, as shown here:
  276.  
  277. @smallexample
  278. make CC="./pcc -ip12" CFLAGS=-w
  279. @end smallexample
  280.  
  281. Note also that Alliant's version of DBX does not manage to work with the
  282. output from GNU CC.
  283. @end ignore
  284.  
  285. @item i386-*-sco
  286. Compilation with RCC is recommended.
  287.  
  288. @item i386-ibm-aix
  289. You need to use GAS version 2.1 or later, and and LD from
  290. GNU binutils version 2.2 or later.
  291.  
  292. @item i386-sequent
  293. Go to the Berkeley universe before compiling.  In addition, you probably
  294. need to create a file named @file{string.h} containing just one line:
  295. @samp{#include <strings.h>}.
  296.  
  297. @item i386-sun-sunos4
  298. You may find that you need another version of GNU CC to begin
  299. bootstrapping with, since the current version when built with the
  300. system's own compiler seems to get an infinite loop compiling part of
  301. @file{libgcc2.c}.  GNU CC version 2 compiled with GNU CC (any version)
  302. seems not to have this problem.
  303.  
  304. @item m68000-att
  305. AT&T 3b1, a.k.a. 7300 PC.  Special procedures are needed to compile GNU
  306. CC with this machine's standard C compiler, due to bugs in that
  307. compiler.  @xref{3b1 Install}.  You can bootstrap it more easily with
  308. previous versions of GNU CC if you have them.
  309.  
  310. @item m68000-hp-bsd
  311. HP 9000 series 200 running BSD.  Note that the C compiler that comes
  312. with this system cannot compile GNU CC; contact @code{law@@cs.utah.edu}
  313. to get binaries of GNU CC for bootstrapping.
  314.  
  315. @item m68k-altos
  316. Altos 3068.  You must use the GNU assembler, linker and debugger.
  317. Also, you must fix a kernel bug.  Details in the file @file{README.ALTOS}.
  318.  
  319. @item m68k-hp-hpux
  320. HP 9000 series 300 or 400 running HP-UX.  HP-UX version 8.0 has a bug in
  321. the assembler that prevents compilation of GNU CC.  To fix it, get patch
  322. PHCO_0800 from HP.
  323.  
  324. In addition, @samp{--gas} does not currently work with this
  325. configuration.  Changes in HP-UX have broken the library conversion tool
  326. and the linker.
  327.  
  328. @item m68k-sun
  329. Sun 3.  We do not provide a configuration file to use the Sun FPA by
  330. default, because programs that establish signal handlers for floating
  331. point traps inherently cannot work with the FPA.
  332.  
  333. @item m88k-svr3
  334. Motorola m88k running the AT&T/Unisoft/Motorola V.3 reference port.
  335. These systems tend to use the Green Hills C, revision 1.8.5, as the
  336. standard C compiler.  There are apparently bugs in this compiler that
  337. result in object files differences between stage 2 and stage 3.  If this
  338. happens, make the stage 4 compiler and compare it to the stage 3
  339. compiler.  If the stage 3 and stage 4 object files are identical, this
  340. suggests a problem with the standard C compiler.  It is best, however,
  341. to use an older version of GNU CC for bootstrapping.
  342.  
  343. @item m88k-dgux
  344. Motorola m88k running DG/UX.  To build native or cross compilers on
  345. DG/UX, you must first change to the 88open BCS software development
  346. environment.  This is done by issuing this command:
  347.  
  348. @smallexample
  349. eval `sde-target m88kbcs`
  350. @end smallexample
  351.  
  352. @item m88k-tektronix-sysv3
  353. Tektronix XD88 running UTekV 3.2e.  Do not turn on
  354. optimization while building stage1 if you bootstrap with
  355. the buggy Green Hills compiler.  Also, The bundled LAI
  356. System V NFS is buggy so if you build in an NFS mounted
  357. directory, start from a fresh reboot, or avoid NFS all together.
  358. Otherwise you may have trouble getting clean comparisons
  359. between stages.
  360.  
  361. @item mips-mips-bsd
  362. MIPS machines running the MIPS operating system in BSD mode.  It's
  363. possible that some old versions of the system lack the functions
  364. @code{memcpy}, @code{memcmp}, and @code{memset}.  If your system lacks
  365. these, you must remove or undo the definition of
  366. @code{TARGET_MEM_FUNCTIONS} in @file{mips-bsd.h}.
  367.  
  368. @item mips-sgi-*
  369. Silicon Graphics MIPS machines running IRIX.  In order to compile
  370. GCC on an SGI the "c.hdr.lib" option must be installed from the
  371. CD-ROM supplied from Silicon Graphics.  This is found on the 2nd
  372. CD in release 4.0.1.
  373.  
  374. @item mips-sony-sysv
  375. Sony MIPS NEWS.  This works in NEWSOS 5.0.1, but not in 5.0.2 (which
  376. uses ELF instead of COFF).  Support for 5.0.2 will probably be provided
  377. soon by volunteers.  In particular, the linker does not like the
  378. code generated by GCC when shared libraries are linked in.
  379.  
  380. @item ns32k-encore
  381. Encore ns32000 system.  Encore systems are supported only under BSD.
  382.  
  383. @item ns32k-*-genix
  384. National Semiconductor ns32000 system.  Genix has bugs in @code{alloca}
  385. and @code{malloc}; you must get the compiled versions of these from GNU
  386. Emacs.
  387.  
  388. @item ns32k-sequent
  389. Go to the Berkeley universe before compiling.  In addition, you probably
  390. need to create a file named @file{string.h} containing just one line:
  391. @samp{#include <strings.h>}.
  392.  
  393. @item ns32k-utek
  394. UTEK ns32000 system (``merlin'').  The C compiler that comes with this
  395. system cannot compile GNU CC; contact @samp{tektronix!reed!mason} to get
  396. binaries of GNU CC for bootstrapping.
  397.  
  398. @item romp-*-aos
  399. @itemx romp-*-mach
  400. The only operating systems supported for the IBM RT PC are AOS and
  401. MACH.  GNU CC does not support AIX running on the RT.  We recommend you
  402. compile GNU CC with an earlier version of itself; if you compile GNU CC
  403. with @code{hc}, the Metaware compiler, it will work, but you will get
  404. mismatches between the stage 2 and stage 3 compilers in various files.
  405. These errors are minor differences in some floating-point constants and
  406. can be safely ignored; the stage 3 compiler is correct.
  407.  
  408. @item rs6000-*-aix
  409. @strong{Read the file @file{README.RS6000} for information on how to get
  410. a fix for problems in the IBM assembler that interfere with GNU CC.} You
  411. must either obtain the new assembler or avoid using the @samp{-g}
  412. switch.  Note that @file{Makefile.in} uses @samp{-g} by default when
  413. compiling @file{libgcc2.c}.
  414.  
  415. @item vax-dec-ultrix
  416. Don't try compiling with Vax C (@code{vcc}).  It produces incorrect code
  417. in some cases (for example, when @code{alloca} is used).
  418.  
  419. Meanwhile, compiling @file{cp-parse.c} with pcc does not work because of
  420. an internal table size limitation in that compiler.  To avoid this
  421. problem, compile just the GNU C compiler first, and use it to recompile 
  422. building all the languages that you want to run.
  423. @end table
  424.  
  425. Here we spell out what files will be set up by @code{configure}.  Normally
  426. you need not be concerned with these files.
  427.  
  428. @itemize @bullet
  429. @item
  430. @ifset INTERNALS
  431. A symbolic link named @file{config.h} is made to the top-level config
  432. file for the machine you will run the compiler on (@pxref{Config}).
  433. This file is responsible for defining information about the host
  434. machine.  It includes @file{tm.h}.
  435. @end ifset
  436. @ifclear INTERNALS
  437. A symbolic link named @file{config.h} is made to the top-level config
  438. file for the machine you plan to run the compiler on (@pxref{Config,,The
  439. Configuration File, gcc.info, Using and Porting GCC}).  This file is
  440. responsible for defining information about the host machine.  It
  441. includes @file{tm.h}.
  442. @end ifclear
  443.  
  444. The top-level config file is located in the subdirectory @file{config}.
  445. Its name is always @file{xm-@var{something}.h}; usually
  446. @file{xm-@var{machine}.h}, but there are some exceptions.
  447.  
  448. If your system does not support symbolic links, you might want to
  449. set up @file{config.h} to contain a @samp{#include} command which
  450. refers to the appropriate file.
  451.  
  452. @item
  453. A symbolic link named @file{tconfig.h} is made to the top-level config
  454. file for your target machine.  This is used for compiling certain
  455. programs to run on that machine.
  456.  
  457. @item
  458. A symbolic link named @file{tm.h} is made to the machine-description
  459. macro file for your target machine.  It should be in the subdirectory
  460. @file{config} and its name is often @file{@var{machine}.h}.
  461.  
  462. @item
  463. A symbolic link named @file{md} will be made to the machine description
  464. pattern file.  It should be in the @file{config} subdirectory and its
  465. name should be @file{@var{machine}.md}; but @var{machine} is often not
  466. the same as the name used in the @file{tm.h} file because the
  467. @file{md} files are more general.
  468.  
  469. @item
  470. A symbolic link named @file{aux-output.c} will be made to the output
  471. subroutine file for your machine.  It should be in the @file{config}
  472. subdirectory and its name should be @file{@var{machine}.c}.
  473.  
  474. @item
  475. The command file @file{configure} also constructs the file
  476. @file{Makefile} by adding some text to the template file
  477. @file{Makefile.in}.  The additional text comes from files in the
  478. @file{config} directory, named @file{t-@var{target}} and
  479. @file{x-@var{host}}.  If these files do not exist, it means nothing
  480. needs to be added for a given target or host.
  481. @c does the above work now?  --mew
  482. @end itemize
  483.  
  484. @item
  485. The standard directory for installing the compiler's passes and run-time
  486. support in @file{/usr/local/lib}.  If you want to install it somewhere
  487. else, specify the option @samp{--prefix=@var{dir}} when you run
  488. @file{configure}.  @var{dir} is a directory name to use instead of
  489. @file{/usr/local} for all purposes with one exception: the directory
  490. @file{/usr/local/include} is searched for header files no matter where
  491. you install the compiler.
  492.  
  493. @item
  494. Specify @samp{--local-prefix=@var{dir}} if you want the compiler to
  495. search directory @file{@var{dir}/include} for header files
  496. @emph{instead} of @file{/usr/local/include}.  (This is for systems that
  497. have different conventions for where to put site-specific things.)
  498.  
  499. @cindex Bison parser generator
  500. @cindex parser generator, Bison
  501. @item
  502. Make sure the Bison parser generator is installed.  (This is
  503. unnecessary if the Bison output files @file{c-parse.c} and
  504. @file{cexp.c} are more recent than @file{c-parse.y} and @file{cexp.y}
  505. and you do not plan to change the @samp{.y} files.)
  506.  
  507. Bison versions older than Sept 8, 1988 will produce incorrect output
  508. for @file{c-parse.c}.
  509.  
  510. @item
  511. Build the compiler.  Just type @samp{make LANGUAGES=c} in the compiler
  512. directory.
  513.  
  514. @samp{LANGUAGES=c} specifies that only the C compiler should be
  515. compiled.  The makefile normally builds compilers for all the supported
  516. languages; currently, C, C++ and Objective C.  However, C is the only
  517. language that is sure to work when you build with other non-GNU C
  518. compilers.  In addition, building anything but C at this stage is a
  519. waste of time.
  520.  
  521. In general, you can specify the languages to build by typing the
  522. argument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or more
  523. words from the list @samp{c}, @samp{c++}, and @samp{objective-c}.
  524.  
  525. Ignore any warnings you may see about ``statement not reached'' in
  526. @file{insn-emit.c}; they are normal.  Also, warnings about ``unknown
  527. escape sequence'' are normal in @file{genopinit.c} and perhaps some
  528. other files.  Any other compilation errors may represent bugs in the
  529. port to your machine or operating system, and
  530. @ifclear INSTALLONLY
  531. should be investigated and reported (@pxref{Bugs}).
  532. @end ifclear
  533. @ifset INSTALLONLY
  534. should be investigated and reported.
  535. @end ifset
  536.  
  537. Some commercial compilers fail to compile GNU CC because they have bugs
  538. or limitations.  For example, the Microsoft compiler is said to run out
  539. of macro space.  Some Ultrix compilers run out of expression space; then
  540. you need to break up the statement where the problem happens.
  541.  
  542. If you are building with a previous GNU C compiler, do not
  543. use @samp{CC=gcc} on the make command or by editing the Makefile.
  544. Instead, use a full pathname to specify the compiler, such as
  545. @samp{CC=/usr/local/bin/gcc}.  This is because make might execute
  546. the @file{gcc} in the current directory before all of the
  547. compiler components have been built.
  548.  
  549. @item
  550. If you are building a cross-compiler, stop here.  @xref{Cross-Compiler}.
  551.  
  552. @cindex stage1
  553. @item
  554. Move the first-stage object files and executables into a subdirectory
  555. with this command:
  556.  
  557. @smallexample
  558. make stage1
  559. @end smallexample
  560.  
  561. The files are moved into a subdirectory named @file{stage1}.
  562. Once installation is complete, you may wish to delete these files
  563. with @code{rm -r stage1}.
  564.  
  565. @item
  566. If you have chosen a configuration for GNU CC which requires other GNU
  567. tools (such as GAS or the GNU linker) instead of the standard system
  568. tools, install the required tools in the @file{stage1} subdirectory
  569. under the names @file{as}, @file{ld} or whatever is appropriate.  This
  570. will enable the stage 1 compiler to find the proper tools in the
  571. following stage.
  572.  
  573. Alternatively, you can do subsequent compilation using a value of the
  574. @code{PATH} environment variable such that the necessary GNU tools come
  575. before the standard system tools.
  576.  
  577. @item
  578. Recompile the compiler with itself, with this command:
  579.  
  580. @smallexample
  581. make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O"
  582. @end smallexample
  583.  
  584. This is called making the stage 2 compiler.
  585.  
  586. The command shown above builds compilers for all the supported
  587. languages.  If you don't want them all, you can specify the languages to
  588. build by typing the argument @samp{LANGUAGES="@var{list}"}.  @var{list}
  589. should contain one or more words from the list @samp{c}, @samp{c++},
  590. @samp{objective-c}, and @samp{proto}.  Separate the words with spaces.
  591. @samp{proto} stands for the programs @code{protoize} and
  592. @code{unprotoize}; they are not a separate language, but you use
  593. @code{LANGUAGES} to enable or disable their installation.
  594.  
  595. If you are going to build the stage 3 compiler, then you might want to
  596. build only the C language in stage 2.
  597.  
  598. Once you have built the stage 2 compiler, if you are short of disk
  599. space, you can delete the subdirectory @file{stage1}.
  600.  
  601. On a 68000 or 68020 system lacking floating point hardware,
  602. unless you have selected a @file{tm.h} file that expects by default
  603. that there is no such hardware, do this instead:
  604.  
  605. @smallexample
  606. make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O -msoft-float"
  607. @end smallexample
  608.  
  609. @item
  610. If you wish to test the compiler by compiling it with itself one more
  611. time, install any other necessary GNU tools (such as GAS or the GNU
  612. linker) in the @file{stage2} subdirectory as you did in the
  613. @file{stage1} subdirectory, then do this:
  614.  
  615. @smallexample
  616. make stage2
  617. make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" 
  618. @end smallexample
  619.  
  620. @noindent
  621. This is called making the stage 3 compiler.  Aside from the @samp{-B}
  622. option, the compiler options should be the same as when you made the
  623. stage 2 compiler.  But the @code{LANGUAGES} option need not be the
  624. same.  The command shown above builds compilers for all the supported
  625. languages; if you don't want them all, you can specify the languages to
  626. build by typing the argument @samp{LANGUAGES="@var{list}"}, as described
  627. above.
  628.  
  629. Then compare the latest object files with the stage 2 object
  630. files---they ought to be identical, unless they contain time stamps.
  631. You can compare the files, disregarding the time stamps if any, like
  632. this:
  633.  
  634. @smallexample
  635. make compare
  636. @end smallexample
  637.  
  638. This will mention any object files that differ between stage 2 and stage
  639. 3.  Any difference, no matter how innocuous, indicates that the stage 2
  640. compiler has compiled GNU CC incorrectly, and is therefore a potentially
  641. @ifclear INSTALLONLY
  642. serious bug which you should investigate and report (@pxref{Bugs}).
  643. @end ifclear
  644. @ifset INSTALLONLY
  645. serious bug which you should investigate and report.
  646. @end ifset
  647.  
  648. If your system does not put time stamps in the object files, then this
  649. is a faster way to compare them (using the Bourne shell):
  650.  
  651. @smallexample
  652. for file in *.o; do
  653. cmp $file stage2/$file
  654. done
  655. @end smallexample
  656.  
  657. If you have built the compiler with the @samp{-mno-mips-tfile} option on
  658. MIPS machines, you will not be able to compare the files.  The Alpha
  659. uses timestamps that @samp{make compare} does not know how to ignore,
  660. so you will not be able to compare on the Alpha.
  661.  
  662. @item
  663. Install the compiler driver, the compiler's passes and run-time support
  664. with @samp{make install}.  Use the same value for @code{CC},
  665. @code{CFLAGS} and @code{LANGUAGES} that you used when compiling the
  666. files that are being installed.  One reason this is necessary is that
  667. some versions of Make have bugs and recompile files gratuitously when
  668. you do this step.  If you use the same variable values, those files will
  669. be recompiled properly.
  670.  
  671. For example, if you have built the stage 2 compiler, you can use the
  672. following command:
  673.  
  674. @smallexample
  675. make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES="@var{list}"
  676. @end smallexample
  677.  
  678. @noindent
  679. This copies the files @file{cc1}, @file{cpp} and @file{libgcc.a} to
  680. files @file{cc1}, @file{cpp} and @file{libgcc.a} in the directory
  681. @file{/usr/local/lib/gcc-lib/@var{target}/@var{version}}, which is where
  682. the compiler driver program looks for them.  Here @var{target} is the
  683. target machine type specified when you ran @file{configure}, and
  684. @var{version} is the version number of GNU CC.  This naming scheme
  685. permits various versions and/or cross-compilers to coexist.
  686.  
  687. @c if the following doesn't work, i don't know what will; i've tried a
  688. @c few ideas already.  --mew
  689. This program will also copy the driver program @file{gcc} into the
  690. directory @file{/usr/local/bin}, so that it appears in typical execution
  691. search paths.@refill
  692.  
  693. On some systems, this command will cause recompilation of some files.
  694. This is usually due to bugs in @code{make}.  You should either ignore
  695. this problem, or use GNU Make.
  696.  
  697. @cindex @code{alloca} and SunOs
  698. @strong{Warning: there is a bug in @code{alloca} in the Sun library.  To
  699. avoid this bug, be sure to install the executables of GNU CC that were
  700. compiled by GNU CC.  (That is, the executables from stage 2 or 3, not
  701. stage 1.)  They use @code{alloca} as a built-in function and never the
  702. one in the library.}
  703.  
  704. (It is usually better to install GNU CC executables from stage 2 or 3,
  705. since they usually run faster than the ones compiled with some other
  706. compiler.)
  707.  
  708. @item
  709. Install the Objective C library (if you have built the Objective C
  710. compiler).  Here is the command to do this:
  711.  
  712. @smallexample
  713. make install-libobjc CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O"
  714. @end smallexample
  715.  
  716. @item
  717. If you're going to use C++, it's likely that you need to also install
  718. the libg++ distribution.  It should be available from the same
  719. place where you got the GNU C distribution.  Just as GNU C does not
  720. distribute a C runtime library, it also does not include a C++ run-time
  721. library.  All I/O functionality, special class libraries, etc., are
  722. available in the libg++ distribution.
  723. @end enumerate
  724.  
  725. @node Other Dir
  726. @section Compilation in a Separate Directory
  727. @cindex other directory, compilation in
  728. @cindex compilation in a separate directory
  729. @cindex separate directory, compilation in
  730.  
  731. If you wish to build the object files and executables in a directory
  732. other than the one containing the source files, here is what you must
  733. do differently:
  734.  
  735. @enumerate
  736. @item
  737. Make sure you have a version of Make that supports the @code{VPATH}
  738. feature.  (GNU Make supports it, as do Make versions on most BSD
  739. systems.)
  740.  
  741. @item
  742. If you have ever run @file{configure} in the source directory, you must undo
  743. the configuration.  Do this by running:
  744.  
  745. @example
  746. make distclean
  747. @end example
  748.  
  749. @item
  750. Go to the directory in which you want to build the compiler before
  751. running @file{configure}:
  752.  
  753. @example
  754. mkdir gcc-sun3
  755. cd gcc-sun3
  756. @end example
  757.  
  758. On systems that do not support symbolic links, this directory must be
  759. on the same file system as the source code directory.
  760.  
  761. @item
  762. Specify where to find @file{configure} when you run it:
  763.  
  764. @example
  765. ../gcc/configure @dots{}
  766. @end example
  767.  
  768. This also tells @code{configure} where to find the compiler sources;
  769. @code{configure} takes the directory from the file name that was used to
  770. invoke it.  But if you want to be sure, you can specify the source
  771. directory with the @samp{--srcdir} option, like this:
  772.  
  773. @example
  774. ../gcc/configure --srcdir=../gcc sun3
  775. @end example
  776.  
  777. The directory you specify with @samp{--srcdir} need not be the same
  778. as the one that @code{configure} is found in.
  779. @end enumerate
  780.  
  781. Now, you can run @code{make} in that directory.  You need not repeat the
  782. configuration steps shown above, when ordinary source files change.  You
  783. must, however, run @code{configure} again when the configuration files
  784. change, if your system does not support symbolic links.
  785.  
  786. @node Cross-Compiler
  787. @section Building and Installing a Cross-Compiler
  788. @cindex cross-compiler, installation
  789.  
  790. GNU CC can function as a cross-compiler for many machines, but not all.
  791.  
  792. @itemize @bullet
  793. @item
  794. Cross-compilers for the Mips as target do not work because the auxiliary
  795. programs @file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled
  796. on anything but a Mips.
  797.  
  798. @item
  799. Cross-compilers to or from the Vax probably don't work completely
  800. because the Vax uses an incompatible floating point format (not IEEE
  801. format).
  802. @end itemize
  803.  
  804. Since GNU CC generates assembler code, you probably need a
  805. cross-assembler that GNU CC can run, in order to produce object files.
  806. If you want to link on other than the target machine, you need a
  807. cross-linker as well.  You also need header files and libraries suitable
  808. for the target machine that you can install on the host machine.
  809.  
  810. To build GNU CC as a cross-compiler, you start out by running
  811. @code{configure}.  You must specify two different configurations, the
  812. host and the target.  Use the @samp{--host=@var{host}} option for the
  813. host and @samp{--target=@var{target}} to specify the target type.  For
  814. example, here is how to configure for a cross-compiler that runs on a
  815. hypothetical Intel 386 system and produces code for an HP 68030 system
  816. running BSD:
  817.  
  818. @smallexample
  819. configure --target=m68k-hp-bsd4.3 --host=i386-bozotheclone-bsd4.3
  820. @end smallexample
  821.  
  822. Next you should install the cross-assembler and cross-linker (and
  823. @code{ar} and @code{ranlib}).  Put them in the directory
  824. @file{/usr/local/@var{target}/bin}.  The installation of GNU CC will find
  825. them there and copy or link them to the proper place to find them when
  826. you run the cross-compiler later.
  827.  
  828. If you want to install any additional libraries to use with the
  829. cross-compiler, put them in the directory
  830. @file{/usr/local/@var{target}/lib}; all files in that subdirectory will
  831. be installed in the proper place when you install the cross-compiler.
  832. Likewise, put the header files for the target machine in
  833. @file{/usr/local/@var{target}/include}.
  834.  
  835. You must now produce a substitute for @file{libgcc1.a}.  Normally this
  836. file is compiled with the ``native compiler'' for the target machine;
  837. compiling it with GNU CC does not work.  But compiling it with the host
  838. machine's compiler also doesn't work---that produces a file that would
  839. run on the host, and you need it to run on the target.
  840.  
  841. We can't give you any automatic way to produce this substitute.  For
  842. some targets, the subroutines in @file{libgcc1.c} are not actually used.
  843. You need not provide the ones that won't be used.  The ones that most
  844. commonly are used are the multiplication, division and remainder
  845. routines---many RISC machines rely on the library for this.  One way to
  846. make them work is to define the appropriate @code{perform_@dots{}}
  847. macros for the subroutines that you need.  If these definitions do not
  848. use the C arithmetic operators that they are meant to implement, you
  849. might be able to compile them with the cross-compiler you are building.
  850. To do this, specify @samp{LIBGCC1=libgcc1.a OLDCC=./xgcc} when building
  851. the compiler.
  852.  
  853. Now you can proceed just as for compiling a single-machine compiler
  854. through the step of building stage 1.  If you have not provided some
  855. sort of @file{libgcc1.a}, then compilation will give up at the point
  856. where it needs that file, printing a suitable error message.  If you
  857. do provide @file{libgcc1.a}, then building the compiler will automatically
  858. compile and link a test program called @file{cross-test}; if you get
  859. errors in the linking, it means that not all of the necessary routines
  860. in @file{libgcc1.a} are available.
  861.  
  862. When you are using a cross-compiler configuration, building stage 1
  863. does not compile all of GNU CC.  This is because one part of building,
  864. the compilation of @file{libgcc2.c}, requires use of the cross-compiler.
  865.  
  866. However, when you type @samp{make install} to install the bulk of the
  867. cross-compiler, that will also compile @file{libgcc2.c} and install the
  868. resulting @file{libgcc.a}.
  869.  
  870. Do not try to build stage 2 for a cross-compiler.  It doesn't work to
  871. rebuild GNU CC as a cross-compiler using the cross-compiler, because
  872. that would produce a program that runs on the target machine, not on the
  873. host.  For example, if you compile a 386-to-68030 cross-compiler with
  874. itself, the result will not be right either for the 386 (because it was
  875. compiled into 68030 code) or for the 68030 (because it was configured
  876. for a 386 as the host).  If you want to compile GNU CC into 68030 code,
  877. whether you compile it on a 68030 or with a cross-compiler on a 386, you
  878. must specify a 68030 as the host when you configure it.
  879.  
  880. @c this makes an underfull hbox; any ideas?  --mew 27jan93
  881. @c Now fixed --bob 5feb93
  882. @c Old text, page 83, was:
  883. @c Installing GNU CC on the HP Precision Architecture
  884. @node PA Install
  885. @section GNU CC on the HP Precision Architecture
  886.  
  887. There are two variants of this CPU, called 1.0 and 1.1, which have
  888. different machine descriptions.  You must use the right one for your
  889. machine.  All 7@var{nn} machines and 8@var{n}7 machines use 1.1, while
  890. all other 8@var{nn} machines use 1.0.
  891.  
  892. The easiest way to handle this problem is to use @samp{configure
  893. hp@var{nnn}} or @samp{configure hp@var{nnn}-hpux}, where @var{nnn} is
  894. the model number of the machine.  Then @file{configure} will figure out
  895. if the machine is a 1.0 or 1.1.  Use @samp{uname -a} to find out the
  896. model number of your machine.
  897.  
  898. @samp{-g} does not work on HP-UX, since that system uses a peculiar
  899. debugging format which GNU CC does not know about.  There are preliminary
  900. versions of GAS and GDB for the HP-PA which do work with GNU CC for 
  901. debugging.  You can get them by anonymous ftp from @code{jaguar.cs.utah.edu}
  902. @samp{dist} subdirectory.  You would need to install GAS in the file
  903.  
  904. @example
  905. /usr/local/lib/gcc-lib/@var{configuration}/@var{gccversion}/as
  906. @end example
  907.  
  908. @noindent
  909. where @var{configuration} is the configuration name (perhaps
  910. @samp{hp@var{nnn}-hpux}) and @var{gccversion} is the GNU CC version
  911. number.  Do this @emph{before} starting the build process, otherwise you will
  912. get errors from the HPUX assembler while building @file{libgcc2.a}.  The
  913. command 
  914.  
  915. @example
  916. make install-dir
  917. @end example
  918.  
  919. @noindent
  920. will create the necessary directory hierarchy so you can install GAS before
  921. building GCC.
  922.  
  923. If you obtained GAS before October 6, 1992 it is highly recommended you
  924. get a new one to avoid several bugs which have been discovered
  925. recently.
  926.  
  927. To enable debugging, configure GNU CC with the @samp{--gas} option before
  928. building.
  929.  
  930. It has been reported that GNU CC produces invalid assembly code for
  931. 1.1 machines running HP-UX 8.02 when using the HP assembler.  Typically
  932. the errors look like this:
  933. @example
  934. as: bug.s @@line#15 [err#1060]
  935.   Argument 0 or 2 in FARG upper
  936.          - lookahead = ARGW1=FR,RTNVAL=GR
  937. as: foo.s @@line#28 [err#1060]
  938.   Argument 0 or 2 in FARG upper
  939.          - lookahead = ARGW1=FR
  940. @end example
  941.  
  942. You can check the version of HP-UX you are running by executing the command
  943. @samp{uname -r}.   If you are indeed running HP-UX 8.02 on a 1.1 machine and 
  944. using the HP assembler then configure GCC with "hp700-hpux8.02".
  945.  
  946. @node Sun Install
  947. @section Installing GNU CC on the Sun
  948. @cindex Sun installation
  949. @cindex installing GNU CC on the Sun
  950.  
  951. Make sure the environment variable @code{FLOAT_OPTION} is not set when
  952. you compile @file{libgcc.a}.  If this option were set to @code{f68881}
  953. when @file{libgcc.a} is compiled, the resulting code would demand to be
  954. linked with a special startup file and would not link properly without
  955. special pains.
  956.  
  957. @cindex @code{alloca}, for SunOs
  958. There is a bug in @code{alloca} in certain versions of the Sun library.
  959. To avoid this bug, install the binaries of GNU CC that were compiled by
  960. GNU CC.  They use @code{alloca} as a built-in function and never the one
  961. in the library.
  962.  
  963. Some versions of the Sun compiler crash when compiling GNU CC.  The
  964. problem is a segmentation fault in cpp.  This problem seems to be due to
  965. the bulk of data in the environment variables.  You may be able to avoid
  966. it by using the following command to compile GNU CC with Sun CC:
  967.  
  968. @example
  969. make CC="TERMCAP=x OBJS=x LIBFUNCS=x STAGESTUFF=x cc"
  970. @end example
  971.  
  972. @node 3b1 Install
  973. @section Installing GNU CC on the 3b1
  974. @cindex 3b1 installation
  975. @cindex installing GNU CC on the 3b1
  976.  
  977. Installing GNU CC on the 3b1 is difficult if you do not already have
  978. GNU CC running, due to bugs in the installed C compiler.  However,
  979. the following procedure might work.  We are unable to test it.
  980.  
  981. @enumerate
  982. @item
  983. Comment out the @samp{#include "config.h"} line on line 37 of
  984. @file{cccp.c} and do @samp{make cpp}.  This makes a preliminary version
  985. of GNU cpp.
  986.  
  987. @item
  988. Save the old @file{/lib/cpp} and copy the preliminary GNU cpp to that
  989. file name.
  990.  
  991. @item
  992. Undo your change in @file{cccp.c}, or reinstall the original version,
  993. and do @samp{make cpp} again.
  994.  
  995. @item
  996. Copy this final version of GNU cpp into @file{/lib/cpp}.
  997.  
  998. @findex obstack_free
  999. @item
  1000. Replace every occurrence of @code{obstack_free} in the file
  1001. @file{tree.c} with @code{_obstack_free}.
  1002.  
  1003. @item
  1004. Run @code{make} to get the first-stage GNU CC.
  1005.  
  1006. @item
  1007. Reinstall the original version of @file{/lib/cpp}.
  1008.  
  1009. @item
  1010. Now you can compile GNU CC with itself and install it in the normal
  1011. fashion.
  1012. @end enumerate
  1013.  
  1014. @node Unos Install
  1015. @section Installing GNU CC on Unos
  1016. @cindex Unos installation
  1017. @cindex installing GNU CC on Unos
  1018.  
  1019. Use @samp{configure unos} for building on Unos.
  1020.  
  1021. The Unos assembler is named @code{casm} instead of @code{as}.  For some
  1022. strange reason linking @file{/bin/as} to @file{/bin/casm} changes the
  1023. behavior, and does not work.  So, when installing GNU CC, you should
  1024. install the following script as @file{as} in the subdirectory where
  1025. the passes of GCC are installed:
  1026.  
  1027. @example
  1028. #!/bin/sh
  1029. casm $*
  1030. @end example
  1031.  
  1032. The default Unos library is named @file{libunos.a} instead of
  1033. @file{libc.a}.  To allow GNU CC to function, either change all
  1034. references to @samp{-lc} in @file{gcc.c} to @samp{-lunos} or link
  1035. @file{/lib/libc.a} to @file{/lib/libunos.a}.
  1036.  
  1037. @cindex @code{alloca}, for Unos
  1038. When compiling GNU CC with the standard compiler, to overcome bugs in
  1039. the support of @code{alloca}, do not use @samp{-O} when making stage 2.
  1040. Then use the stage 2 compiler with @samp{-O} to make the stage 3
  1041. compiler.  This compiler will have the same characteristics as the usual
  1042. stage 2 compiler on other systems.  Use it to make a stage 4 compiler
  1043. and compare that with stage 3 to verify proper compilation.
  1044.  
  1045. (Perhaps simply defining @code{ALLOCA} in @file{x-crds} as described in
  1046. the comments there will make the above paragraph superfluous.  Please
  1047. inform us of whether this works.)
  1048.  
  1049. Unos uses memory segmentation instead of demand paging, so you will need
  1050. a lot of memory.  5 Mb is barely enough if no other tasks are running.
  1051. If linking @file{cc1} fails, try putting the object files into a library
  1052. and linking from that library.
  1053.  
  1054. @node VMS Install
  1055. @section Installing GNU CC on VMS
  1056. @cindex VMS installation
  1057. @cindex installing GNU CC on VMS
  1058.  
  1059. The VMS version of GNU CC is distributed in a backup saveset containing
  1060. both source code and precompiled binaries.
  1061.  
  1062. To install the @file{gcc} command so you can use the compiler easily, in
  1063. the same manner as you use the VMS C compiler, you must install the VMS CLD
  1064. file for GNU CC as follows:
  1065.  
  1066. @enumerate
  1067. @item
  1068. Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
  1069. to point to the directories where the GNU CC executables
  1070. (@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are
  1071. kept respectively.  This should be done with the commands:@refill
  1072.  
  1073. @smallexample
  1074. $ assign /system /translation=concealed -
  1075.   disk:[gcc.] gnu_cc
  1076. $ assign /system /translation=concealed -
  1077.   disk:[gcc.include.] gnu_cc_include
  1078. @end smallexample
  1079.  
  1080. @noindent
  1081. with the appropriate disk and directory names.  These commands can be
  1082. placed in your system startup file so they will be executed whenever
  1083. the machine is rebooted.  You may, if you choose, do this via the
  1084. @file{GCC_INSTALL.COM} script in the @file{[GCC]} directory.
  1085.  
  1086. @item
  1087. Install the @file{GCC} command with the command line:
  1088.  
  1089. @smallexample
  1090. $ set command /table=sys$common:[syslib]dcltables -
  1091.   /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
  1092. $ install replace sys$common:[syslib]dcltables
  1093. @end smallexample
  1094.  
  1095. @item
  1096. To install the help file, do the following:
  1097.  
  1098. @smallexample
  1099. $ library/help sys$library:helplib.hlb gcc.hlp
  1100. @end smallexample
  1101.  
  1102. @noindent
  1103. Now you can invoke the compiler with a command like @samp{gcc /verbose
  1104. file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
  1105. Unix.
  1106. @end enumerate
  1107.  
  1108. If you wish to use GNU C++ you must first install GNU CC, and then
  1109. perform the following steps:
  1110.  
  1111. @enumerate
  1112. @item
  1113. Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the
  1114. directory where the preprocessor will search for the C++ header files.
  1115. This can be done with the command:@refill
  1116.  
  1117. @smallexample
  1118. $ assign /system /translation=concealed -
  1119.   disk:[gcc.gxx_include.] gnu_gxx_include
  1120. @end smallexample
  1121.  
  1122. @noindent
  1123. with the appropriate disk and directory name.  If you are going to be
  1124. using libg++, this is where the libg++ install procedure will install
  1125. the libg++ header files.
  1126.  
  1127. @item
  1128. Obtain the file @file{gcc-cc1plus.exe}, and place this in the same
  1129. directory that @file{gcc-cc1.exe} is kept.
  1130.  
  1131. The GNU C++ compiler can be invoked with a command like @samp{gcc /plus
  1132. /verbose file.cc}, which is equivalent to the command @samp{g++ -v -c
  1133. file.cc} in Unix.
  1134. @end enumerate
  1135.  
  1136. We try to put corresponding binaries and sources on the VMS distribution
  1137. tape.  But sometimes the binaries will be from an older version than the
  1138. sources, because we don't always have time to update them.  (Use the
  1139. @samp{/version} option to determine the version number of the binaries and
  1140. compare it with the source file @file{version.c} to tell whether this is
  1141. so.)  In this case, you should use the binaries you get to recompile the
  1142. sources.  If you must recompile, here is how:
  1143.  
  1144. @enumerate
  1145. @item
  1146. Execute the command procedure @file{vmsconfig.com} to copy files
  1147. @file{vax-vms.h}, @file{xm-vax-vms.h}, @file{vax.c} and @file{vax.md} to
  1148. files @file{tm.h}, @file{config.h}, @file{aux-output.c}, and @file{md.}
  1149. respectively, and to create files @file{tconfig.h} and @file{hconfig.h}.
  1150. This procedure also creates several linker option files used by
  1151. @file{make-cc1.com} and a data file used by @file{make-l2.com}.@refill
  1152.  
  1153. @smallexample
  1154. $ @@vmsconfig.com
  1155. @end smallexample
  1156.  
  1157. @item
  1158. Setup the logical names and command tables as defined above.  In
  1159. addition, define the VMS logical name @samp{GNU_BISON} to point at the
  1160. to the directories where the Bison executable is kept.  This should be
  1161. done with the command:@refill
  1162.  
  1163. @smallexample
  1164. $ assign /system /translation=concealed -
  1165.   disk:[bison.] gnu_bison
  1166. @end smallexample
  1167.  
  1168. You may, if you choose, use the @file{INSTALL_BISON.COM} script in the
  1169. @file{[BISON]} directory.
  1170.  
  1171. @item
  1172. Install the @samp{BISON} command with the command line:@refill
  1173.  
  1174. @smallexample
  1175. $ set command /table=sys$common:[syslib]dcltables -
  1176.   /output=sys$common:[syslib]dcltables -
  1177.   gnu_bison:[000000]bison
  1178. $ install replace sys$common:[syslib]dcltables
  1179. @end smallexample
  1180.  
  1181. @item
  1182. Type @samp{@@make-gcc} to recompile everything (alternatively, you may
  1183. submit the file @file{make-gcc.com} to a batch queue).  If you wish to
  1184. build the GNU C++ compiler as well as the GNU CC compiler, you must
  1185. first edit @file{make-gcc.com} and follow the instructions that appear
  1186. in the comments.@refill
  1187.  
  1188. @item
  1189. In order to use GCC, you need a library of functions which GCC compiled code
  1190. will call to perform certain tasks, and these functions are defined in the
  1191. file @file{libgcc2.c}.  To compile this you should use the command procedure
  1192. @file{make-l2.com}, which will generate the library @file{libgcc2.olb}.
  1193. @file{libgcc2.olb} should be built using the compiler built from
  1194. the same distribution that @file{libgcc2.c} came from, and
  1195. @file{make-gcc.com} will automatically do all of this for you.
  1196.  
  1197. To install the library, use the following commands:@refill
  1198.  
  1199. @smallexample
  1200. $ library gnu_cc:[000000]gcclib/delete=(new,eprintf)
  1201. $ library gnu_cc:[000000]gcclib/delete=L_*
  1202. $ library libgcc2/extract=*/output=libgcc2.obj
  1203. $ library gnu_cc:[000000]gcclib libgcc2.obj
  1204. @end smallexample
  1205.  
  1206. The first command simply removes old modules that will be replaced with
  1207. modules from @file{libgcc2} under different module names.  The modules
  1208. @code{new} and @code{eprintf} may not actually be present in your
  1209. @file{gcclib.olb}---if the VMS librarian complains about those modules
  1210. not being present, simply ignore the message and continue on with the
  1211. next command.  The second command removes the modules that came from the
  1212. previous version of the library @file{libgcc2.c}.
  1213.  
  1214. Whenever you update the compiler on your system, you should also update the
  1215. library with the above procedure.
  1216.  
  1217. @item
  1218. You may wish to build GCC in such a way that no files are written to the
  1219. directory where the source files reside.  An example would be the when
  1220. the source files are on a read-only disk.  In these cases, execute the
  1221. following DCL commands (substituting your actual path names):
  1222.  
  1223. @smallexample
  1224. $ assign dua0:[gcc.build_dir.]/translation=concealed, -
  1225.          dua1:[gcc.source_dir.]/translation=concealed  gcc_build
  1226. $ set default gcc_build:[000000]
  1227. @end smallexample
  1228.  
  1229. where @file{dua1:[gcc.source_dir]}
  1230. contains the source code, and
  1231. @file{dua0:[gcc.build_dir]} is meant to contain all of the generated object
  1232. files and executables.  Once you have done this, you can proceed building GCC
  1233. as described above.  (Keep in mind that @file{gcc_build} is a rooted logical
  1234. name, and thus the device names in each element of the search list must be an
  1235. actual physical device name rather than another rooted logical name).
  1236.  
  1237. @item
  1238. @strong{If you are building GNU CC with a previous version of GNU CC,
  1239. you also should check to see that you have the newest version of the
  1240. assembler}.  In particular, GNU CC version 2 treats global constant
  1241. variables slightly differently from GNU CC version 1, and GAS version
  1242. 1.38.1 does not have the patches required to work with GCC version 2.
  1243. If you use GAS 1.38.1, then @code{extern const} variables will not have
  1244. the read-only bit set, and the linker will generate warning messages
  1245. about mismatched psect attributes for these variables.  These warning
  1246. messages are merely a nuisance, and can safely be ignored.
  1247.  
  1248. If you are compiling with a version of GNU CC older than 1.33, specify
  1249. @samp{/DEFINE=("inline=")} as an option in all the compilations.  This
  1250. requires editing all the @code{gcc} commands in @file{make-cc1.com}.
  1251. (The older versions had problems supporting @code{inline}.)  Once you
  1252. have a working 1.33 or newer GNU CC, you can change this file back.
  1253.  
  1254. @item
  1255. If you want to build GNU CC with the VAX C compiler, you will need to
  1256. make minor changes in @file{make-cccp.com} and @file{make-cc1.com}
  1257. to choose alternate definitions of @code{CC}, @code{CFLAGS}, and
  1258. @code{LIBS}.  See comments in those files.  However, you must
  1259. also have a working version of the GNU assembler (GNU as, aka GAS) as
  1260. it is used as the back-end for GNU CC to produce binary object modules
  1261. and is not included in the GNU CC sources.  GAS is also needed to
  1262. compile @file{libgcc2} in order to build @file{gcclib} (see above);
  1263. @file{make-l2.com} expects to be able to find it operational in
  1264. @file{gnu_cc:[000000]gnu-as.exe}.
  1265.  
  1266. To use GNU CC on VMS, you need the VMS driver programs
  1267. @file{gcc.exe}, @file{gcc.com}, and @file{gcc.cld}.  They are
  1268. distributed with the VMS binaries (@file{gcc-vms}) rather than the
  1269. GNU CC sources.  GAS is also included in @file{gcc-vms}, as is Bison.
  1270.  
  1271. Once you have successfully built GNU CC with VAX C, you should use the
  1272. resulting compiler to rebuild itself.  Before doing this, be sure to
  1273. restore the @code{CC}, @code{CFLAGS}, and @code{LIBS} definitions in
  1274. @file{make-cccp.com} and @file{make-cc1.com}.  The second generation
  1275. compiler will be able to take advantage of many optimizations that must
  1276. be suppressed when building with other compilers.
  1277. @end enumerate
  1278.  
  1279. Under previous versions of GNU CC, the generated code would occasionally
  1280. give strange results when linked with the sharable @file{VAXCRTL} library.
  1281. Now this should work.
  1282.  
  1283. Even with this version, however, GNU CC itself should not be linked with
  1284. the sharable @file{VAXCRTL}.  The version of @code{qsort} in
  1285. @file{VAXCRTL} has a bug (known to be present in VMS versions V4.6
  1286. through V5.5) which causes the compiler to fail.
  1287.  
  1288. The executables are generated by @file{make-cc1.com} and
  1289. @file{make-cccp.com} use the object library version of @file{VAXCRTL} in
  1290. order to make use of the @code{qsort} routine in @file{gcclib.olb}.  If
  1291. you wish to link the compiler executables with the shareable image
  1292. version of @file{VAXCRTL}, you should edit the file @file{tm.h} (created
  1293. by @file{vmsconfig.com}) to define the macro @code{QSORT_WORKAROUND}.
  1294.  
  1295. @code{QSORT_WORKAROUND} is always defined when GNU CC is compiled with
  1296. VAX C, to avoid a problem in case @file{gcclib.olb} is not yet
  1297. available.
  1298.  
  1299.  
  1300. @node WE32K Install
  1301. @section Installing GNU CC on the WE32K
  1302.  
  1303. These computers are also known as the 3b2, 3b5, 3b20 and other similar
  1304. names.  (However, the 3b1 is actually a 68000; see @ref{3b1 Install}.)
  1305.  
  1306. Don't use @samp{-g} when compiling with the system's compiler.  The
  1307. system's linker seems to be unable to handle such a large program with
  1308. debugging information.
  1309.  
  1310. The system's compiler runs out of capacity when compiling @file{stmt.c}
  1311. in GNU CC.  You can work around this by building @file{cpp} in GNU CC
  1312. first, then use that instead of the system's preprocessor with the
  1313. system's C compiler to compile @file{stmt.c}.  Here is how:
  1314.  
  1315. @example
  1316. mv /lib/cpp /lib/cpp.att
  1317. cp cpp /lib/cpp.gnu
  1318. echo "/lib/cpp.gnu -traditional $*" > /lib/cpp
  1319. chmod +x /lib/cpp
  1320. @end example
  1321.  
  1322. The system's compiler produces bad code for some of the GNU CC
  1323. optimization files.  So you must build the stage 2 compiler without
  1324. optimization.  Then build a stage 3 compiler with optimization.
  1325. That executable should work.  Here are the necessary commands:
  1326.  
  1327. @example
  1328. make LANGUAGES=c CC=stage1/xgcc CFLAGS="-Bstage1/ -g"
  1329. make stage2
  1330. make CC=stage2/xgcc CFLAGS="-Bstage2/ -g -O"
  1331. @end example
  1332.  
  1333. You may need to raise the ULIMIT setting to build a C++ compiler,
  1334. as the file @file{cc1plus} is larger than one megabyte.
  1335.  
  1336.  
  1337. @node MIPS Install
  1338. @section Installing GNU CC on the MIPS
  1339.  
  1340. See @ref{Installation} about whether to use either of the options
  1341. @samp{--with-stabs} or @samp{--with-gnu-as}.
  1342.  
  1343. The MIPS C compiler needs to be told to increase its table size
  1344. for switch statements with the @samp{-Wf,-XNg1500} option in
  1345. order to compile @file{cp-parse.c}.  If you use the @samp{-O2}
  1346. optimization option, you also need to use @samp{-Olimit 3000}.
  1347. Both of these options are automatically generated in the
  1348. @file{Makefile} that the shell script @file{configure} builds.
  1349. If you override the @code{CC} make variable and use the MIPS
  1350. compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}.
  1351.  
  1352. MIPS computers running RISC-OS can support four different
  1353. personalities: default, BSD 4.3, System V.3, and System V.4
  1354. (older versions of RISC-OS don't support V.4).  To configure GCC
  1355. for these platforms use the following configurations:
  1356.  
  1357. @table @samp
  1358. @item mips-mips-riscos@code{rev}
  1359. Default configuration for RISC-OS, revision @code{rev}.
  1360.  
  1361. @item mips-mips-riscos@code{rev}bsd
  1362. BSD 4.3 configuration for RISC-OS, revision @code{rev}.
  1363.  
  1364. @item mips-mips-riscos@code{rev}sysv4
  1365. System V.4 configuration for RISC-OS, revision @code{rev}.
  1366.  
  1367. @item mips-mips-riscos@code{rev}sysv
  1368. System V.3 configuration for RISC-OS, revision @code{rev}.
  1369. @end table
  1370.  
  1371. The revision @code{rev} mentioned above is the revision of
  1372. RISC-OS to use.  You must reconfigure GCC when going from a
  1373. RISC-OS revision 4 to RISC-OS revision 5.  This has the effect of
  1374. avoiding a linker
  1375. @ifclear INSTALLONLY
  1376. bug (see @ref{Installation Problems} for more details).
  1377. @end ifclear
  1378. @ifset INSTALLONLY
  1379. bug.
  1380. @end ifset
  1381.  
  1382. DECstations can support three different personalities: Ultrix,
  1383. DEC OSF/1, and OSF/rose.  To configure GCC for these platforms
  1384. use the following configurations:
  1385.  
  1386. @table @samp
  1387. @item decstation-ultrix
  1388. Ultrix configuration.
  1389.  
  1390. @item decstation-osf1
  1391. Dec's version of OSF/1.
  1392.  
  1393. @item decstation-osfrose
  1394. Open Software Foundation reference port of OSF/1 which uses the
  1395. OSF/rose object file format instead of ECOFF.  Normally, you
  1396. would not select this configuration.
  1397. @end table
  1398.  
  1399. On Irix version 4.0.5F, and perhaps on some other versions as well,
  1400. there is an assembler bug that reorders instructions incorrectly.  To
  1401. work around it, specify the target configuration
  1402. @samp{mips-sgi-irix4loser}.  This configuration inhibits assembler
  1403. optimization.
  1404.  
  1405. You can turn off assembler optimization in a compiler configured with
  1406. target @samp{mips-sgi-irix4} using the @samp{-noasmopt} option.  This
  1407. compiler option passes the option @samp{-O0} to the assembler, to
  1408. inhibit reordering.
  1409.  
  1410. The @samp{-noasmopt} option can be useful for testing whether a problem
  1411. is due to erroneous assembler reordering.  Even if a problem does not go
  1412. away with @samp{-noasmopt}, it may still be due to assembler
  1413. reordering---perhaps GNU CC itself was miscompiled as a result.
  1414.  
  1415. We know this is inconvenient, but it's the best that can be done at
  1416. the last minute.
  1417.  
  1418. @node Collect2
  1419. @section @code{collect2}
  1420.  
  1421. Many target systems do not have support in the assembler and linker for
  1422. ``constructors''---initialization functions to be called before the
  1423. official ``start'' of @code{main}.  On such systems, GNU CC uses a
  1424. utility called @code{collect2} to arrange to call these functions at
  1425. start time.
  1426.  
  1427. The program @code{collect2} works by linking the program once and
  1428. looking through the linker output file for symbols with particular names
  1429. indicating they are constructor functions.  If it finds any, it
  1430. creates a new temporary @samp{.c} file containing a table of them,
  1431. compiles it, and links the program a second time including that file.
  1432.  
  1433. The actual calls to the constructors are carried out by a subroutine
  1434. called @code{__main}, which is called (automatically) at the beginning
  1435. of the body of @code{main} (provided @code{main} was compiled with GNU
  1436. CC).
  1437.  
  1438. The program @code{collect2} is installed as @code{ld} in the directory
  1439. where the passes of the compiler are installed.  When @code{collect2}
  1440. needs to find the @emph{real} @code{ld}, it tries the following file
  1441. names:
  1442.  
  1443. @itemize @bullet
  1444. @item
  1445. @file{gld} in the directories listed in the compiler's search
  1446. directories.
  1447.  
  1448. @item
  1449. @file{gld} in the directories listed in the environment variable
  1450. @code{PATH}.
  1451.  
  1452. @item
  1453. @file{real-ld} in the compiler's search directories.
  1454.  
  1455. @item
  1456. @file{real-ld} in @code{PATH}.
  1457.  
  1458. @item
  1459. @file{ld} in @code{PATH}.
  1460. @end itemize
  1461.  
  1462. ``The compiler's search directories'' means all the directories where
  1463. @code{gcc} searches for passes of the compiler.  This includes
  1464. directories that you specify with @samp{-B}.
  1465.  
  1466. Cross compilers search a little differently:
  1467.  
  1468. @itemize @bullet
  1469. @item
  1470. @file{gld} in the compiler's search directories.
  1471.  
  1472. @item
  1473. @file{@var{target}-gld} in @code{PATH}.
  1474.  
  1475. @item
  1476. @file{real-ld} in the compiler's search directories.
  1477.  
  1478. @item
  1479. @file{@var{target}-real-ld} in @code{PATH}.
  1480.  
  1481. @item
  1482. @file{@var{target}-ld} in @code{PATH}.
  1483. @end itemize
  1484.  
  1485. @code{collect2} does not search for @file{ld} using the compiler's
  1486. search directories, because if it did, it would find itself---not the
  1487. real @code{ld}---and this could lead to infinite recursion.  However,
  1488. the directory where @code{collect2} is installed might happen to be in
  1489. @code{PATH}.  That could lead @code{collect2} to invoke itself anyway.
  1490. when looking for @code{ld}.
  1491.  
  1492. To prevent this, @code{collect2} explicitly avoids running @code{ld}
  1493. using the file name under which @code{collect2} itself was invoked.  In
  1494. fact, it remembers up to two such names---in case one copy of
  1495. @code{collect2} finds another copy (or version) of @code{collect2}
  1496. installed as @code{ld} in a second place in the search path.
  1497.  
  1498. If two file names to avoid are not sufficient, you may still encounter
  1499. an infinite recursion of @code{collect2} processes.  When this happens.
  1500. check all the files installed as @file{ld} in any of the directories
  1501. searched, and straighten out the situation.
  1502.  
  1503. (In a future version, we will probably change @code{collect2} to avoid
  1504. any reinvocation of a file from which any parent @code{collect2} was
  1505. run.)
  1506.