|
|
1.1 root 1: @c Copyright (C) 1988, 1989, 1992 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: @end menu
25: @iftex
26: See below for VMS systems, and modified procedures needed on other
27: systems including HP, Sun, 3b1, SCO Unix and Unos. The following section
28: says how to compile in a separate directory on Unix; here we assume you
29: compile in the same directory that contains the source files.
30: @end iftex
31:
32: @enumerate
33: @item
34: If you have built GNU CC previously in the same directory for a
35: different target machine, do @samp{make distclean} to delete all files
36: that might be invalid.
37:
38: @item
39: On a System V release 4 system, make sure @file{/usr/bin} precedes
40: @file{/usr/ucb} in @code{PATH}. The @code{cc} command in
41: @file{/usr/ucb} uses libraries which have bugs.
42:
43: @item
44: Specify the host and target machine configurations. You do this by
45: running the file @file{configure} with appropriate arguments.
46:
47: If you are building a compiler to produce code for the machine it runs
48: on, specify just one machine type. Use the @samp{--target} option; the
49: host type will default to be the same as the target. (For information
50: on building a cross-compiler, see @ref{Cross-Compiler}.) The command
51: looks like this:
52:
53: @example
54: configure --target=sparc-sun-sunos4.1
55: @end example
56:
57: A configuration name may be canonical or it may be more or less
58: abbreviated.
59:
60: A canonical configuration name has three parts, separated by dashes.
61: It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}.
62: (The three parts may themselves contain dashes; @file{configure}
63: can figure out which dashes serve which purpose.) For example,
64: @samp{m68k-sun-sunos4.1} specifies a Sun 3.
65:
66: You can also replace parts of the configuration by nicknames or aliases.
67: For example, @samp{sun3} stands for @samp{m68k-sun}, so
68: @samp{sun3-sunos4.1} is another way to specify a Sun 3. You can also
69: use simply @samp{sun3-sunos}, since the version of SunOS is assumed by
70: default to be version 4. @samp{sun3-bsd} also works, since
71: @file{configure} knows that the only BSD variant on a Sun 3 is SunOS.
72:
73: You can specify a version number after any of the system types, and some
74: of the CPU types. In most cases, the version is irrelevant, and will be
75: ignored. So you might as well specify the version if you know it.
76:
77: Here are the possible CPU types:
78:
79: @quotation
80: @c gmicro, pyramid, alliant, spur and tahoe omitted since they don't work.
81: a29k, arm, c@var{n}, hppa1.0, hppa1.1, i386,
82: i860, i960, m68000, m68k, m88k, mips,
83: ns32k, romp, rs6000, sparc, vax, we32k.
84: @end quotation
85:
86: Here are the recognized company names. As you can see, customary
87: abbreviations are used rather than the longer official names.
88:
89: @quotation
90: alliant, altos, apollo, att,
91: convergent, convex, crds, dec, dg,
92: encore, harris, hp, ibm, mips,
93: motorola, ncr, next, ns, omron,
94: sequent, sgi, sony, sun, tti,
95: unicom.
96: @end quotation
97:
98: The company name is meaningful only to disambiguate when the rest of
99: the information supplied is insufficient. You can omit it, writing
100: just @samp{@var{cpu}-@var{system}}, if it is not needed. For example,
101: @samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}.
102:
103: Here is a list of system types:
104:
105: @quotation
106: bsd, sysv, mach, minix, genix,
107: ultrix, vms, sco, isc,
108: aix, sunos, hpux, unos,
109: luna, dgux, newsos, osfrose, osf,
110: dynix, aos, ctix.
111: @end quotation
112:
113: @noindent
114: You can omit the system type; then @file{configure} guesses the
115: operating system from the CPU and company.
116:
117: You can add a version number to the system type; this may or may not
118: make a difference. For example, you can write @samp{bsd4.3} or
119: @samp{bsd4.4} to distinguish versions of BSD. In practice, the version
120: number is most needed for @samp{sysv3} and @samp{sysv4}, which are often
121: treated differently.
122:
123: If you specify an impossible combination such as @samp{i860-dg-vms},
124: then you may get an error message from @file{configure}, or it may
125: ignore part of the information and do the best it can with the rest.
126: @file{configure} always prints the canonical name for the alternative
127: that it used.
128:
129: Often a particular model of machine has a name. Many machine names are
130: recognized as aliases for CPU/company combinations. Thus, the machine
131: name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}.
132: Sometimes we accept a company name as a machine name, when the name is
133: popularly used for a particular machine. Here is a table of the known
134: machine names:
135:
136: @quotation
137: 3300, 3b1, 3b@var{n}, 7300, altos3068, altos,
138: apollo68, att-7300, balance,
139: convex-c@var{n}, crds, decstation-3100,
140: decstation, delta, encore,
141: fx2800, gmicro, hp7@var{nn}, hp8@var{nn},
142: hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn},
143: hp9k8@var{nn}, iris4d, iris, isi68,
144: m3230, magnum, merlin, miniframe,
145: mmax, news-3600, news800, news, next,
146: pbd, pc532, pmax, ps2, risc-news,
147: rtpc, sun2, sun386i, sun386, sun3,
148: sun4, symmetry, tower-32, tower.
149: @end quotation
150:
151: @noindent
152: Remember that a machine name specifies both the cpu type and the company
153: name.
154:
155: There are three additional options you can specify independently to
156: describe variant hardware and software configurations. These are
157: @samp{--with-gnu-as}, @samp{--with-gnu-ld}, and @samp{--nfp}.
158:
159: @table @samp
160: @item --with-gnu-as
161: On certain systems, you must specify whether you want GNU CC to work
162: with the usual compilation tools or with the GNU compilation tools
163: (including GAS). Use the @samp{--with-gnu-as} argument when you run
164: @file{configure}, if you want to use the GNU tools. (Specify
165: @samp{--with-gnu-ld} as well, since on these systems GAS works only with
166: the GNU linker.) The systems were this makes a difference are
167: @samp{i386-@var{anything}-sysv}, @samp{i860-@var{anything}-bsd},
168: @samp{m68k-hp-hpux}, @samp{m68k-sony-bsd}, @samp{m68k-altos-sysv},
169: @samp{m68000-hp-hpux}, and @samp{m68000-att-sysv}. On any other system,
170: @samp{--with-gnu-as} has no effect.
171:
172: @item --with-gnu-ld
173: Specify the option @samp{--with-gnu-ld} if you plan to use the GNU
174: linker. This inhibits the installation of @code{collect2}, a program
175: which otherwise serves as a front-end for the system's linker on most
176: configurations.
177:
178: @item --nfp
179: On certain systems, you must specify whether the machine has a floating
180: point unit. These systems are @samp{m68k-sun-sunos@var{n}} and
181: @samp{m68k-isi-bsd}. On any other system, @samp{--nfp} currently has no
182: effect, though perhaps there are other systems where it could usefully
183: make a difference.
184: @end table
185:
186: If you want to install your own homemade configuration files, you can
187: use @samp{local} as the company name to access them. If you use
188: configuration @samp{@var{cpu}-local}, the entire configuration name
189: is used to form the configuration file names.
190:
191: Thus, if you specify @samp{m68k-local}, then the files used are
192: @file{m68k-local.md}, @file{m68k-local.h}, @file{m68k-local.c},
193: @file{xm-m68k-local.h}, @file{t-m68k-local}, and @file{x-m68k-local}.
194:
195: Here is a list of configurations that have special treatment or special
196: things you must know:
197:
198: @table @samp
199: @ignore
200: @item fx80
201: Alliant FX/8 computer. Note that the standard installed C compiler in
202: Concentrix 5.0 has a bug which prevent it from compiling GNU CC
203: correctly. You can patch the compiler bug as follows:
204:
205: @example
206: cp /bin/pcc ./pcc
207: adb -w ./pcc - << EOF
208: 15f6?w 6610
209: EOF
210: @end example
211:
212: Then you must use the @samp{-ip12} option when compiling GNU CC
213: with the patched compiler, as shown here:
214:
215: @example
216: make CC="./pcc -ip12" CFLAGS=-w
217: @end example
218:
219: Note also that Alliant's version of DBX does not manage to work with the
220: output from GNU CC.
221: @end ignore
222:
223: @item i386-*-sco
224: Compilation with RCC is recommended, but it produces lots of spurious
225: warnings. They do not necessarily indicate that anything is wrong.
226:
227: @item i386-sequent
228: Go to the Berkeley universe before compiling. In addition, you probably
229: need to create a file named @file{string.h} containing just one line:
230: @samp{#include <strings.h>}.
231:
232: @item m68000-att
233: AT&T 3b1, a.k.a. 7300 PC. Special procedures are needed to compile GNU
234: CC with this machine's standard C compiler, due to bugs in that
235: compiler. @xref{3b1 Install}. You can bootstrap it more easily with
236: previous versions of GNU CC if you have them.
237:
238: @item m68000-hp-bsd
239: HP 9000 series 200 running BSD. Note that the C compiler that comes
240: with this system cannot compile GNU CC; contact @code{law@@cs.utah.edu}
241: to get binaries of GNU CC for bootstrapping.
242:
243: @item m68k-altos
244: Altos 3068. You must use the GNU assembler, linker and debugger, with
245: COFF-encapsulation. Also, you must fix a kernel bug. Details in the
246: file @file{README.ALTOS}.
247:
248: @item m68k-hp-hpux
249: HP 9000 series 300 or 400 running HP-UX. HP-UX version 8.0 has a bug in
250: the assembler that prevents compilation of GNU CC. To fix it, get patch
251: PHCO_0800 from HP.
252:
253: In addition, @samp{--gas} does not currently work with this
254: configuration. Changes in HP-UX have broken the library conversion tool
255: and the linker.
256:
257: @item m68k-sun
258: Sun 3. We do not provide a configuration file to use the Sun FPA by
259: default, because programs that establish signal handlers for floating
260: point traps inherently cannot work with the FPA.
261:
262: @item m88k-svr3
263: Motorola m88k running the AT&T/Unisoft/Motorla V.3 reference port.
264: These systems tend to use the Green Hills C, revision 1.8.5, as the
265: standard C compiler. There are apparently bugs in this compiler that
266: result in object files differences between stage 2 and stage 3. If this
267: happens, make the stage 4 compiler and compare it to the stage 3
268: compiler. If the stage 3 and stage 4 object files are identical, this
269: suggests a problem with the standard C compiler. It is best, however,
270: to use an older version of GNU CC for bootstrapping.
271:
272: @item m88k-dgux
273: Motorola m88k running DG/UX. To build native or cross compilers on
274: DG/UX, you must first change to the 88open BCS software development
275: environment. This is done by issuing this command:
276:
277: @example
278: eval `sde-target m88kbcs`
279: @end example
280:
281: @item mips-mips-bsd
282: MIPS machines running the MIPS operating system in BSD mode. It's
283: possible that some old versions of the system lack the functions
284: @code{memcpy}, @code{memcmp}, and @code{memset}. If your system lacks
285: these, you must remove or undo the definition of
286: @code{TARGET_MEM_FUNCTIONS} in @file{mips-bsd.h}.
287:
288: @item mips-sony-sysv
289: Sony MIPS NEWS. This works in NEWSOS 5.0.1, but not in 5.0.2 (which
290: uses ELF instead of COFF). Support for 5.0.2 will probably be provided
291: soon by volunteers.
292:
293: @item ns32k-encore
294: Encore ns32000 system. Encore systems are supported only under BSD.
295:
296: @item ns32k-*-genix
297: National Semiconductor ns32000 system. Genix has bugs in @code{alloca}
298: and @code{malloc}; you must get the compiled versions of these from GNU
299: Emacs.
300:
301: @item ns32k-sequent
302: Go to the Berkeley universe before compiling. In addition, you probably
303: need to create a file named @file{string.h} containing just one line:
304: @samp{#include <strings.h>}.
305:
306: @item ns32k-utek
307: UTEK ns32000 system (``merlin''). The C compiler that comes with this
308: system cannot compile GNU CC; contact @samp{tektronix!reed!mason} to get
309: binaries of GNU CC for bootstrapping.
310:
311: @item romp-*-aos
312: @itemx romp-*-mach
313: The only operating systems supported for the IBM RT PC are AOS and
314: MACH. GNU CC does not support AIX running on the RT.
315:
316: @item rs6000-*-aix
317: Read the file @file{README.RS6000} for information on how to get a fix
318: for a problem in the IBM assembler that prevents use of GNU CC.
319:
320: @item vax-dec-ultrix
321: Don't try compiling with Vax C (@code{vcc}). It produces incorrect code
322: in some cases (for example, when @code{alloca} is used).
323:
324: Meanwhile, compiling @file{cp-parse.c} with pcc does not work because of
325: an internal table size limitation in that compiler. To avoid this
326: problem, compile just the GNU C compiler first, and use it to recompile
327: building all the languages that you want to run.
328:
329: @item we32k-att-sysv
330: Don't use @samp{-g} when compiling GNU CC. The system's linker seems to
331: be unable to handle such a large program with debugging information.
332: @end table
333:
334: Here we spell out what files will be set up by @code{configure}. Normally
335: you need not be concerned with these files.
336:
337: @itemize @bullet
338: @item
339: @ifset INTERNALS
340: A symbolic link named @file{config.h} is made to the top-level config
341: file for the machine you will run the compiler on (@pxref{Config}).
342: This file is responsible for defining information about the host
343: machine. It includes @file{tm.h}.
344: @end ifset
345: @ifclear INTERNALS
346: A symbolic link named @file{config.h} is made to the top-level config
347: file for the machine you plan to run the compiler on (@pxref{Config,,The
348: Configuration File, gcc.info, Using and Porting GCC}). This file is
349: responsible for defining information about the host machine. It
350: includes @file{tm.h}.
351: @end ifclear
352:
353: The top-level config file is located in the subdirectory @file{config}.
354: Its name is always @file{xm-@var{something}.h}; usually
355: @file{xm-@var{machine}.h}, but there are some exceptions.
356:
357: If your system does not support symbolic links, you might want to
358: set up @file{config.h} to contain a @samp{#include} command which
359: refers to the appropriate file.
360:
361: @item
362: A symbolic link named @file{tconfig.h} is made to the top-level config
363: file for your target machine. This is used for compiling certain
364: programs to run on that machine.
365:
366: @item
367: A symbolic link named @file{tm.h} is made to the machine-description
368: macro file for your target machine. It should be in the subdirectory
369: @file{config} and its name is often @file{@var{machine}.h}.
370:
371: @item
372: A symbolic link named @file{md} will be made to the machine description
373: pattern file. It should be in the @file{config} subdirectory and its
374: name should be @file{@var{machine}.md}; but @var{machine} is often not
375: the same as the name used in the @file{tm.h} file because the
376: @file{md} files are more general.
377:
378: @item
379: A symbolic link named @file{aux-output.c} will be made to the output
380: subroutine file for your machine. It should be in the @file{config}
381: subdirectory and its name should be @file{@var{machine}.c}.
382:
383: @item
384: The command file @file{configure} also constructs @file{Makefile} by
385: adding some text to the template file @file{Makefile.in}. The
386: additional text comes from files in the @file{config} directory, named
387: @file{t-@var{target}} and @file{h-@var{host}}. If these files do not
388: exist, it means nothing needs to be added for a given target or host.
389: @end itemize
390:
391: @cindex Bison parser generator
392: @cindex parser generator, Bison
393: @item
394: Make sure the Bison parser generator is installed. (This is
395: unnecessary if the Bison output files @file{c-parse.c} and
396: @file{cexp.c} are more recent than @file{c-parse.y} and @file{cexp.y}
397: and you do not plan to change the @samp{.y} files.)
398:
399: Bison versions older than Sept 8, 1988 will produce incorrect output
400: for @file{c-parse.c}.
401:
402: @item
403: Build the compiler. Just type @samp{make LANGUAGES=c} in the compiler
404: directory.
405:
406: @samp{LANGUAGES=c} specifies that only the C compiler should be
407: compiled. The makefile normally builds compilers for all the supported
408: languages; currently, C, C++ and Objective C. However, C is the only
409: language that is sure to work when you build with other non-GNU C
410: compilers. In addition, building anything but C at this stage is a
411: waste of time.
412:
413: In general, you can specify the languages to build by typing the
414: argument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or more
415: words from the list @samp{c}, @samp{c++}, and @samp{objective-c}.
416:
417: Ignore any warnings you may see about ``statement not reached'' in
418: @file{insn-emit.c}; they are normal. Any other compilation errors may
419: represent bugs in the port to your machine or operating system, and
420: @ifclear INSTALLONLY
421: should be investigated and reported (@pxref{Bugs}).
422: @end ifclear
423: @ifset INSTALLONLY
424: should be investigated and reported.
425: @end ifset
426:
427: Some commercial compilers fail to compile GNU CC because they have bugs
428: or limitations. For example, the Microsoft compiler is said to run out
429: of macro space. Some Ultrix compilers run out of expression space; then
430: you need to break up the statement where the problem happens.
431:
432: If you are building with a previous GNU C compiler, do not
433: use @samp{CC=gcc} on the make command or by editing the Makefile.
434: Instead, use a full pathname to specify the compiler, such as
435: @samp{CC=/usr/local/bin/gcc}. This is because make might execute
436: the @file{gcc} in the current directory before all of the
437: compiler components have been built.
438:
439: @item
440: If you are using COFF-encapsulation, you must convert @file{libgcc.a} to
441: a GNU-format library at this point. See the file @file{README.ENCAP}
442: in the directory containing the GNU binary file utilities, for
443: directions.
444:
445: @item
446: If you are building a cross-compiler, stop here. @xref{Cross-Compiler}.
447:
448: @cindex stage1
449: @item
450: Move the first-stage object files and executables into a subdirectory
451: with this command:
452:
453: @example
454: make stage1
455: @end example
456:
457: The files are moved into a subdirectory named @file{stage1}.
458: Once installation is complete, you may wish to delete these files
459: with @code{rm -r stage1}.
460:
461: @item
462: Recompile the compiler with itself, with this command:
463:
464: @example
465: make CC="stage1/gcc -Bstage1/" CFLAGS="-g -O"
466: @end example
467:
468: This is called making the stage 2 compiler.
469:
470: The command shown above builds compilers for all the supported
471: languages. If you don't want them all, you can specify the languages to
472: build by typing the argument @samp{LANGUAGES="@var{list}"}. @var{list}
473: should contain one or more words from the list @samp{c}, @samp{c++},
474: @samp{objective-c}, and @samp{proto}. Separate the words with spaces.
475: @samp{proto} stands for the programs @code{protoize} and
476: @code{unprotoize}; they are not a separate language, but you use
477: @code{LANGUAGES} to enable or disable their installation.
478:
479: If you are going to build the stage 3 compiler, then you might want to
480: build only the C language in stage 2.
481:
482: Once you have built the stage 2 compiler, if you are short of disk
483: space, you can delete the subdirectory @file{stage1}.
484:
485: On a 68000 or 68020 system lacking floating point hardware,
486: unless you have selected a @file{tm.h} file that expects by default
487: that there is no such hardware, do this instead:
488:
489: @example
490: make CC="stage1/gcc -Bstage1/" CFLAGS="-g -O -msoft-float"
491: @end example
492:
493: @item
494: If you wish to test the compiler by compiling it with itself one more
495: time, do this:
496:
497: @example
498: make stage2
499: make CC="stage2/gcc -Bstage2/" CFLAGS="-g -O"
500: @end example
501:
502: @noindent
503: This is called making the stage 3 compiler. Aside from the @samp{-B}
504: option, the options should be the same as when you made the stage 2
505: compiler.
506:
507: The command shown above builds compilers for all the supported
508: languages. If you don't want them all, you can specify the languages to
509: build by typing the argument @samp{LANGUAGES="@var{list}"}, as described
510: above.
511:
512: Then compare the latest object files with the stage 2 object
513: files---they ought to be identical, unless they contain time stamps.
514: You can compare the files, disregarding the time stamps if any, like
515: this:
516:
517: @example
518: make compare
519: @end example
520:
521: This will mention any object files that differ between stage 2 and stage
522: 3. Any difference, no matter how innocuous, indicates that the stage 2
523: compiler has compiled GNU CC incorrectly, and is therefore a potentially
524: @ifclear INSTALLONLY
525: serious bug which you should investigate and report (@pxref{Bugs}).
526: @end ifclear
527: @ifset INSTALLONLY
528: serious bug which you should investigate and report.
529: @end ifset
530:
531: If your system does not put time stamps in the object files, then this
532: is a faster way to compare them (using the Bourne shell):
533:
534: @example
535: for file in *.o; do
536: cmp $file stage2/$file
537: done
538: @end example
539:
540: If you have built the compiler with the @samp{-mno-mips-tfile} option on
541: MIPS machines, you will not be able to compare the files.
542:
543: @item
544: Install the compiler driver, the compiler's passes and run-time support.
545: You can use the following command:
546:
547: @example
548: make CC="stage2/gcc -Bstage2/" CFLAGS="-g -O" install LANGUAGES="@var{list}"
549: @end example
550:
551: @noindent
552: (Use the same value for @code{CC}, @code{CFLAGS} and @code{LANGUAGES}
553: that you used when compiling the files that are being installed. One
554: reason this is necessary is that some versions of Make have bugs and
555: recompile files gratuitously when you do this step. If you use the same
556: variable values, those files will be recompiled properly.
557:
558: This copies the files @file{cc1}, @file{cpp} and @file{libgcc.a} to files
559: @file{cc1}, @file{cpp} and @file{libgcc.a} in directory
560: @file{/usr/local/lib/gcc-lib/@var{target}/@var{version}}, which is where the
561: compiler driver program looks for them. Here @var{target} is the target
562: machine type specified when you ran @file{configure}, and @var{version}
563: is the version number of GNU CC. This naming scheme permits various
564: versions and/or cross-compilers to coexist.
565:
566: It also copies the driver program @file{gcc} into the directory
567: @file{/usr/local/bin}, so that it appears in typical execution search
568: paths.@refill
569:
570: On some systems, this command will cause recompilation of some files.
571: This is usually due to bugs in @code{make}. You should either ignore
572: this problem, or use GNU Make.
573:
574: @cindex @code{alloca} and SunOs
575: @strong{Warning: there is a bug in @code{alloca} in the Sun library. To
576: avoid this bug, be sure to install the executables of GNU CC that were
577: compiled by GNU CC. (That is, the executables from stage 2 or 3, not
578: stage 1.) They use @code{alloca} as a built-in function and never the
579: one in the library.}
580:
581: (It is usually better to install GNU CC executables from stage 2 or 3,
582: since they usually run faster than the ones compiled with some other
583: compiler.)
584:
585: @item
586: Correct errors in the header files on your machine.
587:
588: Various system header files often contain constructs which are
589: incompatible with ANSI C, and they will not work when you compile
590: programs with GNU CC. This behavior consists of substituting for macro
591: argument names when they appear inside of character constants. The most
592: common offender is @file{ioctl.h}.
593:
594: You can overcome this problem when you compile by specifying the
595: @samp{-traditional} option.
596:
597: Alternatively, on Sun systems and 4.3BSD at least, you can correct the
598: include files by running the shell script @file{fixincludes}. This
599: installs modified, corrected copies of the files @file{ioctl.h},
600: @file{ttychars.h} and many others, in a special directory where only
601: GNU CC will normally look for them. This script will work on various
602: systems because it chooses the files by searching all the system
603: headers for the problem cases that we know about.
604:
605: Use the following command to do this:
606:
607: @example
608: make install-fixincludes
609: @end example
610:
611: @noindent
612: If you selected a different directory for GNU CC installation when you
613: installed it, by specifying the Make variable @code{prefix} or
614: @code{libdir}, specify it the same way in this command.
615:
616: Note that some systems are starting to come with ANSI C system header
617: files. On these systems, don't run @file{fixincludes}; it may not work,
618: and is certainly not necessary.
619: @end enumerate
620:
621: If you cannot install the compiler's passes and run-time support in
622: @file{/usr/local/lib}, you can alternatively use the @samp{-B} option to
623: specify a prefix by which they may be found. The compiler concatenates
624: the prefix with the names @file{cpp}, @file{cc1} and @file{libgcc.a}.
625: Thus, you can put the files in a directory @file{/usr/foo/gcc} and
626: specify @samp{-B/usr/foo/gcc/} when you run GNU CC.
627:
628: Also, you can specify an alternative default directory for these files
629: by setting the Make variable @code{libdir} when you make GNU CC.
630:
631: @node Other Dir
632: @section Compilation in a Separate Directory
633: @cindex other directory, compilation in
634: @cindex compilation in a separate directory
635: @cindex separate directory, compilation in
636:
637: If you wish to build the object files and executables in a directory
638: other than the one containing the source files, here is what you must
639: do differently:
640:
641: @enumerate
642: @item
643: Make sure you have a version of Make that supports the @code{VPATH}
644: feature. (GNU Make supports it, as do Make versions on most BSD
645: systems.)
646:
647: @item
648: If you have ever run @file{configure} in the source directory, you must undo
649: the configuration. Do this by running:
650:
651: @example
652: make distclean
653: @end example
654:
655: @item
656: Go to the directory in which you want to build the compiler before
657: running @file{configure}:
658:
659: @example
660: mkdir gcc-sun3
661: cd gcc-sun3
662: @end example
663:
664: On systems that do not support symbolic links, this directory must be
665: on the same file system as the source code directory.
666:
667: @item
668: Specify where to find @file{configure} when you run it:
669:
670: @example
671: ../gcc/configure @dots{}
672: @end example
673:
674: This also tells @code{configure} where to find the compiler sources;
675: @code{configure} takes the directory from the file name that was used to
676: invoke it. But if you want to be sure, you can specify the source
677: directory with the @samp{--srcdir} option, like this:
678:
679: @example
680: ../gcc/configure --srcdir=../gcc sun3
681: @end example
682:
683: The directory you specify with @samp{--srcdir} need not be the same
684: as the one that @code{configure} is found in.
685: @end enumerate
686:
687: Now, you can run @code{make} in that directory. You need not repeat the
688: configuration steps shown above, when ordinary source files change. You
689: must, however, run @code{configure} again when the configuration files
690: change, if your system does not support symbolic links.
691:
692: @node Cross-Compiler
693: @section Building and Installing a Cross-Compiler
694: @cindex cross-compiler, installation
695:
696: GNU CC can function as a cross-compiler for many machines, but not all.
697:
698: @itemize @bullet
699: @item
700: Cross-compilers for the Mips as target do not work because the auxiliary
701: programs @file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled
702: on anything but a Mips.
703:
704: @item
705: Cross-compilers to or from the Vax probably don't work completely
706: because the Vax uses an incompatible floating point format (not IEEE
707: format).
708: @end itemize
709:
710: Since GNU CC generates assembler code, you probably need a
711: cross-assembler that GNU CC can run, in order to produce object files.
712: If you want to link on other than the target machine, you need a
713: cross-linker as well. You also need header files and libraries suitable
714: for the target machine that you can install on the host machine.
715:
716: To build GNU CC as a cross-compiler, you start out by running
717: @code{configure}. You must specify two different configureations, the
718: host and the target. Use the @samp{--host=@var{host}} option for the
719: host and @samp{--target=@var{target}} to specify the target type. For
720: example, here is how to configure for a cross-compiler that runs on a
721: hypothetical Intel 386 system and produces code for an HP 68030 system
722: running BSD:
723:
724: @example
725: configure --target=m68k-hp-bsd4.3 --host=i386-bozotheclone-bsd4.3
726: @end example
727:
728: Next you should install the cross-assembler and cross-linker (and
729: @code{ar} and @code{ranlib}). Put them in the directory
730: @file{/usr/local/@var{target}}. The installation of GNU CC will find
731: them there and copy or link them to the proper place to find them when
732: you run the cross-compiler later.
733:
734: If you want to install any additional libraries to use with the
735: cross-compiler, put them in the directory
736: @file{/usr/local/@var{target}/lib}; all files in that subdirectory will
737: be installed in the proper place when you install the cross-compiler.
738: Likewise, put the header files for the target machine in
739: @file{/usr/local/@var{target}/include}.
740:
741: Then you can proceed just as for compiling a single-machine compiler
742: through the step of building stage 1.
743:
744: When you are using a cross-compiler configuration, building stage 1
745: does not compile all of GNU CC. This is because one part of building,
746: the compilation of @file{libgcc2.c}, requires use of the cross-compiler.
747:
748: However, when you type @samp{make install} to install the bulk of the
749: cross-compiler, that will also compile @file{libgcc2.c} and install the
750: resulting @file{libgcc.a}.
751:
752: You will find it necessary to produce a substitute for @file{libgcc1.a}.
753: Normally this file is compiled with the ``native compiler'' for the
754: target machine; compiling it with GNU CC does not work. But compiling
755: it with the host machine's compiler also doesn't work---that produces a
756: file that would run on the host, and you need it to run on the target.
757:
758: We can't give you any automatic way to produce this substitute. For
759: some targets, the subroutines in @file{libgcc1.c} are not actually used.
760: You need not provide the ones that won't be used. The ones that most
761: commonly are used are the multiplication, division and remainder
762: routines---many RISC machines rely on the library for this. One way to
763: make them work is to define the appropriate @code{perform_@dots{}}
764: macros for the subroutines that you need. If these definitions do not
765: use the C arithmetic operators that they are meant to implement, you
766: might be able to compile them with the cross-compiler you have just
767: built.
768:
769: Do not try to build stage 2 for a cross-compiler. It doesn't work to
770: rebuild GNU CC as a cross-compiler using the cross-compiler, because
771: that would produce a program that runs on the target machine, not on the
772: host. For example, if you compile a 386-to-68030 cross-compiler with
773: itself, the result will not be right either for the 386 (because it was
774: compiled into 68030 code) or for the 68030 (because it was configured
775: for a 386 as the host). If you want to compile GNU CC into 68030 code,
776: whether you compile it on a 68030 or with a cross-compiler on a 386, you
777: must specify a 68030 as the host when you configure it.
778:
779: @node PA Install
780: @section Installing GNU CC on the HP Precision Architecture
781:
782: There are two variants of this CPU, called 1.0 and 1.1, which have
783: different machine descriptions. You must use the right one for your
784: machine. All 7@var{nn} machines and 8@var{n}7 machines use 1.1, while
785: all other 8@var{nn} machines use 1.0.
786:
787: The easiest way to handle this problem is to use @samp{configure
788: hp@var{nnn}} or @samp{configure hp@var{nnn}-hpux}, where @var{nnn} is
789: the model number of the machine. Then @file{configure} will figure out
790: if the machine is a 1.0 or 1.1. Use @samp{uname -a} to find out the
791: model number of your machine.
792:
793: @samp{-g} does not work on HP-UX, since that system uses a peculiar
794: debugging format which GNU CC does not know about. There is a
795: preliminary version available of some modified GNU tools including the
796: GDB debugger which do work with GNU CC for debugging. You can get them
797: by anonymous ftp from @code{mancos.cs.utah.edu} in the @samp{dist}
798: subdirectory. You would need to install GAS in the file
799:
800: @example
801: /usr/local/lib/gcc-lib/@var{configuration}/@var{gccversion}/as
802: @end example
803:
804: @noindent
805: where @var{configuration} is the configuration name (perhaps
806: @samp{hp@var{nnn}-hpux}) and @var{gccversion} is the GNU CC version
807: number.
808:
809: If you do this, delete the line
810:
811: @example
812: #undef DBX_DEBUGGING_INFO
813: @end example
814:
815: @noindent
816: from @file{tm.h} before you build GNU CC, to enable generation of
817: debugging information.
818:
819: @node Sun Install
820: @section Installing GNU CC on the Sun
821: @cindex Sun installation
822: @cindex installing GNU CC on the Sun
823:
824: Make sure the environment variable @code{FLOAT_OPTION} is not set when
825: you compile @file{libgcc.a}. If this option were set to @code{f68881}
826: when @file{libgcc.a} is compiled, the resulting code would demand to be
827: linked with a special startup file and would not link properly without
828: special pains.
829:
830: @cindex @code{alloca}, for SunOs
831: There is a bug in @code{alloca} in certain versions of the Sun library.
832: To avoid this bug, install the binaries of GNU CC that were compiled by
833: GNU CC. They use @code{alloca} as a built-in function and never the one
834: in the library.
835:
836: Some versions of the Sun compiler crash when compiling GNU CC. The
837: problem is a segmentation fault in cpp. This problem seems to be due to
838: the bulk of data in the environment variables. You may be able to avoid
839: it by using the following command to compile GNU CC with Sun CC:
840:
841: @example
842: make CC="TERMCAP=x OBJS=x LIBFUNCS=x STAGESTUFF=x cc"
843: @end example
844:
845: @node 3b1 Install
846: @section Installing GNU CC on the 3b1
847: @cindex 3b1 installation
848: @cindex installing GNU CC on the 3b1
849:
850: Installing GNU CC on the 3b1 is difficult if you do not already have
851: GNU CC running, due to bugs in the installed C compiler. However,
852: the following procedure might work. We are unable to test it.
853:
854: @enumerate
855: @item
856: Comment out the @samp{#include "config.h"} line on line 37 of
857: @file{cccp.c} and do @samp{make cpp}. This makes a preliminary version
858: of GNU cpp.
859:
860: @item
861: Save the old @file{/lib/cpp} and copy the preliminary GNU cpp to that
862: file name.
863:
864: @item
865: Undo your change in @file{cccp.c}, or reinstall the original version,
866: and do @samp{make cpp} again.
867:
868: @item
869: Copy this final version of GNU cpp into @file{/lib/cpp}.
870:
871: @findex obstack_free
872: @item
873: Replace every occurrence of @code{obstack_free} in the file
874: @file{tree.c} with @code{_obstack_free}.
875:
876: @item
877: Run @code{make} to get the first-stage GNU CC.
878:
879: @item
880: Reinstall the original version of @file{/lib/cpp}.
881:
882: @item
883: Now you can compile GNU CC with itself and install it in the normal
884: fashion.
885: @end enumerate
886:
887: @node Unos Install
888: @section Installing GNU CC on Unos
889: @cindex Unos installation
890: @cindex installing GNU CC on Unos
891:
892: Use @samp{configure unos} for building on Unos.
893:
894: The Unos assembler is named @code{casm} instead of @code{as}. For some
895: strange reason linking @file{/bin/as} to @file{/bin/casm} changes the
896: behavior, and does not work. So, when installing GNU CC, you should
897: install the following script as @file{as} in the subdirectory where
898: the passes of GCC are installed:
899:
900: @example
901: #!/bin/sh
902: casm $*
903: @end example
904:
905: The default Unos library is named @file{libunos.a} instead of
906: @file{libc.a}. To allow GNU CC to function, either change all
907: references to @samp{-lc} in @file{gcc.c} to @samp{-lunos} or link
908: @file{/lib/libc.a} to @file{/lib/libunos.a}.
909:
910: @cindex @code{alloca}, for Unos
911: When compiling GNU CC with the standard compiler, to overcome bugs in
912: the support of @code{alloca}, do not use @samp{-O} when making stage 2.
913: Then use the stage 2 compiler with @samp{-O} to make the stage 3
914: compiler. This compiler will have the same characteristics as the usual
915: stage 2 compiler on other systems. Use it to make a stage 4 compiler
916: and compare that with stage 3 to verify proper compilation.
917:
918: (Perhaps simply defining @code{ALLOCA} in @file{x-crds} as described in
919: the comments there will make the above paragraph superfluous. Please
920: inform us of whether this works.)
921:
922: Unos uses memory segmentation instead of demand paging, so you will need
923: a lot of memory. 5 Mb is barely enough if no other tasks are running.
924: If linking @file{cc1} fails, try putting the object files into a library
925: and linking from that library.
926:
927: @node VMS Install, , Unos Install, Installation
928: @section Installing GNU CC on VMS
929: @cindex VMS installation
930: @cindex installing GNU CC on VMS
931:
932: The VMS version of GNU CC is distributed in a backup saveset containing
933: both source code and precompiled binaries.
934:
935: To install the @file{gcc} command so you can use the compiler easily, in
936: the same manner as you use the VMS C compiler, you must install the VMS CLD
937: file for GNU CC as follows:
938:
939: @enumerate
940: @item
941: Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
942: to point to the directories where the GNU CC executables
943: (@file{gcc-cpp}, @file{gcc-cc1}, etc.) and the C include files are
944: kept. This should be done with the commands:@refill
945:
946: @smallexample
947: $ assign /system /translation=concealed -
948: disk:[gcc.] gnu_cc
949: $ assign /system /translation=concealed -
950: disk:[gcc.include.] gnu_cc_include
951: @end smallexample
952:
953: @noindent
954: with the appropriate disk and directory names. These commands can be
955: placed in your system startup file so they will be executed whenever
956: the machine is rebooted. You may, if you choose, do this via the
957: @file{GCC_INSTALL.COM} script in the @file{[GCC]} directory.
958:
959: @item
960: Install the @file{GCC} command with the command line:
961:
962: @smallexample
963: $ set command /table=sys$common:[syslib]dcltables -
964: /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
965: $ install replace sys$common:[syslib]dcltables
966: @end smallexample
967:
968: @item
969: To install the help file, do the following:
970:
971: @smallexample
972: $ lib/help sys$library:helplib.hlb gcc.hlp
973: @end smallexample
974:
975: @noindent
976: Now you can invoke the compiler with a command like @samp{gcc /verbose
977: file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
978: Unix.
979: @end enumerate
980:
981: If you wish to use GNU C++ you must first install GNU CC, and then
982: perform the following steps:
983:
984: @enumerate
985: @item
986: Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the
987: directory where the preprocessor will search for the C++ header files.
988: This can be done with the command:@refill
989:
990: @smallexample
991: $ assign /system /translation=concealed -
992: disk:[gcc.gxx_include.] gnu_gxx_include
993: @end smallexample
994:
995: @noindent
996: with the appropriate disk and directory name. If you are going to be
997: using libg++, this is where the libg++ install procedure will install
998: the libg++ header files.
999:
1000: @item
1001: Obtain the file @file{gcc-cc1plus.exe}, and place this in the same
1002: directory that @file{gcc-cc1.exe} is kept.
1003:
1004: The GNU C++ compiler can be invoked with a command like @samp{gcc /plus
1005: /verbose file.cc}, which is equivalent to the command @samp{g++ -v -c
1006: file.cc} in Unix.
1007: @end enumerate
1008:
1009: We try to put corresponding binaries and sources on the VMS distribution
1010: tape. But sometimes the binaries will be from an older version that the
1011: sources, because we don't always have time to update them. (Use the
1012: @samp{/version} option to determine the version number of the binaries and
1013: compare it with the source file @file{version.c} to tell whether this is
1014: so.) In this case, you should use the binaries you get to recompile the
1015: sources. If you must recompile, here is how:
1016:
1017: @enumerate
1018: @item
1019: Copy the file @file{vms.h} to @file{tm.h}, @file{xm-vms.h} to
1020: @file{config.h}, @file{vax.md} to @file{md.} and @file{vax.c}
1021: to @file{aux-output.c}. The files to be copied are found in the
1022: subdirectory named @file{config}; they should be copied to the
1023: main directory of GNU CC. If you wish, you may use the command file
1024: @file{config-gcc.com} to perform these steps for you.@refill
1025:
1026: @item
1027: Setup the logical names and command tables as defined above. In
1028: addition, define the VMS logical name @samp{GNU_BISON} to point at the
1029: to the directories where the Bison executable is kept. This should be
1030: done with the command:@refill
1031:
1032: @smallexample
1033: $ assign /system /translation=concealed -
1034: disk:[bison.] gnu_bison
1035: @end smallexample
1036:
1037: You may, if you choose, use the @file{INSTALL_BISON.COM} script in the
1038: @file{[BISON]} directory.
1039:
1040: @item
1041: Install the @samp{BISON} command with the command line:@refill
1042:
1043: @smallexample
1044: $ set command /table=sys$common:[syslib]dcltables -
1045: /output=sys$common:[syslib]dcltables -
1046: gnu_bison:[000000]bison
1047: $ install replace sys$common:[syslib]dcltables
1048: @end smallexample
1049:
1050: @item
1051: Type @samp{@@make-gcc} to recompile everything (alternatively, you may
1052: submit the file @file{make-gcc.com} to a batch queue). If you wish to
1053: build the GNU C++ compiler as well as the GNU CC compiler, you must
1054: first edit @file{make-gcc.com} and follow the instructions that appear
1055: in the comments.@refill
1056:
1057: @item
1058: In order to use GCC, you need a library of functions which GCC compiled code
1059: will call to perform certain tasks, and these functions are defined in the
1060: file @file{libgcc2.c}. To compile this you should use the command procedure
1061: @file{make-l2.com}, which will generate the library @file{libgcc2.olb}.
1062: @file{libgcc2.olb} should be built using the compiler built from
1063: the same distribution that @file{libgcc2.c} came from, and
1064: @file{make-gcc.com} will automatically do all of this for you.
1065:
1066: To install the library, use the following commands:@refill
1067:
1068: @smallexample
1069: $ lib gnu_cc:[000000]gcclib/delete=(new,eprintf)
1070: $ lib libgcc2/extract=*/output=libgcc2.obj
1071: $ lib gnu_cc:[000000]gcclib libgcc2.obj
1072: @end smallexample
1073:
1074: The first command simply removes old modules that will be replaced with modules
1075: from libgcc2. If the VMS librarian complains about those modules not being
1076: present, simply ignore the message and continue on with the next command.
1077:
1078: Whenever you update the compiler on your system, you should also update the
1079: library with the above procedure.
1080:
1081: You may wish to build GCC in such a way that no files are written to the
1082: directory where the source files reside. An example would be the when
1083: the source files are on a read-only disk. In these cases, execute the
1084: following DCL commands (substituting your actual path names):
1085:
1086: @smallexample
1087: $ assign dua0:[gcc.build_dir.]tran=conc, -
1088: dua1:[gcc.source_dir.]/tran=conc gcc_build
1089: $ set default gcc_build:[000000]
1090: @end smallexample
1091:
1092: where @file{dua1:[gcc.source_dir.]} contains the source code, and
1093: @file{dua0:[gcc.build_dir.]} is meant to contain all of the generated object
1094: files and executables. Once you have done this, you can proceed building GCC
1095: as described above. (Keep in mind that @file{gcc_build} is a rooted logical
1096: name, and thus the device names in each element of the search list must be an
1097: actual physical device name rather than another rooted logical name).
1098:
1099: @strong{If you are building GNU CC with a previous version of GNU CC,
1100: you also should check to see that you have the newest version of the
1101: assembler}. In particular, GNU CC version 2 treats global constant
1102: variables slightly differently from GNU CC version 1, and GAS version
1103: 1.38.1 does not have the patches required to work with GCC version 2.
1104: If you use GAS 1.38.1, then @code{extern const} variables will not have
1105: the read-only bit set, and the linker will generate warning messages
1106: about mismatched psect attributes for these variables. These warning
1107: messages are merely a nuisance, and can safely be ignored.
1108:
1109: If you are compiling with a version of GNU CC older than 1.33, specify
1110: @samp{/DEFINE=("inline=")} as an option in all the compilations. This
1111: requires editing all the @code{gcc} commands in @file{make-cc1.com}.
1112: (The older versions had problems supporting @code{inline}.) Once you
1113: have a working 1.33 or newer GNU CC, you can change this file back.
1114: @end enumerate
1115:
1116: Under previous versions of GNU CC, the generated code would occasionally
1117: give strange results when linked to the sharable @file{VAXCRTL} library.
1118: Now this should work.
1119:
1120: Even with this version, however, GNU CC itself should not be linked to
1121: the sharable @file{VAXCRTL}. The @code{qsort} routine supplied with
1122: @file{VAXCRTL} has a bug which can cause a compiler crash.
1123:
1124: Similarly, the preprocessor should not be linked to the sharable
1125: @file{VAXCRTL}. The @code{strncat} routine supplied with @file{VAXCRTL}
1126: has a bug which can cause the preprocessor to go into an infinite loop.
1127:
1128: If you attempt to link to the sharable @file{VAXCRTL}, the VMS linker
1129: will strongly resist any effort to force it to use the @code{qsort} and
1130: @code{strncat} routines from @file{gcclib}. Until the bugs in
1131: @file{VAXCRTL} have been fixed, linking any of the compiler components
1132: to the sharable VAXCRTL is not recommended. (These routines can be
1133: bypassed by placing duplicate copies of @code{qsort} and @code{strncat}
1134: in @file{gcclib} under different names, and patching the compiler
1135: sources to use these routines). Both of the bugs in @file{VAXCRTL} are
1136: still present in VMS version 5.4-1, which is the most recent version as
1137: of this writing.
1138:
1139: The executables that are generated by @file{make-cc1.com} and
1140: @file{make-cccp.com} use the nonshared version of @file{VAXCRTL} (and
1141: thus use the @code{qsort} and @code{strncat} routines from
1142: @file{gcclib.olb}).
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.