| 1 | <html lang="en"> | 
|---|
| 2 | <head> | 
|---|
| 3 | <title>Installing GCC: Old documentation</title> | 
|---|
| 4 | <meta http-equiv="Content-Type" content="text/html"> | 
|---|
| 5 | <meta name="description" content="Installing GCC: Old documentation"> | 
|---|
| 6 | <meta name="generator" content="makeinfo 4.5"> | 
|---|
| 7 | <link href="http://www.gnu.org/software/texinfo/" rel="generator-home"> | 
|---|
| 8 | <!-- | 
|---|
| 9 | Copyright © 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, | 
|---|
| 10 | 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 
|---|
| 11 | <br><p> | 
|---|
| 12 | <p>Permission is granted to copy, distribute and/or modify this document | 
|---|
| 13 | under the terms of the GNU Free Documentation License, Version 1.2 or | 
|---|
| 14 | any later version published by the Free Software Foundation; with no | 
|---|
| 15 | Invariant Sections, the Front-Cover texts being (a) (see below), and | 
|---|
| 16 | with the Back-Cover Texts being (b) (see below).  A copy of the | 
|---|
| 17 | license is included in the section entitled "<a href="./gfdl.html">GNU Free Documentation License</a>". | 
|---|
| 18 |  | 
|---|
| 19 | <p>(a) The FSF's Front-Cover Text is: | 
|---|
| 20 |  | 
|---|
| 21 | <p>A GNU Manual | 
|---|
| 22 |  | 
|---|
| 23 | <p>(b) The FSF's Back-Cover Text is: | 
|---|
| 24 |  | 
|---|
| 25 | <p>You have freedom to copy and modify this GNU Manual, like GNU | 
|---|
| 26 | software.  Copies published by the Free Software Foundation raise | 
|---|
| 27 | funds for GNU development.--> | 
|---|
| 28 | </head> | 
|---|
| 29 | <body> | 
|---|
| 30 | <h1 class="settitle">Installing GCC: Old documentation</h1> | 
|---|
| 31 | <h1 align="center">Old installation documentation</h1> | 
|---|
| 32 |  | 
|---|
| 33 | <p>Note most of this information is out of date and superseded by the | 
|---|
| 34 | previous chapters of this manual.  It is provided for historical | 
|---|
| 35 | reference only, because of a lack of volunteers to merge it into the | 
|---|
| 36 | main manual. | 
|---|
| 37 |  | 
|---|
| 38 | <p>Here is the procedure for installing GNU CC on a GNU or Unix system. | 
|---|
| 39 | See <a href="#VMS%20Install">VMS Install</a>, for VMS systems. | 
|---|
| 40 |  | 
|---|
| 41 | <ol type=1 start=1> | 
|---|
| 42 | <li>If you have chosen a configuration for GNU CC which requires other GNU | 
|---|
| 43 | tools (such as GAS or the GNU linker) instead of the standard system | 
|---|
| 44 | tools, install the required tools in the build directory under the names | 
|---|
| 45 | <code>as</code>, <code>ld</code> or whatever is appropriate. | 
|---|
| 46 |  | 
|---|
| 47 | <p>Alternatively, you can do subsequent compilation using a value of the | 
|---|
| 48 | <code>PATH</code> environment variable such that the necessary GNU tools come | 
|---|
| 49 | before the standard system tools. | 
|---|
| 50 |  | 
|---|
| 51 | </p><li>Specify the host, build and target machine configurations.  You do this | 
|---|
| 52 | when you run the <code>configure</code> script. | 
|---|
| 53 |  | 
|---|
| 54 | <p>The <dfn>build</dfn> machine is the system which you are using, the | 
|---|
| 55 | <dfn>host</dfn> machine is the system where you want to run the resulting | 
|---|
| 56 | compiler (normally the build machine), and the <dfn>target</dfn> machine is | 
|---|
| 57 | the system for which you want the compiler to generate code. | 
|---|
| 58 |  | 
|---|
| 59 | <p>If you are building a compiler to produce code for the machine it runs | 
|---|
| 60 | on (a native compiler), you normally do not need to specify any operands | 
|---|
| 61 | to <code>configure</code>; it will try to guess the type of machine you are on | 
|---|
| 62 | and use that as the build, host and target machines.  So you don't need | 
|---|
| 63 | to specify a configuration when building a native compiler unless | 
|---|
| 64 | <code>configure</code> cannot figure out what your configuration is or guesses | 
|---|
| 65 | wrong. | 
|---|
| 66 |  | 
|---|
| 67 | <p>In those cases, specify the build machine's <dfn>configuration name</dfn> | 
|---|
| 68 | with the <code>--host</code> option; the host and target will default to be | 
|---|
| 69 | the same as the host machine.  (If you are building a cross-compiler, | 
|---|
| 70 | see <a href="#Cross-Compiler">Cross-Compiler</a>.) | 
|---|
| 71 |  | 
|---|
| 72 | <p>Here is an example: | 
|---|
| 73 |  | 
|---|
| 74 | <pre class="smallexample">          ./configure --host=sparc-sun-sunos4.1 | 
|---|
| 75 | </pre> | 
|---|
| 76 |  | 
|---|
| 77 | <p>A configuration name may be canonical or it may be more or less | 
|---|
| 78 | abbreviated. | 
|---|
| 79 |  | 
|---|
| 80 | <p>A canonical configuration name has three parts, separated by dashes. | 
|---|
| 81 | It looks like this: <code></code><var>cpu</var><code>-</code><var>company</var><code>-</code><var>system</var><code></code>. | 
|---|
| 82 | (The three parts may themselves contain dashes; <code>configure</code> | 
|---|
| 83 | can figure out which dashes serve which purpose.)  For example, | 
|---|
| 84 | <code>m68k-sun-sunos4.1</code> specifies a Sun 3. | 
|---|
| 85 |  | 
|---|
| 86 | <p>You can also replace parts of the configuration by nicknames or aliases. | 
|---|
| 87 | For example, <code>sun3</code> stands for <code>m68k-sun</code>, so | 
|---|
| 88 | <code>sun3-sunos4.1</code> is another way to specify a Sun 3. | 
|---|
| 89 |  | 
|---|
| 90 | <p>You can specify a version number after any of the system types, and some | 
|---|
| 91 | of the CPU types.  In most cases, the version is irrelevant, and will be | 
|---|
| 92 | ignored.  So you might as well specify the version if you know it. | 
|---|
| 93 |  | 
|---|
| 94 | <p>See <a href="#Configurations">Configurations</a>, for a list of supported configuration names and | 
|---|
| 95 | notes on many of the configurations.  You should check the notes in that | 
|---|
| 96 | section before proceeding any further with the installation of GNU CC. | 
|---|
| 97 |  | 
|---|
| 98 | </ol> | 
|---|
| 99 |  | 
|---|
| 100 | <h2><a name="Configurations"></a>Configurations Supported by GNU CC</h2> | 
|---|
| 101 |  | 
|---|
| 102 | <p>Here are the possible CPU types: | 
|---|
| 103 |  | 
|---|
| 104 | <blockquote> | 
|---|
| 105 | 1750a, a29k, alpha, arm, avr, c<var>n</var>, clipper, dsp16xx, elxsi, fr30, h8300, | 
|---|
| 106 | hppa1.0, hppa1.1, i370, i386, i486, i586, i686, i786, i860, i960, ip2k, m32r, | 
|---|
| 107 | m68000, m68k, m6811, m6812, m88k, mcore, mips, mipsel, mips64, mips64el, | 
|---|
| 108 | mn10200, mn10300, ns32k, pdp11, powerpc, powerpcle, romp, rs6000, sh, sparc, | 
|---|
| 109 | sparclite, sparc64, v850, vax, we32k. | 
|---|
| 110 | </blockquote> | 
|---|
| 111 |  | 
|---|
| 112 | <p>Here are the recognized company names.  As you can see, customary | 
|---|
| 113 | abbreviations are used rather than the longer official names. | 
|---|
| 114 |  | 
|---|
| 115 | <blockquote> | 
|---|
| 116 | acorn, alliant, altos, apollo, apple, att, bull, | 
|---|
| 117 | cbm, convergent, convex, crds, dec, dg, dolphin, | 
|---|
| 118 | elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi, | 
|---|
| 119 | mips, motorola, ncr, next, ns, omron, plexus, | 
|---|
| 120 | sequent, sgi, sony, sun, tti, unicom, wrs. | 
|---|
| 121 | </blockquote> | 
|---|
| 122 |  | 
|---|
| 123 | <p>The company name is meaningful only to disambiguate when the rest of | 
|---|
| 124 | the information supplied is insufficient.  You can omit it, writing | 
|---|
| 125 | just <code></code><var>cpu</var><code>-</code><var>system</var><code></code>, if it is not needed.  For example, | 
|---|
| 126 | <code>vax-ultrix4.2</code> is equivalent to <code>vax-dec-ultrix4.2</code>. | 
|---|
| 127 |  | 
|---|
| 128 | <p>Here is a list of system types: | 
|---|
| 129 |  | 
|---|
| 130 | <blockquote> | 
|---|
| 131 | 386bsd, aix, acis, amigaos, aos, aout, aux, bosx, bsd, clix, coff, ctix, cxux, | 
|---|
| 132 | dgux, dynix, ebmon, ecoff, elf, esix, freebsd, hms, genix, gnu, linux, | 
|---|
| 133 | linux-gnu, hiux, hpux, iris, irix, isc, luna, lynxos, mach, minix, msdos, mvs, | 
|---|
| 134 | netbsd, newsos, nindy, ns, osf, osfrose, ptx, riscix, riscos, rtu, sco, sim, | 
|---|
| 135 | solaris, sunos, sym, sysv, udi, ultrix, unicos, uniplus, unos, vms, vsta, | 
|---|
| 136 | vxworks, winnt, xenix. | 
|---|
| 137 | </blockquote> | 
|---|
| 138 |  | 
|---|
| 139 | <p>You can omit the system type; then <code>configure</code> guesses the | 
|---|
| 140 | operating system from the CPU and company. | 
|---|
| 141 |  | 
|---|
| 142 | <p>You can add a version number to the system type; this may or may not | 
|---|
| 143 | make a difference.  For example, you can write <code>bsd4.3</code> or | 
|---|
| 144 | <code>bsd4.4</code> to distinguish versions of BSD.  In practice, the version | 
|---|
| 145 | number is most needed for <code>sysv3</code> and <code>sysv4</code>, which are often | 
|---|
| 146 | treated differently. | 
|---|
| 147 |  | 
|---|
| 148 | <p><code>linux-gnu</code> is the canonical name for the GNU/Linux target; however | 
|---|
| 149 | GNU CC will also accept <code>linux</code>.  The version of the kernel in use is | 
|---|
| 150 | not relevant on these systems.  A suffix such as <code>libc1</code> or <code>aout</code> | 
|---|
| 151 | distinguishes major versions of the C library; all of the suffixed versions | 
|---|
| 152 | are obsolete. | 
|---|
| 153 |  | 
|---|
| 154 | <p>If you specify an impossible combination such as <code>i860-dg-vms</code>, | 
|---|
| 155 | then you may get an error message from <code>configure</code>, or it may | 
|---|
| 156 | ignore part of the information and do the best it can with the rest. | 
|---|
| 157 | <code>configure</code> always prints the canonical name for the alternative | 
|---|
| 158 | that it used.  GNU CC does not support all possible alternatives. | 
|---|
| 159 |  | 
|---|
| 160 | <p>Often a particular model of machine has a name.  Many machine names are | 
|---|
| 161 | recognized as aliases for CPU/company combinations.  Thus, the machine | 
|---|
| 162 | name <code>sun3</code>, mentioned above, is an alias for <code>m68k-sun</code>. | 
|---|
| 163 | Sometimes we accept a company name as a machine name, when the name is | 
|---|
| 164 | popularly used for a particular machine.  Here is a table of the known | 
|---|
| 165 | machine names: | 
|---|
| 166 |  | 
|---|
| 167 | <blockquote> | 
|---|
| 168 | 3300, 3b1, 3b<var>n</var>, 7300, altos3068, altos, | 
|---|
| 169 | apollo68, att-7300, balance, | 
|---|
| 170 | convex-c<var>n</var>, crds, decstation-3100, | 
|---|
| 171 | decstation, delta, encore, | 
|---|
| 172 | fx2800, gmicro, hp7<var>nn</var>, hp8<var>nn</var>, | 
|---|
| 173 | hp9k2<var>nn</var>, hp9k3<var>nn</var>, hp9k7<var>nn</var>, | 
|---|
| 174 | hp9k8<var>nn</var>, iris4d, iris, isi68, | 
|---|
| 175 | m3230, magnum, merlin, miniframe, | 
|---|
| 176 | mmax, news-3600, news800, news, next, | 
|---|
| 177 | pbd, pc532, pmax, powerpc, powerpcle, ps2, risc-news, | 
|---|
| 178 | rtpc, sun2, sun386i, sun386, sun3, | 
|---|
| 179 | sun4, symmetry, tower-32, tower. | 
|---|
| 180 | </blockquote> | 
|---|
| 181 |  | 
|---|
| 182 | <p>Remember that a machine name specifies both the cpu type and the company | 
|---|
| 183 | name. | 
|---|
| 184 | If you want to install your own homemade configuration files, you can | 
|---|
| 185 | use <code>local</code> as the company name to access them.  If you use | 
|---|
| 186 | configuration <code></code><var>cpu</var><code>-local</code>, the configuration name | 
|---|
| 187 | without the cpu prefix | 
|---|
| 188 | is used to form the configuration file names. | 
|---|
| 189 |  | 
|---|
| 190 | <p>Thus, if you specify <code>m68k-local</code>, configuration uses | 
|---|
| 191 | files <code>m68k.md</code>, <code>local.h</code>, <code>m68k.c</code>, | 
|---|
| 192 | <code>xm-local.h</code>, <code>t-local</code>, and <code>x-local</code>, all in the | 
|---|
| 193 | directory <code>config/m68k</code>. | 
|---|
| 194 |  | 
|---|
| 195 | <p>Here is a list of configurations that have special treatment or special | 
|---|
| 196 | things you must know: | 
|---|
| 197 |  | 
|---|
| 198 | <dl> | 
|---|
| 199 | <dt><code>vax-dec-vms</code> | 
|---|
| 200 | <dd>See <a href="#VMS%20Install">VMS Install</a>, for details on how to install GNU CC on VMS. | 
|---|
| 201 | </dl> | 
|---|
| 202 |  | 
|---|
| 203 | <h2><a name="Cross-Compiler"></a>Building and Installing a Cross-Compiler</h2> | 
|---|
| 204 |  | 
|---|
| 205 | <p>GNU CC can function as a cross-compiler for many machines, but not all. | 
|---|
| 206 |  | 
|---|
| 207 | <ul> | 
|---|
| 208 | <li>Cross-compilers for the Mips as target using the Mips assembler | 
|---|
| 209 | currently do not work, because the auxiliary programs | 
|---|
| 210 | <code>mips-tdump.c</code> and <code>mips-tfile.c</code> can't be compiled on | 
|---|
| 211 | anything but a Mips.  It does work to cross compile for a Mips | 
|---|
| 212 | if you use the GNU assembler and linker. | 
|---|
| 213 |  | 
|---|
| 214 | <li>Cross-compilers between machines with different floating point formats | 
|---|
| 215 | have not all been made to work.  GNU CC now has a floating point | 
|---|
| 216 | emulator with which these can work, but each target machine description | 
|---|
| 217 | needs to be updated to take advantage of it. | 
|---|
| 218 |  | 
|---|
| 219 | <li>Cross-compilation between machines of different word sizes is | 
|---|
| 220 | somewhat problematic and sometimes does not work. | 
|---|
| 221 | </ul> | 
|---|
| 222 |  | 
|---|
| 223 | <p>Since GNU CC generates assembler code, you probably need a | 
|---|
| 224 | cross-assembler that GNU CC can run, in order to produce object files. | 
|---|
| 225 | If you want to link on other than the target machine, you need a | 
|---|
| 226 | cross-linker as well.  You also need header files and libraries suitable | 
|---|
| 227 | for the target machine that you can install on the host machine. | 
|---|
| 228 |  | 
|---|
| 229 | <h2>Steps of Cross-Compilation</h2> | 
|---|
| 230 |  | 
|---|
| 231 | <p>To compile and run a program using a cross-compiler involves several | 
|---|
| 232 | steps: | 
|---|
| 233 |  | 
|---|
| 234 | <ul> | 
|---|
| 235 | <li>Run the cross-compiler on the host machine to produce assembler files | 
|---|
| 236 | for the target machine.  This requires header files for the target | 
|---|
| 237 | machine. | 
|---|
| 238 |  | 
|---|
| 239 | <li>Assemble the files produced by the cross-compiler.  You can do this | 
|---|
| 240 | either with an assembler on the target machine, or with a | 
|---|
| 241 | cross-assembler on the host machine. | 
|---|
| 242 |  | 
|---|
| 243 | <li>Link those files to make an executable.  You can do this either with a | 
|---|
| 244 | linker on the target machine, or with a cross-linker on the host | 
|---|
| 245 | machine.  Whichever machine you use, you need libraries and certain | 
|---|
| 246 | startup files (typically <code>crt....o</code>) for the target machine. | 
|---|
| 247 | </ul> | 
|---|
| 248 |  | 
|---|
| 249 | <p>It is most convenient to do all of these steps on the same host machine, | 
|---|
| 250 | since then you can do it all with a single invocation of GNU CC.  This | 
|---|
| 251 | requires a suitable cross-assembler and cross-linker.  For some targets, | 
|---|
| 252 | the GNU assembler and linker are available. | 
|---|
| 253 |  | 
|---|
| 254 | <h2>Configuring a Cross-Compiler</h2> | 
|---|
| 255 |  | 
|---|
| 256 | <p>To build GNU CC as a cross-compiler, you start out by running | 
|---|
| 257 | <code>configure</code>.  Use the <code>--target=</code><var>target</var><code></code> to specify the | 
|---|
| 258 | target type.  If <code>configure</code> was unable to correctly identify the | 
|---|
| 259 | system you are running on, also specify the <code>--build=</code><var>build</var><code></code> | 
|---|
| 260 | option.  For example, here is how to configure for a cross-compiler that | 
|---|
| 261 | produces code for an HP 68030 system running BSD on a system that | 
|---|
| 262 | <code>configure</code> can correctly identify: | 
|---|
| 263 |  | 
|---|
| 264 | <pre class="smallexample">     ./configure --target=m68k-hp-bsd4.3 | 
|---|
| 265 | </pre> | 
|---|
| 266 |  | 
|---|
| 267 | <h2>Tools and Libraries for a Cross-Compiler</h2> | 
|---|
| 268 |  | 
|---|
| 269 | <p>If you have a cross-assembler and cross-linker available, you should | 
|---|
| 270 | install them now.  Put them in the directory | 
|---|
| 271 | <code>/usr/local/</code><var>target</var><code>/bin</code>.  Here is a table of the tools | 
|---|
| 272 | you should put in this directory: | 
|---|
| 273 |  | 
|---|
| 274 | <dl> | 
|---|
| 275 | <dt><code>as</code> | 
|---|
| 276 | <dd>This should be the cross-assembler. | 
|---|
| 277 |  | 
|---|
| 278 | <br><dt><code>ld</code> | 
|---|
| 279 | <dd>This should be the cross-linker. | 
|---|
| 280 |  | 
|---|
| 281 | <br><dt><code>ar</code> | 
|---|
| 282 | <dd>This should be the cross-archiver: a program which can manipulate | 
|---|
| 283 | archive files (linker libraries) in the target machine's format. | 
|---|
| 284 |  | 
|---|
| 285 | <br><dt><code>ranlib</code> | 
|---|
| 286 | <dd>This should be a program to construct a symbol table in an archive file. | 
|---|
| 287 | </dl> | 
|---|
| 288 |  | 
|---|
| 289 | <p>The installation of GNU CC will find these programs in that directory, | 
|---|
| 290 | and copy or link them to the proper place to for the cross-compiler to | 
|---|
| 291 | find them when run later. | 
|---|
| 292 |  | 
|---|
| 293 | <p>The easiest way to provide these files is to build the Binutils package | 
|---|
| 294 | and GAS.  Configure them with the same <code>--host</code> and <code>--target</code> | 
|---|
| 295 | options that you use for configuring GNU CC, then build and install | 
|---|
| 296 | them.  They install their executables automatically into the proper | 
|---|
| 297 | directory.  Alas, they do not support all the targets that GNU CC | 
|---|
| 298 | supports. | 
|---|
| 299 |  | 
|---|
| 300 | <p>If you want to install libraries to use with the cross-compiler, such as | 
|---|
| 301 | a standard C library, put them in the directory | 
|---|
| 302 | <code>/usr/local/</code><var>target</var><code>/lib</code>; installation of GNU CC copies | 
|---|
| 303 | all the files in that subdirectory into the proper place for GNU CC to | 
|---|
| 304 | find them and link with them.  Here's an example of copying some | 
|---|
| 305 | libraries from a target machine: | 
|---|
| 306 |  | 
|---|
| 307 | <pre class="example">     ftp <var>target-machine</var> | 
|---|
| 308 | lcd /usr/local/<var>target</var>/lib | 
|---|
| 309 | cd /lib | 
|---|
| 310 | get libc.a | 
|---|
| 311 | cd /usr/lib | 
|---|
| 312 | get libg.a | 
|---|
| 313 | get libm.a | 
|---|
| 314 | quit | 
|---|
| 315 | </pre> | 
|---|
| 316 |  | 
|---|
| 317 | <p>The precise set of libraries you'll need, and their locations on | 
|---|
| 318 | the target machine, vary depending on its operating system. | 
|---|
| 319 |  | 
|---|
| 320 | <p>Many targets require "start files" such as <code>crt0.o</code> and | 
|---|
| 321 | <code>crtn.o</code> which are linked into each executable; these too should be | 
|---|
| 322 | placed in <code>/usr/local/</code><var>target</var><code>/lib</code>.  There may be several | 
|---|
| 323 | alternatives for <code>crt0.o</code>, for use with profiling or other | 
|---|
| 324 | compilation options.  Check your target's definition of | 
|---|
| 325 | <code>STARTFILE_SPEC</code> to find out what start files it uses. | 
|---|
| 326 | Here's an example of copying these files from a target machine: | 
|---|
| 327 |  | 
|---|
| 328 | <pre class="example">     ftp <var>target-machine</var> | 
|---|
| 329 | lcd /usr/local/<var>target</var>/lib | 
|---|
| 330 | prompt | 
|---|
| 331 | cd /lib | 
|---|
| 332 | mget *crt*.o | 
|---|
| 333 | cd /usr/lib | 
|---|
| 334 | mget *crt*.o | 
|---|
| 335 | quit | 
|---|
| 336 | </pre> | 
|---|
| 337 |  | 
|---|
| 338 | <h2>Cross-Compilers and Header Files</h2> | 
|---|
| 339 |  | 
|---|
| 340 | <p>If you are cross-compiling a standalone program or a program for an | 
|---|
| 341 | embedded system, then you may not need any header files except the few | 
|---|
| 342 | that are part of GNU CC (and those of your program).  However, if you | 
|---|
| 343 | intend to link your program with a standard C library such as | 
|---|
| 344 | <code>libc.a</code>, then you probably need to compile with the header files | 
|---|
| 345 | that go with the library you use. | 
|---|
| 346 |  | 
|---|
| 347 | <p>The GNU C compiler does not come with these files, because (1) they are | 
|---|
| 348 | system-specific, and (2) they belong in a C library, not in a compiler. | 
|---|
| 349 |  | 
|---|
| 350 | <p>If the GNU C library supports your target machine, then you can get the | 
|---|
| 351 | header files from there (assuming you actually use the GNU library when | 
|---|
| 352 | you link your program). | 
|---|
| 353 |  | 
|---|
| 354 | <p>If your target machine comes with a C compiler, it probably comes with | 
|---|
| 355 | suitable header files also.  If you make these files accessible from the host | 
|---|
| 356 | machine, the cross-compiler can use them also. | 
|---|
| 357 |  | 
|---|
| 358 | <p>Otherwise, you're on your own in finding header files to use when | 
|---|
| 359 | cross-compiling. | 
|---|
| 360 |  | 
|---|
| 361 | <p>When you have found suitable header files, you should put them in the | 
|---|
| 362 | directory <code>/usr/local/</code><var>target</var><code>/include</code>, before building the | 
|---|
| 363 | cross compiler.  Then installation will run fixincludes properly and | 
|---|
| 364 | install the corrected versions of the header files where the compiler | 
|---|
| 365 | will use them. | 
|---|
| 366 |  | 
|---|
| 367 | <p>Provide the header files before you build the cross-compiler, because | 
|---|
| 368 | the build stage actually runs the cross-compiler to produce parts of | 
|---|
| 369 | <code>libgcc.a</code>.  (These are the parts that <em>can</em> be compiled with | 
|---|
| 370 | GNU CC.)  Some of them need suitable header files. | 
|---|
| 371 |  | 
|---|
| 372 | <p>Here's an example showing how to copy the header files from a target | 
|---|
| 373 | machine.  On the target machine, do this: | 
|---|
| 374 |  | 
|---|
| 375 | <pre class="example">     (cd /usr/include; tar cf - .) > tarfile | 
|---|
| 376 | </pre> | 
|---|
| 377 |  | 
|---|
| 378 | <p>Then, on the host machine, do this: | 
|---|
| 379 |  | 
|---|
| 380 | <pre class="example">     ftp <var>target-machine</var> | 
|---|
| 381 | lcd /usr/local/<var>target</var>/include | 
|---|
| 382 | get tarfile | 
|---|
| 383 | quit | 
|---|
| 384 | tar xf tarfile | 
|---|
| 385 | </pre> | 
|---|
| 386 |  | 
|---|
| 387 | <h2>Actually Building the Cross-Compiler</h2> | 
|---|
| 388 |  | 
|---|
| 389 | <p>Now you can proceed just as for compiling a single-machine compiler | 
|---|
| 390 | through the step of building stage 1. | 
|---|
| 391 |  | 
|---|
| 392 | <p>Do not try to build stage 2 for a cross-compiler.  It doesn't work to | 
|---|
| 393 | rebuild GNU CC as a cross-compiler using the cross-compiler, because | 
|---|
| 394 | that would produce a program that runs on the target machine, not on the | 
|---|
| 395 | host.  For example, if you compile a 386-to-68030 cross-compiler with | 
|---|
| 396 | itself, the result will not be right either for the 386 (because it was | 
|---|
| 397 | compiled into 68030 code) or for the 68030 (because it was configured | 
|---|
| 398 | for a 386 as the host).  If you want to compile GNU CC into 68030 code, | 
|---|
| 399 | whether you compile it on a 68030 or with a cross-compiler on a 386, you | 
|---|
| 400 | must specify a 68030 as the host when you configure it. | 
|---|
| 401 |  | 
|---|
| 402 | <p>To install the cross-compiler, use <code>make install</code>, as usual. | 
|---|
| 403 |  | 
|---|
| 404 | <h2><a name="VMS%20Install"></a>Installing GNU CC on VMS</h2> | 
|---|
| 405 |  | 
|---|
| 406 | <p>The VMS version of GNU CC is distributed in a backup saveset containing | 
|---|
| 407 | both source code and precompiled binaries. | 
|---|
| 408 |  | 
|---|
| 409 | <p>To install the <code>gcc</code> command so you can use the compiler easily, in | 
|---|
| 410 | the same manner as you use the VMS C compiler, you must install the VMS CLD | 
|---|
| 411 | file for GNU CC as follows: | 
|---|
| 412 |  | 
|---|
| 413 | <ol type=1 start=1> | 
|---|
| 414 | <li>Define the VMS logical names <code>GNU_CC</code> and <code>GNU_CC_INCLUDE</code> | 
|---|
| 415 | to point to the directories where the GNU CC executables | 
|---|
| 416 | (<code>gcc-cpp.exe</code>, <code>gcc-cc1.exe</code>, etc.) and the C include files are | 
|---|
| 417 | kept respectively.  This should be done with the commands: | 
|---|
| 418 |  | 
|---|
| 419 | <pre class="smallexample">          $ assign /system /translation=concealed - | 
|---|
| 420 | disk:[gcc.] gnu_cc | 
|---|
| 421 | $ assign /system /translation=concealed - | 
|---|
| 422 | disk:[gcc.include.] gnu_cc_include | 
|---|
| 423 | </pre> | 
|---|
| 424 |  | 
|---|
| 425 | <p>with the appropriate disk and directory names.  These commands can be | 
|---|
| 426 | placed in your system startup file so they will be executed whenever | 
|---|
| 427 | the machine is rebooted.  You may, if you choose, do this via the | 
|---|
| 428 | <code>GCC_INSTALL.COM</code> script in the <code>[GCC]</code> directory. | 
|---|
| 429 |  | 
|---|
| 430 | </p><li>Install the <code>GCC</code> command with the command line: | 
|---|
| 431 |  | 
|---|
| 432 | <pre class="smallexample">          $ set command /table=sys$common:[syslib]dcltables - | 
|---|
| 433 | /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc | 
|---|
| 434 | $ install replace sys$common:[syslib]dcltables | 
|---|
| 435 | </pre> | 
|---|
| 436 |  | 
|---|
| 437 | <li>To install the help file, do the following: | 
|---|
| 438 |  | 
|---|
| 439 | <pre class="smallexample">          $ library/help sys$library:helplib.hlb gcc.hlp | 
|---|
| 440 | </pre> | 
|---|
| 441 |  | 
|---|
| 442 | <p>Now you can invoke the compiler with a command like <code>gcc /verbose | 
|---|
| 443 | file.c</code>, which is equivalent to the command <code>gcc -v -c file.c</code> in | 
|---|
| 444 | Unix. | 
|---|
| 445 | </ol> | 
|---|
| 446 |  | 
|---|
| 447 | <p>If you wish to use GNU C++ you must first install GNU CC, and then | 
|---|
| 448 | perform the following steps: | 
|---|
| 449 |  | 
|---|
| 450 | <ol type=1 start=1> | 
|---|
| 451 | <li>Define the VMS logical name <code>GNU_GXX_INCLUDE</code> to point to the | 
|---|
| 452 | directory where the preprocessor will search for the C++ header files. | 
|---|
| 453 | This can be done with the command: | 
|---|
| 454 |  | 
|---|
| 455 | <pre class="smallexample">          $ assign /system /translation=concealed - | 
|---|
| 456 | disk:[gcc.gxx_include.] gnu_gxx_include | 
|---|
| 457 | </pre> | 
|---|
| 458 |  | 
|---|
| 459 | <p>with the appropriate disk and directory name.  If you are going to be | 
|---|
| 460 | using a C++ runtime library, this is where its install procedure will install | 
|---|
| 461 | its header files. | 
|---|
| 462 |  | 
|---|
| 463 | </p><li>Obtain the file <code>gcc-cc1plus.exe</code>, and place this in the same | 
|---|
| 464 | directory that <code>gcc-cc1.exe</code> is kept. | 
|---|
| 465 |  | 
|---|
| 466 | <p>The GNU C++ compiler can be invoked with a command like <code>gcc /plus | 
|---|
| 467 | /verbose file.cc</code>, which is equivalent to the command <code>g++ -v -c | 
|---|
| 468 | file.cc</code> in Unix. | 
|---|
| 469 | </ol> | 
|---|
| 470 |  | 
|---|
| 471 | <p>We try to put corresponding binaries and sources on the VMS distribution | 
|---|
| 472 | tape.  But sometimes the binaries will be from an older version than the | 
|---|
| 473 | sources, because we don't always have time to update them.  (Use the | 
|---|
| 474 | <code>/version</code> option to determine the version number of the binaries and | 
|---|
| 475 | compare it with the source file <code>version.c</code> to tell whether this is | 
|---|
| 476 | so.)  In this case, you should use the binaries you get to recompile the | 
|---|
| 477 | sources.  If you must recompile, here is how: | 
|---|
| 478 |  | 
|---|
| 479 | <ol type=1 start=1> | 
|---|
| 480 | <li>Execute the command procedure <code>vmsconfig.com</code> to set up the files | 
|---|
| 481 | <code>tm.h</code>, <code>config.h</code>, <code>aux-output.c</code>, and <code>md.</code>, and | 
|---|
| 482 | to create files <code>tconfig.h</code> and <code>hconfig.h</code>.  This procedure | 
|---|
| 483 | also creates several linker option files used by <code>make-cc1.com</code> and | 
|---|
| 484 | a data file used by <code>make-l2.com</code>. | 
|---|
| 485 |  | 
|---|
| 486 | <pre class="smallexample">          $ @vmsconfig.com | 
|---|
| 487 | </pre> | 
|---|
| 488 |  | 
|---|
| 489 | <li>Setup the logical names and command tables as defined above.  In | 
|---|
| 490 | addition, define the VMS logical name <code>GNU_BISON</code> to point at the | 
|---|
| 491 | to the directories where the Bison executable is kept.  This should be | 
|---|
| 492 | done with the command: | 
|---|
| 493 |  | 
|---|
| 494 | <pre class="smallexample">          $ assign /system /translation=concealed - | 
|---|
| 495 | disk:[bison.] gnu_bison | 
|---|
| 496 | </pre> | 
|---|
| 497 |  | 
|---|
| 498 | <p>You may, if you choose, use the <code>INSTALL_BISON.COM</code> script in the | 
|---|
| 499 | <code>[BISON]</code> directory. | 
|---|
| 500 |  | 
|---|
| 501 | </p><li>Install the <code>BISON</code> command with the command line: | 
|---|
| 502 |  | 
|---|
| 503 | <pre class="smallexample">          $ set command /table=sys$common:[syslib]dcltables - | 
|---|
| 504 | /output=sys$common:[syslib]dcltables - | 
|---|
| 505 | gnu_bison:[000000]bison | 
|---|
| 506 | $ install replace sys$common:[syslib]dcltables | 
|---|
| 507 | </pre> | 
|---|
| 508 |  | 
|---|
| 509 | <li>Type <code>@make-gcc</code> to recompile everything, or submit the file | 
|---|
| 510 | <code>make-gcc.com</code> to a batch queue.  If you wish to build the GNU C++ | 
|---|
| 511 | compiler as well as the GNU CC compiler, you must first edit | 
|---|
| 512 | <code>make-gcc.com</code> and follow the instructions that appear in the | 
|---|
| 513 | comments. | 
|---|
| 514 |  | 
|---|
| 515 | <li>In order to use GCC, you need a library of functions which GCC compiled code | 
|---|
| 516 | will call to perform certain tasks, and these functions are defined in the | 
|---|
| 517 | file <code>libgcc2.c</code>.  To compile this you should use the command procedure | 
|---|
| 518 | <code>make-l2.com</code>, which will generate the library <code>libgcc2.olb</code>. | 
|---|
| 519 | <code>libgcc2.olb</code> should be built using the compiler built from | 
|---|
| 520 | the same distribution that <code>libgcc2.c</code> came from, and | 
|---|
| 521 | <code>make-gcc.com</code> will automatically do all of this for you. | 
|---|
| 522 |  | 
|---|
| 523 | <p>To install the library, use the following commands: | 
|---|
| 524 |  | 
|---|
| 525 | <pre class="smallexample">          $ library gnu_cc:[000000]gcclib/delete=(new,eprintf) | 
|---|
| 526 | $ library gnu_cc:[000000]gcclib/delete=L_* | 
|---|
| 527 | $ library libgcc2/extract=*/output=libgcc2.obj | 
|---|
| 528 | $ library gnu_cc:[000000]gcclib libgcc2.obj | 
|---|
| 529 | </pre> | 
|---|
| 530 |  | 
|---|
| 531 | <p>The first command simply removes old modules that will be replaced with | 
|---|
| 532 | modules from <code>libgcc2</code> under different module names.  The modules | 
|---|
| 533 | <code>new</code> and <code>eprintf</code> may not actually be present in your | 
|---|
| 534 | <code>gcclib.olb</code>--if the VMS librarian complains about those modules | 
|---|
| 535 | not being present, simply ignore the message and continue on with the | 
|---|
| 536 | next command.  The second command removes the modules that came from the | 
|---|
| 537 | previous version of the library <code>libgcc2.c</code>. | 
|---|
| 538 |  | 
|---|
| 539 | <p>Whenever you update the compiler on your system, you should also update the | 
|---|
| 540 | library with the above procedure. | 
|---|
| 541 |  | 
|---|
| 542 | </p><li>You may wish to build GCC in such a way that no files are written to the | 
|---|
| 543 | directory where the source files reside.  An example would be the when | 
|---|
| 544 | the source files are on a read-only disk.  In these cases, execute the | 
|---|
| 545 | following DCL commands (substituting your actual path names): | 
|---|
| 546 |  | 
|---|
| 547 | <pre class="smallexample">          $ assign dua0:[gcc.build_dir.]/translation=concealed, - | 
|---|
| 548 | dua1:[gcc.source_dir.]/translation=concealed  gcc_build | 
|---|
| 549 | $ set default gcc_build:[000000] | 
|---|
| 550 | </pre> | 
|---|
| 551 |  | 
|---|
| 552 | <p>where the directory <code>dua1:[gcc.source_dir]</code> contains the source | 
|---|
| 553 | code, and the directory <code>dua0:[gcc.build_dir]</code> is meant to contain | 
|---|
| 554 | all of the generated object files and executables.  Once you have done | 
|---|
| 555 | this, you can proceed building GCC as described above.  (Keep in mind | 
|---|
| 556 | that <code>gcc_build</code> is a rooted logical name, and thus the device | 
|---|
| 557 | names in each element of the search list must be an actual physical | 
|---|
| 558 | device name rather than another rooted logical name). | 
|---|
| 559 |  | 
|---|
| 560 | </p><li><strong>If you are building GNU CC with a previous version of GNU CC, | 
|---|
| 561 | you also should check to see that you have the newest version of the | 
|---|
| 562 | assembler</strong>.  In particular, GNU CC version 2 treats global constant | 
|---|
| 563 | variables slightly differently from GNU CC version 1, and GAS version | 
|---|
| 564 | 1.38.1 does not have the patches required to work with GCC version 2. | 
|---|
| 565 | If you use GAS 1.38.1, then <code>extern const</code> variables will not have | 
|---|
| 566 | the read-only bit set, and the linker will generate warning messages | 
|---|
| 567 | about mismatched psect attributes for these variables.  These warning | 
|---|
| 568 | messages are merely a nuisance, and can safely be ignored. | 
|---|
| 569 |  | 
|---|
| 570 | <li>If you want to build GNU CC with the VAX C compiler, you will need to | 
|---|
| 571 | make minor changes in <code>make-cccp.com</code> and <code>make-cc1.com</code> | 
|---|
| 572 | to choose alternate definitions of <code>CC</code>, <code>CFLAGS</code>, and | 
|---|
| 573 | <code>LIBS</code>.  See comments in those files.  However, you must | 
|---|
| 574 | also have a working version of the GNU assembler (GNU as, aka GAS) as | 
|---|
| 575 | it is used as the back end for GNU CC to produce binary object modules | 
|---|
| 576 | and is not included in the GNU CC sources.  GAS is also needed to | 
|---|
| 577 | compile <code>libgcc2</code> in order to build <code>gcclib</code> (see above); | 
|---|
| 578 | <code>make-l2.com</code> expects to be able to find it operational in | 
|---|
| 579 | <code>gnu_cc:[000000]gnu-as.exe</code>. | 
|---|
| 580 |  | 
|---|
| 581 | <p>To use GNU CC on VMS, you need the VMS driver programs | 
|---|
| 582 | <code>gcc.exe</code>, <code>gcc.com</code>, and <code>gcc.cld</code>.  They are | 
|---|
| 583 | distributed with the VMS binaries (<code>gcc-vms</code>) rather than the | 
|---|
| 584 | GNU CC sources.  GAS is also included in <code>gcc-vms</code>, as is Bison. | 
|---|
| 585 |  | 
|---|
| 586 | <p>Once you have successfully built GNU CC with VAX C, you should use the | 
|---|
| 587 | resulting compiler to rebuild itself.  Before doing this, be sure to | 
|---|
| 588 | restore the <code>CC</code>, <code>CFLAGS</code>, and <code>LIBS</code> definitions in | 
|---|
| 589 | <code>make-cccp.com</code> and <code>make-cc1.com</code>.  The second generation | 
|---|
| 590 | compiler will be able to take advantage of many optimizations that must | 
|---|
| 591 | be suppressed when building with other compilers. | 
|---|
| 592 | </ol> | 
|---|
| 593 |  | 
|---|
| 594 | <p>Under previous versions of GNU CC, the generated code would occasionally | 
|---|
| 595 | give strange results when linked with the sharable <code>VAXCRTL</code> library. | 
|---|
| 596 | Now this should work. | 
|---|
| 597 |  | 
|---|
| 598 | <p>Even with this version, however, GNU CC itself should not be linked with | 
|---|
| 599 | the sharable <code>VAXCRTL</code>.  The version of <code>qsort</code> in | 
|---|
| 600 | <code>VAXCRTL</code> has a bug (known to be present in VMS versions V4.6 | 
|---|
| 601 | through V5.5) which causes the compiler to fail. | 
|---|
| 602 |  | 
|---|
| 603 | <p>The executables are generated by <code>make-cc1.com</code> and | 
|---|
| 604 | <code>make-cccp.com</code> use the object library version of <code>VAXCRTL</code> in | 
|---|
| 605 | order to make use of the <code>qsort</code> routine in <code>gcclib.olb</code>.  If | 
|---|
| 606 | you wish to link the compiler executables with the shareable image | 
|---|
| 607 | version of <code>VAXCRTL</code>, you should edit the file <code>tm.h</code> (created | 
|---|
| 608 | by <code>vmsconfig.com</code>) to define the macro <code>QSORT_WORKAROUND</code>. | 
|---|
| 609 |  | 
|---|
| 610 | <p><code>QSORT_WORKAROUND</code> is always defined when GNU CC is compiled with | 
|---|
| 611 | VAX C, to avoid a problem in case <code>gcclib.olb</code> is not yet | 
|---|
| 612 | available. | 
|---|
| 613 | <hr /> | 
|---|
| 614 | <p> | 
|---|
| 615 | <a href="./index.html">Return to the GCC Installation page</a> | 
|---|
| 616 |  | 
|---|
| 617 | </body></html> | 
|---|
| 618 |  | 
|---|