]>
Commit | Line | Data |
---|---|---|
5c25e11d | 1 | @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
2284f91b DE |
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 | ||
99bdaa68 JM |
8 | Note most of this information is out of date and superseded by the |
9 | online GCC install procedures @uref{http://gcc.gnu.org/install/}. It is | |
10 | provided for historical reference only. | |
f2d76545 | 11 | |
2284f91b DE |
12 | @ifclear INSTALLONLY |
13 | @node Installation | |
14 | @chapter Installing GNU CC | |
15 | @end ifclear | |
16 | @cindex installing GNU CC | |
17 | ||
18 | @menu | |
ab87f8c8 | 19 | * Configuration Files:: Files created by running @code{configure}. |
2284f91b DE |
20 | * Configurations:: Configurations Supported by GNU CC. |
21 | * Other Dir:: Compiling in a separate directory (not where the source is). | |
22 | * Cross-Compiler:: Building and installing a cross-compiler. | |
2284f91b DE |
23 | * VMS Install:: See below for installation on VMS. |
24 | * Collect2:: How @code{collect2} works; how it finds @code{ld}. | |
25 | * Header Dirs:: Understanding the standard header file directories. | |
26 | @end menu | |
27 | ||
ab87f8c8 JL |
28 | Here is the procedure for installing GNU CC on a GNU or Unix system. |
29 | See @ref{VMS Install}, for VMS systems. In this section we assume you | |
2284f91b | 30 | compile in the same directory that contains the source files; see |
ab87f8c8 JL |
31 | @ref{Other Dir}, to find out how to compile in a separate directory on |
32 | Unix systems. | |
2284f91b DE |
33 | |
34 | You cannot install GNU C by itself on MSDOS; it will not compile under | |
35 | any MSDOS compiler except itself. You need to get the complete | |
36 | compilation package DJGPP, which includes binaries as well as sources, | |
37 | and includes all the necessary compilation tools and libraries. | |
38 | ||
39 | @enumerate | |
40 | @item | |
41 | If you have built GNU CC previously in the same directory for a | |
42 | different target machine, do @samp{make distclean} to delete all files | |
43 | that might be invalid. One of the files this deletes is | |
44 | @file{Makefile}; if @samp{make distclean} complains that @file{Makefile} | |
45 | does not exist, it probably means that the directory is already suitably | |
46 | clean. | |
47 | ||
48 | @item | |
49 | On a System V release 4 system, make sure @file{/usr/bin} precedes | |
50 | @file{/usr/ucb} in @code{PATH}. The @code{cc} command in | |
51 | @file{/usr/ucb} uses libraries which have bugs. | |
52 | ||
ab87f8c8 JL |
53 | @cindex Bison parser generator |
54 | @cindex parser generator, Bison | |
55 | @item | |
86702e31 ZW |
56 | Make sure the Bison parser generator is installed. (This is unnecessary |
57 | if the Bison output file @file{c-parse.c} is more recent than | |
58 | @file{c-parse.y},and you do not plan to change the @samp{.y} file.) | |
ab87f8c8 JL |
59 | |
60 | Bison versions older than Sept 8, 1988 will produce incorrect output | |
61 | for @file{c-parse.c}. | |
62 | ||
63 | @item | |
64 | If you have chosen a configuration for GNU CC which requires other GNU | |
65 | tools (such as GAS or the GNU linker) instead of the standard system | |
66 | tools, install the required tools in the build directory under the names | |
67 | @file{as}, @file{ld} or whatever is appropriate. This will enable the | |
68 | compiler to find the proper tools for compilation of the program | |
69 | @file{enquire}. | |
70 | ||
71 | Alternatively, you can do subsequent compilation using a value of the | |
72 | @code{PATH} environment variable such that the necessary GNU tools come | |
73 | before the standard system tools. | |
74 | ||
2284f91b DE |
75 | @item |
76 | Specify the host, build and target machine configurations. You do this | |
ab87f8c8 | 77 | when you run the @file{configure} script. |
2284f91b DE |
78 | |
79 | The @dfn{build} machine is the system which you are using, the | |
80 | @dfn{host} machine is the system where you want to run the resulting | |
81 | compiler (normally the build machine), and the @dfn{target} machine is | |
82 | the system for which you want the compiler to generate code. | |
83 | ||
84 | If you are building a compiler to produce code for the machine it runs | |
85 | on (a native compiler), you normally do not need to specify any operands | |
86 | to @file{configure}; it will try to guess the type of machine you are on | |
87 | and use that as the build, host and target machines. So you don't need | |
88 | to specify a configuration when building a native compiler unless | |
89 | @file{configure} cannot figure out what your configuration is or guesses | |
90 | wrong. | |
91 | ||
92 | In those cases, specify the build machine's @dfn{configuration name} | |
e5e809f4 JL |
93 | with the @samp{--host} option; the host and target will default to be |
94 | the same as the host machine. (If you are building a cross-compiler, | |
2284f91b DE |
95 | see @ref{Cross-Compiler}.) |
96 | ||
97 | Here is an example: | |
98 | ||
99 | @smallexample | |
f5963e61 | 100 | ./configure --host=sparc-sun-sunos4.1 |
2284f91b DE |
101 | @end smallexample |
102 | ||
103 | A configuration name may be canonical or it may be more or less | |
104 | abbreviated. | |
105 | ||
106 | A canonical configuration name has three parts, separated by dashes. | |
107 | It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}. | |
108 | (The three parts may themselves contain dashes; @file{configure} | |
109 | can figure out which dashes serve which purpose.) For example, | |
110 | @samp{m68k-sun-sunos4.1} specifies a Sun 3. | |
111 | ||
112 | You can also replace parts of the configuration by nicknames or aliases. | |
113 | For example, @samp{sun3} stands for @samp{m68k-sun}, so | |
e954b3d7 | 114 | @samp{sun3-sunos4.1} is another way to specify a Sun 3. |
2284f91b DE |
115 | |
116 | You can specify a version number after any of the system types, and some | |
117 | of the CPU types. In most cases, the version is irrelevant, and will be | |
118 | ignored. So you might as well specify the version if you know it. | |
119 | ||
120 | See @ref{Configurations}, for a list of supported configuration names and | |
121 | notes on many of the configurations. You should check the notes in that | |
122 | section before proceeding any further with the installation of GNU CC. | |
123 | ||
ab87f8c8 JL |
124 | @item |
125 | When running @code{configure}, you may also need to specify certain | |
126 | additional options that describe variant hardware and software | |
127 | configurations. These are @samp{--with-gnu-as}, @samp{--with-gnu-ld}, | |
128 | @samp{--with-stabs} and @samp{--nfp}. | |
2284f91b DE |
129 | |
130 | @table @samp | |
131 | @item --with-gnu-as | |
132 | If you will use GNU CC with the GNU assembler (GAS), you should declare | |
133 | this by using the @samp{--with-gnu-as} option when you run | |
134 | @file{configure}. | |
135 | ||
136 | Using this option does not install GAS. It only modifies the output of | |
137 | GNU CC to work with GAS. Building and installing GAS is up to you. | |
138 | ||
139 | Conversely, if you @emph{do not} wish to use GAS and do not specify | |
140 | @samp{--with-gnu-as} when building GNU CC, it is up to you to make sure | |
141 | that GAS is not installed. GNU CC searches for a program named | |
142 | @code{as} in various directories; if the program it finds is GAS, then | |
143 | it runs GAS. If you are not sure where GNU CC finds the assembler it is | |
144 | using, try specifying @samp{-v} when you run it. | |
145 | ||
146 | The systems where it makes a difference whether you use GAS are@* | |
147 | @samp{hppa1.0-@var{any}-@var{any}}, @samp{hppa1.1-@var{any}-@var{any}}, | |
148 | @samp{i386-@var{any}-sysv}, @samp{i386-@var{any}-isc},@* | |
149 | @samp{i860-@var{any}-bsd}, @samp{m68k-bull-sysv},@* | |
150 | @samp{m68k-hp-hpux}, @samp{m68k-sony-bsd},@* | |
151 | @samp{m68k-altos-sysv}, @samp{m68000-hp-hpux},@* | |
152 | @samp{m68000-att-sysv}, @samp{@var{any}-lynx-lynxos}, | |
153 | and @samp{mips-@var{any}}). | |
154 | On any other system, @samp{--with-gnu-as} has no effect. | |
155 | ||
156 | On the systems listed above (except for the HP-PA, for ISC on the | |
157 | 386, and for @samp{mips-sgi-irix5.*}), if you use GAS, you should also | |
158 | use the GNU linker (and specify @samp{--with-gnu-ld}). | |
159 | ||
160 | @item --with-gnu-ld | |
161 | Specify the option @samp{--with-gnu-ld} if you plan to use the GNU | |
162 | linker with GNU CC. | |
163 | ||
164 | This option does not cause the GNU linker to be installed; it just | |
165 | modifies the behavior of GNU CC to work with the GNU linker. | |
ace62b49 JL |
166 | @c Specifically, it inhibits the installation of @code{collect2}, a program |
167 | @c which otherwise serves as a front-end for the system's linker on most | |
168 | @c configurations. | |
2284f91b DE |
169 | |
170 | @item --with-stabs | |
171 | On MIPS based systems and on Alphas, you must specify whether you want | |
172 | GNU CC to create the normal ECOFF debugging format, or to use BSD-style | |
173 | stabs passed through the ECOFF symbol table. The normal ECOFF debug | |
174 | format cannot fully handle languages other than C. BSD stabs format can | |
175 | handle other languages, but it only works with the GNU debugger GDB. | |
176 | ||
177 | Normally, GNU CC uses the ECOFF debugging format by default; if you | |
178 | prefer BSD stabs, specify @samp{--with-stabs} when you configure GNU | |
179 | CC. | |
180 | ||
181 | No matter which default you choose when you configure GNU CC, the user | |
182 | can use the @samp{-gcoff} and @samp{-gstabs+} options to specify explicitly | |
183 | the debug format for a particular compilation. | |
184 | ||
185 | @samp{--with-stabs} is meaningful on the ISC system on the 386, also, if | |
186 | @samp{--with-gas} is used. It selects use of stabs debugging | |
187 | information embedded in COFF output. This kind of debugging information | |
188 | supports C++ well; ordinary COFF debugging information does not. | |
189 | ||
190 | @samp{--with-stabs} is also meaningful on 386 systems running SVR4. It | |
191 | selects use of stabs debugging information embedded in ELF output. The | |
192 | C++ compiler currently (2.6.0) does not support the DWARF debugging | |
193 | information normally used on 386 SVR4 platforms; stabs provide a | |
194 | workable alternative. This requires gas and gdb, as the normal SVR4 | |
195 | tools can not generate or interpret stabs. | |
196 | ||
197 | @item --nfp | |
198 | On certain systems, you must specify whether the machine has a floating | |
199 | point unit. These systems include @samp{m68k-sun-sunos@var{n}} and | |
200 | @samp{m68k-isi-bsd}. On any other system, @samp{--nfp} currently has no | |
201 | effect, though perhaps there are other systems where it could usefully | |
202 | make a difference. | |
203 | ||
9ec36da5 JL |
204 | @cindex Internal Compiler Checking |
205 | @item --enable-checking | |
206 | When you specify this option, the compiler is built to perform checking | |
207 | of tree node types when referencing fields of that node. This does not | |
208 | change the generated code, but adds error checking within the compiler. | |
209 | This will slow down the compiler and may only work properly if you | |
210 | are building the compiler with GNU C. | |
2284f91b | 211 | |
ab87f8c8 JL |
212 | @cindex Native Language Support |
213 | @cindex NLS | |
214 | @item --enable-nls | |
215 | @itemx --disable-nls | |
216 | The @samp{--enable-nls} option enables Native Language Support (NLS), | |
217 | which lets GCC output diagnostics in languages other than American | |
ebb48a4d | 218 | English. Native Language Support is enabled by default if not doing a |
69fe169e | 219 | canadian cross build. The @samp{--disable-nls} option disables NLS. |
ab87f8c8 JL |
220 | |
221 | @cindex @code{gettext} | |
222 | @item --with-included-gettext | |
69fe169e PT |
223 | If NLS is enbled, the @samp{--with-included-gettext} option causes the build |
224 | procedure to prefer its copy of GNU @code{gettext}. This is the default. If | |
225 | you want the GCC build procedure to prefer the host's @code{gettext} | |
226 | libraries, use @samp{--without-included-gettext}. | |
ab87f8c8 JL |
227 | |
228 | @cindex @code{catgets} | |
229 | @item --with-catgets | |
230 | If NLS is enabled, and if the host lacks @code{gettext} but has the | |
231 | inferior @code{catgets} interface, the GCC build procedure normally | |
232 | ignores @code{catgets} and instead uses GCC's copy of the GNU | |
233 | @code{gettext} library. The @samp{--with-catgets} option causes the | |
234 | build procedure to use the host's @code{catgets} in this situation. | |
f4ab28e3 MK |
235 | |
236 | @cindex Windows32 Registry support | |
237 | @item --enable-win32-registry | |
238 | @itemx --enable-win32-registry=@var{KEY} | |
239 | @itemx --disable-win32-registry | |
240 | The @samp{--enable-win32-registry} option enables Windows-hosted GCC | |
241 | to look up installations paths in the registry using the following key: | |
242 | ||
243 | @smallexample | |
244 | @code{HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\<KEY>} | |
245 | @end smallexample | |
246 | ||
247 | <KEY> defaults to GCC version number, and can be overridden by the | |
248 | @code{--enable-win32-registry=KEY} option. Vendors and distributors | |
249 | who use custom installers are encouraged to provide a different key, | |
250 | perhaps one comprised of vendor name and GCC version number, to | |
251 | avoid conflict with existing installations. This feature is enabled | |
252 | by default, and can be disabled by @code{--disable-win32-registry} | |
253 | option. This option has no effect on the other hosts. | |
ab87f8c8 JL |
254 | @end table |
255 | ||
2284f91b DE |
256 | @item |
257 | Build the compiler. Just type @samp{make LANGUAGES=c} in the compiler | |
258 | directory. | |
259 | ||
260 | @samp{LANGUAGES=c} specifies that only the C compiler should be | |
261 | compiled. The makefile normally builds compilers for all the supported | |
669ed2b1 UD |
262 | languages; currently, C, C++, Objective C, Java, FORTRAN, and CHILL. |
263 | However, C is the only language that is sure to work when you build with | |
264 | other non-GNU C compilers. In addition, building anything but C at this | |
265 | stage is a waste of time. | |
2284f91b DE |
266 | |
267 | In general, you can specify the languages to build by typing the | |
268 | argument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or more | |
669ed2b1 UD |
269 | words from the list @samp{c}, @samp{c++}, @samp{objective-c}, |
270 | @samp{java}, @samp{f77}, and @samp{CHILL}. If you have any additional | |
271 | GNU compilers as subdirectories of the GNU CC source directory, you may | |
272 | also specify their names in this list. | |
2284f91b DE |
273 | |
274 | Ignore any warnings you may see about ``statement not reached'' in | |
275 | @file{insn-emit.c}; they are normal. Also, warnings about ``unknown | |
276 | escape sequence'' are normal in @file{genopinit.c} and perhaps some | |
277 | other files. Likewise, you should ignore warnings about ``constant is | |
278 | so large that it is unsigned'' in @file{insn-emit.c} and | |
86702e31 ZW |
279 | @file{insn-recog.c}, and a warning about a comparison always being zero |
280 | in @file{enquire.o}. Any other compilation errors may represent bugs in | |
2284f91b DE |
281 | the port to your machine or operating system, and |
282 | @ifclear INSTALLONLY | |
283 | should be investigated and reported (@pxref{Bugs}). | |
284 | @end ifclear | |
285 | @ifset INSTALLONLY | |
286 | should be investigated and reported. | |
287 | @end ifset | |
288 | ||
ab87f8c8 JL |
289 | Some compilers fail to compile GNU CC because they have bugs or |
290 | limitations. For example, the Microsoft compiler is said to run out of | |
291 | macro space. Some Ultrix compilers run out of expression space; then | |
2284f91b DE |
292 | you need to break up the statement where the problem happens. |
293 | ||
294 | @item | |
295 | If you are building a cross-compiler, stop here. @xref{Cross-Compiler}. | |
296 | ||
297 | @cindex stage1 | |
298 | @item | |
299 | Move the first-stage object files and executables into a subdirectory | |
300 | with this command: | |
301 | ||
302 | @smallexample | |
303 | make stage1 | |
304 | @end smallexample | |
305 | ||
306 | The files are moved into a subdirectory named @file{stage1}. | |
307 | Once installation is complete, you may wish to delete these files | |
308 | with @code{rm -r stage1}. | |
309 | ||
310 | @item | |
311 | If you have chosen a configuration for GNU CC which requires other GNU | |
312 | tools (such as GAS or the GNU linker) instead of the standard system | |
313 | tools, install the required tools in the @file{stage1} subdirectory | |
314 | under the names @file{as}, @file{ld} or whatever is appropriate. This | |
315 | will enable the stage 1 compiler to find the proper tools in the | |
316 | following stage. | |
317 | ||
318 | Alternatively, you can do subsequent compilation using a value of the | |
319 | @code{PATH} environment variable such that the necessary GNU tools come | |
320 | before the standard system tools. | |
321 | ||
322 | @item | |
323 | Recompile the compiler with itself, with this command: | |
324 | ||
325 | @smallexample | |
326 | make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2" | |
327 | @end smallexample | |
328 | ||
329 | This is called making the stage 2 compiler. | |
330 | ||
331 | The command shown above builds compilers for all the supported | |
332 | languages. If you don't want them all, you can specify the languages to | |
333 | build by typing the argument @samp{LANGUAGES="@var{list}"}. @var{list} | |
334 | should contain one or more words from the list @samp{c}, @samp{c++}, | |
335 | @samp{objective-c}, and @samp{proto}. Separate the words with spaces. | |
336 | @samp{proto} stands for the programs @code{protoize} and | |
337 | @code{unprotoize}; they are not a separate language, but you use | |
338 | @code{LANGUAGES} to enable or disable their installation. | |
339 | ||
340 | If you are going to build the stage 3 compiler, then you might want to | |
341 | build only the C language in stage 2. | |
342 | ||
343 | Once you have built the stage 2 compiler, if you are short of disk | |
344 | space, you can delete the subdirectory @file{stage1}. | |
345 | ||
346 | On a 68000 or 68020 system lacking floating point hardware, | |
347 | unless you have selected a @file{tm.h} file that expects by default | |
348 | that there is no such hardware, do this instead: | |
349 | ||
350 | @smallexample | |
351 | make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2 -msoft-float" | |
352 | @end smallexample | |
353 | ||
354 | @item | |
355 | If you wish to test the compiler by compiling it with itself one more | |
356 | time, install any other necessary GNU tools (such as GAS or the GNU | |
357 | linker) in the @file{stage2} subdirectory as you did in the | |
358 | @file{stage1} subdirectory, then do this: | |
359 | ||
360 | @smallexample | |
361 | make stage2 | |
362 | make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" | |
363 | @end smallexample | |
364 | ||
365 | @noindent | |
366 | This is called making the stage 3 compiler. Aside from the @samp{-B} | |
367 | option, the compiler options should be the same as when you made the | |
368 | stage 2 compiler. But the @code{LANGUAGES} option need not be the | |
369 | same. The command shown above builds compilers for all the supported | |
370 | languages; if you don't want them all, you can specify the languages to | |
371 | build by typing the argument @samp{LANGUAGES="@var{list}"}, as described | |
372 | above. | |
373 | ||
374 | If you do not have to install any additional GNU tools, you may use the | |
375 | command | |
376 | ||
377 | @smallexample | |
378 | make bootstrap LANGUAGES=@var{language-list} BOOT_CFLAGS=@var{option-list} | |
379 | @end smallexample | |
380 | ||
381 | @noindent | |
382 | instead of making @file{stage1}, @file{stage2}, and performing | |
383 | the two compiler builds. | |
384 | ||
385 | @item | |
ab87f8c8 JL |
386 | Compare the latest object files with the stage 2 object files---they |
387 | ought to be identical, aside from time stamps (if any). | |
2284f91b DE |
388 | |
389 | On some systems, meaningful comparison of object files is impossible; | |
390 | they always appear ``different.'' This is currently true on Solaris and | |
391 | some systems that use ELF object file format. On some versions of Irix | |
392 | on SGI machines and DEC Unix (OSF/1) on Alpha systems, you will not be | |
393 | able to compare the files without specifying @file{-save-temps}; see the | |
394 | description of individual systems above to see if you get comparison | |
395 | failures. You may have similar problems on other systems. | |
396 | ||
397 | Use this command to compare the files: | |
398 | ||
399 | @smallexample | |
400 | make compare | |
401 | @end smallexample | |
402 | ||
403 | This will mention any object files that differ between stage 2 and stage | |
404 | 3. Any difference, no matter how innocuous, indicates that the stage 2 | |
405 | compiler has compiled GNU CC incorrectly, and is therefore a potentially | |
406 | @ifclear INSTALLONLY | |
407 | serious bug which you should investigate and report (@pxref{Bugs}). | |
408 | @end ifclear | |
409 | @ifset INSTALLONLY | |
410 | serious bug which you should investigate and report. | |
411 | @end ifset | |
412 | ||
413 | If your system does not put time stamps in the object files, then this | |
414 | is a faster way to compare them (using the Bourne shell): | |
415 | ||
416 | @smallexample | |
417 | for file in *.o; do | |
418 | cmp $file stage2/$file | |
419 | done | |
420 | @end smallexample | |
421 | ||
422 | If you have built the compiler with the @samp{-mno-mips-tfile} option on | |
423 | MIPS machines, you will not be able to compare the files. | |
424 | ||
425 | @item | |
426 | Install the compiler driver, the compiler's passes and run-time support | |
427 | with @samp{make install}. Use the same value for @code{CC}, | |
428 | @code{CFLAGS} and @code{LANGUAGES} that you used when compiling the | |
429 | files that are being installed. One reason this is necessary is that | |
430 | some versions of Make have bugs and recompile files gratuitously when | |
431 | you do this step. If you use the same variable values, those files will | |
432 | be recompiled properly. | |
433 | ||
434 | For example, if you have built the stage 2 compiler, you can use the | |
435 | following command: | |
436 | ||
437 | @smallexample | |
438 | make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES="@var{list}" | |
439 | @end smallexample | |
440 | ||
441 | @noindent | |
442 | This copies the files @file{cc1}, @file{cpp} and @file{libgcc.a} to | |
443 | files @file{cc1}, @file{cpp} and @file{libgcc.a} in the directory | |
444 | @file{/usr/local/lib/gcc-lib/@var{target}/@var{version}}, which is where | |
445 | the compiler driver program looks for them. Here @var{target} is the | |
e5e809f4 JL |
446 | canonicalized form of target machine type specified when you ran |
447 | @file{configure}, and @var{version} is the version number of GNU CC. | |
448 | This naming scheme permits various versions and/or cross-compilers to | |
449 | coexist. It also copies the executables for compilers for other | |
450 | languages (e.g., @file{cc1plus} for C++) to the same directory. | |
2284f91b DE |
451 | |
452 | This also copies the driver program @file{xgcc} into | |
453 | @file{/usr/local/bin/gcc}, so that it appears in typical execution | |
454 | search paths. It also copies @file{gcc.1} into | |
455 | @file{/usr/local/man/man1} and info pages into @file{/usr/local/info}. | |
456 | ||
457 | On some systems, this command causes recompilation of some files. This | |
458 | is usually due to bugs in @code{make}. You should either ignore this | |
459 | problem, or use GNU Make. | |
460 | ||
2284f91b DE |
461 | (It is usually better to install GNU CC executables from stage 2 or 3, |
462 | since they usually run faster than the ones compiled with some other | |
463 | compiler.) | |
464 | ||
2284f91b DE |
465 | @item |
466 | GNU CC includes a runtime library for Objective-C because it is an | |
467 | integral part of the language. You can find the files associated with | |
468 | the library in the subdirectory @file{objc}. The GNU Objective-C | |
469 | Runtime Library requires header files for the target's C library in | |
470 | order to be compiled,and also requires the header files for the target's | |
471 | thread library if you want thread support. @xref{Cross Headers, | |
472 | Cross-Compilers and Header Files, Cross-Compilers and Header Files}, for | |
473 | discussion about header files issues for cross-compilation. | |
474 | ||
475 | When you run @file{configure}, it picks the appropriate Objective-C | |
476 | thread implementation file for the target platform. In some situations, | |
477 | you may wish to choose a different back-end as some platforms support | |
478 | multiple thread implementations or you may wish to disable thread | |
479 | support completely. You do this by specifying a value for the | |
480 | @var{OBJC_THREAD_FILE} makefile variable on the command line when you | |
481 | run make, for example: | |
482 | ||
483 | @smallexample | |
484 | make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" OBJC_THREAD_FILE=thr-single | |
485 | @end smallexample | |
486 | ||
487 | @noindent | |
488 | Below is a list of the currently available back-ends. | |
489 | ||
490 | @itemize @bullet | |
491 | @item thr-single | |
492 | Disable thread support, should work for all platforms. | |
493 | @item thr-decosf1 | |
494 | DEC OSF/1 thread support. | |
495 | @item thr-irix | |
496 | SGI IRIX thread support. | |
497 | @item thr-mach | |
498 | Generic MACH thread support, known to work on NEXTSTEP. | |
499 | @item thr-os2 | |
500 | IBM OS/2 thread support. | |
501 | @item thr-posix | |
502 | Generix POSIX thread support. | |
503 | @item thr-pthreads | |
504 | PCThreads on Linux-based GNU systems. | |
505 | @item thr-solaris | |
506 | SUN Solaris thread support. | |
507 | @item thr-win32 | |
508 | Microsoft Win32 API thread support. | |
509 | @end itemize | |
510 | @end enumerate | |
511 | ||
ab87f8c8 JL |
512 | @node Configuration Files |
513 | @section Files Created by @code{configure} | |
514 | ||
515 | Here we spell out what files will be set up by @code{configure}. Normally | |
516 | you need not be concerned with these files. | |
517 | ||
518 | @itemize @bullet | |
519 | @item | |
520 | @ifset INTERNALS | |
521 | A file named @file{config.h} is created that contains a @samp{#include} | |
522 | of the top-level config file for the machine you will run the compiler | |
523 | on (@pxref{Config}). This file is responsible for defining information | |
524 | about the host machine. It includes @file{tm.h}. | |
525 | @end ifset | |
526 | @ifclear INTERNALS | |
527 | A file named @file{config.h} is created that contains a @samp{#include} | |
528 | of the top-level config file for the machine you will run the compiler | |
529 | on (@pxref{Config,,The Configuration File, gcc.info, Using and Porting | |
530 | GCC}). This file is responsible for defining information about the host | |
531 | machine. It includes @file{tm.h}. | |
532 | @end ifclear | |
533 | ||
534 | The top-level config file is located in the subdirectory @file{config}. | |
535 | Its name is always @file{xm-@var{something}.h}; usually | |
536 | @file{xm-@var{machine}.h}, but there are some exceptions. | |
537 | ||
538 | If your system does not support symbolic links, you might want to | |
539 | set up @file{config.h} to contain a @samp{#include} command which | |
540 | refers to the appropriate file. | |
541 | ||
542 | @item | |
543 | A file named @file{tconfig.h} is created which includes the top-level config | |
544 | file for your target machine. This is used for compiling certain | |
545 | programs to run on that machine. | |
546 | ||
547 | @item | |
548 | A file named @file{tm.h} is created which includes the | |
549 | machine-description macro file for your target machine. It should be in | |
550 | the subdirectory @file{config} and its name is often | |
551 | @file{@var{machine}.h}. | |
552 | ||
553 | @item | |
554 | The command file @file{configure} also constructs the file | |
555 | @file{Makefile} by adding some text to the template file | |
556 | @file{Makefile.in}. The additional text comes from files in the | |
557 | @file{config} directory, named @file{t-@var{target}} and | |
558 | @file{x-@var{host}}. If these files do not exist, it means nothing | |
559 | needs to be added for a given target or host. | |
560 | @end itemize | |
561 | ||
2284f91b DE |
562 | @node Configurations |
563 | @section Configurations Supported by GNU CC | |
564 | @cindex configurations supported by GNU CC | |
565 | ||
566 | Here are the possible CPU types: | |
567 | ||
568 | @quotation | |
55383d87 | 569 | @c gmicro, fx80, spur and tahoe omitted since they don't work. |
052a4b28 | 570 | 1750a, a29k, alpha, arm, avr, c@var{n}, clipper, dsp16xx, elxsi, fr30, h8300, |
55383d87 | 571 | hppa1.0, hppa1.1, i370, i386, i486, i586, i686, i786, i860, i960, m32r, |
2856c3e3 SC |
572 | m68000, m68k, m6811, m6812, m88k, mcore, mips, mipsel, mips64, mips64el, |
573 | mn10200, mn10300, ns32k, pdp11, powerpc, powerpcle, romp, rs6000, sh, sparc, | |
574 | sparclite, sparc64, v850, vax, we32k. | |
2284f91b DE |
575 | @end quotation |
576 | ||
577 | Here are the recognized company names. As you can see, customary | |
578 | abbreviations are used rather than the longer official names. | |
579 | ||
580 | @c What should be done about merlin, tek*, dolphin? | |
581 | @quotation | |
582 | acorn, alliant, altos, apollo, apple, att, bull, | |
583 | cbm, convergent, convex, crds, dec, dg, dolphin, | |
584 | elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi, | |
585 | mips, motorola, ncr, next, ns, omron, plexus, | |
586 | sequent, sgi, sony, sun, tti, unicom, wrs. | |
587 | @end quotation | |
588 | ||
589 | The company name is meaningful only to disambiguate when the rest of | |
590 | the information supplied is insufficient. You can omit it, writing | |
591 | just @samp{@var{cpu}-@var{system}}, if it is not needed. For example, | |
592 | @samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}. | |
593 | ||
594 | Here is a list of system types: | |
595 | ||
596 | @quotation | |
0c82f6bf | 597 | 386bsd, aix, acis, amigaos, aos, aout, aux, bosx, bsd, clix, coff, ctix, cxux, |
57119aa9 ZW |
598 | dgux, dynix, ebmon, ecoff, elf, esix, freebsd, hms, genix, gnu, linux, |
599 | linux-gnu, hiux, hpux, iris, irix, isc, luna, lynxos, mach, minix, msdos, mvs, | |
2284f91b DE |
600 | netbsd, newsos, nindy, ns, osf, osfrose, ptx, riscix, riscos, rtu, sco, sim, |
601 | solaris, sunos, sym, sysv, udi, ultrix, unicos, uniplus, unos, vms, vsta, | |
602 | vxworks, winnt, xenix. | |
603 | @end quotation | |
604 | ||
605 | @noindent | |
606 | You can omit the system type; then @file{configure} guesses the | |
607 | operating system from the CPU and company. | |
608 | ||
609 | You can add a version number to the system type; this may or may not | |
610 | make a difference. For example, you can write @samp{bsd4.3} or | |
611 | @samp{bsd4.4} to distinguish versions of BSD. In practice, the version | |
612 | number is most needed for @samp{sysv3} and @samp{sysv4}, which are often | |
613 | treated differently. | |
614 | ||
f49957d6 JL |
615 | @samp{linux-gnu} is the canonical name for the GNU/Linux target; however |
616 | GNU CC will also accept @samp{linux}. The version of the kernel in use is | |
617 | not relevant on these systems. A suffix such as @samp{libc1} or @samp{aout} | |
618 | distinguishes major versions of the C library; all of the suffixed versions | |
619 | are obsolete. | |
57119aa9 | 620 | |
2284f91b DE |
621 | If you specify an impossible combination such as @samp{i860-dg-vms}, |
622 | then you may get an error message from @file{configure}, or it may | |
623 | ignore part of the information and do the best it can with the rest. | |
624 | @file{configure} always prints the canonical name for the alternative | |
625 | that it used. GNU CC does not support all possible alternatives. | |
626 | ||
627 | Often a particular model of machine has a name. Many machine names are | |
628 | recognized as aliases for CPU/company combinations. Thus, the machine | |
629 | name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}. | |
630 | Sometimes we accept a company name as a machine name, when the name is | |
631 | popularly used for a particular machine. Here is a table of the known | |
632 | machine names: | |
633 | ||
634 | @quotation | |
635 | 3300, 3b1, 3b@var{n}, 7300, altos3068, altos, | |
636 | apollo68, att-7300, balance, | |
637 | convex-c@var{n}, crds, decstation-3100, | |
638 | decstation, delta, encore, | |
639 | fx2800, gmicro, hp7@var{nn}, hp8@var{nn}, | |
640 | hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn}, | |
641 | hp9k8@var{nn}, iris4d, iris, isi68, | |
642 | m3230, magnum, merlin, miniframe, | |
643 | mmax, news-3600, news800, news, next, | |
644 | pbd, pc532, pmax, powerpc, powerpcle, ps2, risc-news, | |
645 | rtpc, sun2, sun386i, sun386, sun3, | |
646 | sun4, symmetry, tower-32, tower. | |
647 | @end quotation | |
648 | ||
649 | @noindent | |
650 | Remember that a machine name specifies both the cpu type and the company | |
651 | name. | |
652 | If you want to install your own homemade configuration files, you can | |
653 | use @samp{local} as the company name to access them. If you use | |
654 | configuration @samp{@var{cpu}-local}, the configuration name | |
655 | without the cpu prefix | |
656 | is used to form the configuration file names. | |
657 | ||
658 | Thus, if you specify @samp{m68k-local}, configuration uses | |
659 | files @file{m68k.md}, @file{local.h}, @file{m68k.c}, | |
660 | @file{xm-local.h}, @file{t-local}, and @file{x-local}, all in the | |
661 | directory @file{config/m68k}. | |
662 | ||
663 | Here is a list of configurations that have special treatment or special | |
664 | things you must know: | |
665 | ||
666 | @table @samp | |
2284f91b DE |
667 | @item vax-dec-vms |
668 | See @ref{VMS Install}, for details on how to install GNU CC on VMS. | |
2284f91b DE |
669 | @end table |
670 | ||
671 | @node Other Dir | |
672 | @section Compilation in a Separate Directory | |
673 | @cindex other directory, compilation in | |
674 | @cindex compilation in a separate directory | |
675 | @cindex separate directory, compilation in | |
676 | ||
677 | If you wish to build the object files and executables in a directory | |
678 | other than the one containing the source files, here is what you must | |
679 | do differently: | |
680 | ||
681 | @enumerate | |
682 | @item | |
683 | Make sure you have a version of Make that supports the @code{VPATH} | |
684 | feature. (GNU Make supports it, as do Make versions on most BSD | |
685 | systems.) | |
686 | ||
687 | @item | |
688 | If you have ever run @file{configure} in the source directory, you must undo | |
689 | the configuration. Do this by running: | |
690 | ||
691 | @example | |
692 | make distclean | |
693 | @end example | |
694 | ||
695 | @item | |
696 | Go to the directory in which you want to build the compiler before | |
697 | running @file{configure}: | |
698 | ||
699 | @example | |
700 | mkdir gcc-sun3 | |
701 | cd gcc-sun3 | |
702 | @end example | |
703 | ||
704 | On systems that do not support symbolic links, this directory must be | |
705 | on the same file system as the source code directory. | |
706 | ||
707 | @item | |
708 | Specify where to find @file{configure} when you run it: | |
709 | ||
710 | @example | |
711 | ../gcc/configure @dots{} | |
712 | @end example | |
713 | ||
714 | This also tells @code{configure} where to find the compiler sources; | |
715 | @code{configure} takes the directory from the file name that was used to | |
716 | invoke it. But if you want to be sure, you can specify the source | |
717 | directory with the @samp{--srcdir} option, like this: | |
718 | ||
719 | @example | |
720 | ../gcc/configure --srcdir=../gcc @var{other options} | |
721 | @end example | |
722 | ||
723 | The directory you specify with @samp{--srcdir} need not be the same | |
724 | as the one that @code{configure} is found in. | |
725 | @end enumerate | |
726 | ||
727 | Now, you can run @code{make} in that directory. You need not repeat the | |
728 | configuration steps shown above, when ordinary source files change. You | |
729 | must, however, run @code{configure} again when the configuration files | |
730 | change, if your system does not support symbolic links. | |
731 | ||
732 | @node Cross-Compiler | |
733 | @section Building and Installing a Cross-Compiler | |
734 | @cindex cross-compiler, installation | |
735 | ||
736 | GNU CC can function as a cross-compiler for many machines, but not all. | |
737 | ||
738 | @itemize @bullet | |
739 | @item | |
740 | Cross-compilers for the Mips as target using the Mips assembler | |
741 | currently do not work, because the auxiliary programs | |
742 | @file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled on | |
743 | anything but a Mips. It does work to cross compile for a Mips | |
744 | if you use the GNU assembler and linker. | |
745 | ||
746 | @item | |
747 | Cross-compilers between machines with different floating point formats | |
748 | have not all been made to work. GNU CC now has a floating point | |
749 | emulator with which these can work, but each target machine description | |
750 | needs to be updated to take advantage of it. | |
751 | ||
752 | @item | |
753 | Cross-compilation between machines of different word sizes is | |
754 | somewhat problematic and sometimes does not work. | |
755 | @end itemize | |
756 | ||
757 | Since GNU CC generates assembler code, you probably need a | |
758 | cross-assembler that GNU CC can run, in order to produce object files. | |
759 | If you want to link on other than the target machine, you need a | |
760 | cross-linker as well. You also need header files and libraries suitable | |
761 | for the target machine that you can install on the host machine. | |
762 | ||
763 | @menu | |
764 | * Steps of Cross:: Using a cross-compiler involves several steps | |
765 | that may be carried out on different machines. | |
766 | * Configure Cross:: Configuring a cross-compiler. | |
767 | * Tools and Libraries:: Where to put the linker and assembler, and the C library. | |
768 | * Cross Headers:: Finding and installing header files | |
769 | for a cross-compiler. | |
2284f91b DE |
770 | * Build Cross:: Actually compiling the cross-compiler. |
771 | @end menu | |
772 | ||
773 | @node Steps of Cross | |
774 | @subsection Steps of Cross-Compilation | |
775 | ||
776 | To compile and run a program using a cross-compiler involves several | |
777 | steps: | |
778 | ||
779 | @itemize @bullet | |
780 | @item | |
781 | Run the cross-compiler on the host machine to produce assembler files | |
782 | for the target machine. This requires header files for the target | |
783 | machine. | |
784 | ||
785 | @item | |
786 | Assemble the files produced by the cross-compiler. You can do this | |
787 | either with an assembler on the target machine, or with a | |
788 | cross-assembler on the host machine. | |
789 | ||
790 | @item | |
791 | Link those files to make an executable. You can do this either with a | |
792 | linker on the target machine, or with a cross-linker on the host | |
793 | machine. Whichever machine you use, you need libraries and certain | |
794 | startup files (typically @file{crt@dots{}.o}) for the target machine. | |
795 | @end itemize | |
796 | ||
797 | It is most convenient to do all of these steps on the same host machine, | |
798 | since then you can do it all with a single invocation of GNU CC. This | |
799 | requires a suitable cross-assembler and cross-linker. For some targets, | |
800 | the GNU assembler and linker are available. | |
801 | ||
802 | @node Configure Cross | |
803 | @subsection Configuring a Cross-Compiler | |
804 | ||
805 | To build GNU CC as a cross-compiler, you start out by running | |
806 | @file{configure}. Use the @samp{--target=@var{target}} to specify the | |
807 | target type. If @file{configure} was unable to correctly identify the | |
808 | system you are running on, also specify the @samp{--build=@var{build}} | |
809 | option. For example, here is how to configure for a cross-compiler that | |
810 | produces code for an HP 68030 system running BSD on a system that | |
811 | @file{configure} can correctly identify: | |
812 | ||
813 | @smallexample | |
814 | ./configure --target=m68k-hp-bsd4.3 | |
815 | @end smallexample | |
816 | ||
817 | @node Tools and Libraries | |
818 | @subsection Tools and Libraries for a Cross-Compiler | |
819 | ||
820 | If you have a cross-assembler and cross-linker available, you should | |
821 | install them now. Put them in the directory | |
822 | @file{/usr/local/@var{target}/bin}. Here is a table of the tools | |
823 | you should put in this directory: | |
824 | ||
825 | @table @file | |
826 | @item as | |
827 | This should be the cross-assembler. | |
828 | ||
829 | @item ld | |
830 | This should be the cross-linker. | |
831 | ||
832 | @item ar | |
833 | This should be the cross-archiver: a program which can manipulate | |
834 | archive files (linker libraries) in the target machine's format. | |
835 | ||
836 | @item ranlib | |
837 | This should be a program to construct a symbol table in an archive file. | |
838 | @end table | |
839 | ||
840 | The installation of GNU CC will find these programs in that directory, | |
841 | and copy or link them to the proper place to for the cross-compiler to | |
842 | find them when run later. | |
843 | ||
844 | The easiest way to provide these files is to build the Binutils package | |
845 | and GAS. Configure them with the same @samp{--host} and @samp{--target} | |
846 | options that you use for configuring GNU CC, then build and install | |
847 | them. They install their executables automatically into the proper | |
848 | directory. Alas, they do not support all the targets that GNU CC | |
849 | supports. | |
850 | ||
851 | If you want to install libraries to use with the cross-compiler, such as | |
852 | a standard C library, put them in the directory | |
853 | @file{/usr/local/@var{target}/lib}; installation of GNU CC copies | |
854 | all the files in that subdirectory into the proper place for GNU CC to | |
855 | find them and link with them. Here's an example of copying some | |
856 | libraries from a target machine: | |
857 | ||
858 | @example | |
859 | ftp @var{target-machine} | |
860 | lcd /usr/local/@var{target}/lib | |
861 | cd /lib | |
862 | get libc.a | |
863 | cd /usr/lib | |
864 | get libg.a | |
865 | get libm.a | |
866 | quit | |
867 | @end example | |
868 | ||
869 | @noindent | |
870 | The precise set of libraries you'll need, and their locations on | |
871 | the target machine, vary depending on its operating system. | |
872 | ||
873 | @cindex start files | |
874 | Many targets require ``start files'' such as @file{crt0.o} and | |
875 | @file{crtn.o} which are linked into each executable; these too should be | |
876 | placed in @file{/usr/local/@var{target}/lib}. There may be several | |
877 | alternatives for @file{crt0.o}, for use with profiling or other | |
878 | compilation options. Check your target's definition of | |
879 | @code{STARTFILE_SPEC} to find out what start files it uses. | |
880 | Here's an example of copying these files from a target machine: | |
881 | ||
882 | @example | |
883 | ftp @var{target-machine} | |
884 | lcd /usr/local/@var{target}/lib | |
885 | prompt | |
886 | cd /lib | |
887 | mget *crt*.o | |
888 | cd /usr/lib | |
889 | mget *crt*.o | |
890 | quit | |
891 | @end example | |
892 | ||
2284f91b DE |
893 | @node Cross Headers |
894 | @subsection Cross-Compilers and Header Files | |
895 | ||
896 | If you are cross-compiling a standalone program or a program for an | |
897 | embedded system, then you may not need any header files except the few | |
898 | that are part of GNU CC (and those of your program). However, if you | |
899 | intend to link your program with a standard C library such as | |
900 | @file{libc.a}, then you probably need to compile with the header files | |
901 | that go with the library you use. | |
902 | ||
903 | The GNU C compiler does not come with these files, because (1) they are | |
904 | system-specific, and (2) they belong in a C library, not in a compiler. | |
905 | ||
906 | If the GNU C library supports your target machine, then you can get the | |
907 | header files from there (assuming you actually use the GNU library when | |
908 | you link your program). | |
909 | ||
910 | If your target machine comes with a C compiler, it probably comes with | |
911 | suitable header files also. If you make these files accessible from the host | |
912 | machine, the cross-compiler can use them also. | |
913 | ||
914 | Otherwise, you're on your own in finding header files to use when | |
915 | cross-compiling. | |
916 | ||
917 | When you have found suitable header files, put them in the directory | |
918 | @file{/usr/local/@var{target}/include}, before building the cross | |
919 | compiler. Then installation will run fixincludes properly and install | |
920 | the corrected versions of the header files where the compiler will use | |
921 | them. | |
922 | ||
923 | Provide the header files before you build the cross-compiler, because | |
924 | the build stage actually runs the cross-compiler to produce parts of | |
925 | @file{libgcc.a}. (These are the parts that @emph{can} be compiled with | |
926 | GNU CC.) Some of them need suitable header files. | |
927 | ||
928 | Here's an example showing how to copy the header files from a target | |
929 | machine. On the target machine, do this: | |
930 | ||
931 | @example | |
932 | (cd /usr/include; tar cf - .) > tarfile | |
933 | @end example | |
934 | ||
935 | Then, on the host machine, do this: | |
936 | ||
937 | @example | |
938 | ftp @var{target-machine} | |
939 | lcd /usr/local/@var{target}/include | |
940 | get tarfile | |
941 | quit | |
942 | tar xf tarfile | |
943 | @end example | |
944 | ||
945 | @node Build Cross | |
946 | @subsection Actually Building the Cross-Compiler | |
947 | ||
948 | Now you can proceed just as for compiling a single-machine compiler | |
7857f134 ZW |
949 | through the step of building stage 1. |
950 | ||
951 | If your target is exotic, you may need to provide the header file | |
952 | @file{float.h}.One way to do this is to compile @file{enquire} and run | |
953 | it on your target machine. The job of @file{enquire} is to run on the | |
954 | target machine and figure out by experiment the nature of its floating | |
955 | point representation. @file{enquire} records its findings in the header | |
956 | file @file{float.h}. If you can't produce this file by running | |
957 | @file{enquire} on the target machine, then you will need to come up with | |
958 | a suitable @file{float.h} in some other way (or else, avoid using it in | |
959 | your programs). | |
2284f91b DE |
960 | |
961 | Do not try to build stage 2 for a cross-compiler. It doesn't work to | |
962 | rebuild GNU CC as a cross-compiler using the cross-compiler, because | |
963 | that would produce a program that runs on the target machine, not on the | |
964 | host. For example, if you compile a 386-to-68030 cross-compiler with | |
965 | itself, the result will not be right either for the 386 (because it was | |
966 | compiled into 68030 code) or for the 68030 (because it was configured | |
967 | for a 386 as the host). If you want to compile GNU CC into 68030 code, | |
968 | whether you compile it on a 68030 or with a cross-compiler on a 386, you | |
969 | must specify a 68030 as the host when you configure it. | |
970 | ||
971 | To install the cross-compiler, use @samp{make install}, as usual. | |
972 | ||
2284f91b DE |
973 | @node VMS Install |
974 | @section Installing GNU CC on VMS | |
975 | @cindex VMS installation | |
976 | @cindex installing GNU CC on VMS | |
977 | ||
978 | The VMS version of GNU CC is distributed in a backup saveset containing | |
979 | both source code and precompiled binaries. | |
980 | ||
981 | To install the @file{gcc} command so you can use the compiler easily, in | |
982 | the same manner as you use the VMS C compiler, you must install the VMS CLD | |
983 | file for GNU CC as follows: | |
984 | ||
985 | @enumerate | |
986 | @item | |
987 | Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE} | |
988 | to point to the directories where the GNU CC executables | |
989 | (@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are | |
990 | kept respectively. This should be done with the commands:@refill | |
991 | ||
992 | @smallexample | |
993 | $ assign /system /translation=concealed - | |
994 | disk:[gcc.] gnu_cc | |
995 | $ assign /system /translation=concealed - | |
996 | disk:[gcc.include.] gnu_cc_include | |
997 | @end smallexample | |
998 | ||
999 | @noindent | |
1000 | with the appropriate disk and directory names. These commands can be | |
1001 | placed in your system startup file so they will be executed whenever | |
1002 | the machine is rebooted. You may, if you choose, do this via the | |
1003 | @file{GCC_INSTALL.COM} script in the @file{[GCC]} directory. | |
1004 | ||
1005 | @item | |
1006 | Install the @file{GCC} command with the command line: | |
1007 | ||
1008 | @smallexample | |
1009 | $ set command /table=sys$common:[syslib]dcltables - | |
1010 | /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc | |
1011 | $ install replace sys$common:[syslib]dcltables | |
1012 | @end smallexample | |
1013 | ||
1014 | @item | |
1015 | To install the help file, do the following: | |
1016 | ||
1017 | @smallexample | |
1018 | $ library/help sys$library:helplib.hlb gcc.hlp | |
1019 | @end smallexample | |
1020 | ||
1021 | @noindent | |
1022 | Now you can invoke the compiler with a command like @samp{gcc /verbose | |
1023 | file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in | |
1024 | Unix. | |
1025 | @end enumerate | |
1026 | ||
1027 | If you wish to use GNU C++ you must first install GNU CC, and then | |
1028 | perform the following steps: | |
1029 | ||
1030 | @enumerate | |
1031 | @item | |
1032 | Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the | |
1033 | directory where the preprocessor will search for the C++ header files. | |
1034 | This can be done with the command:@refill | |
1035 | ||
1036 | @smallexample | |
1037 | $ assign /system /translation=concealed - | |
1038 | disk:[gcc.gxx_include.] gnu_gxx_include | |
1039 | @end smallexample | |
1040 | ||
1041 | @noindent | |
1042 | with the appropriate disk and directory name. If you are going to be | |
c85f7c16 JL |
1043 | using a C++ runtime library, this is where its install procedure will install |
1044 | its header files. | |
2284f91b DE |
1045 | |
1046 | @item | |
1047 | Obtain the file @file{gcc-cc1plus.exe}, and place this in the same | |
1048 | directory that @file{gcc-cc1.exe} is kept. | |
1049 | ||
1050 | The GNU C++ compiler can be invoked with a command like @samp{gcc /plus | |
1051 | /verbose file.cc}, which is equivalent to the command @samp{g++ -v -c | |
1052 | file.cc} in Unix. | |
1053 | @end enumerate | |
1054 | ||
1055 | We try to put corresponding binaries and sources on the VMS distribution | |
1056 | tape. But sometimes the binaries will be from an older version than the | |
1057 | sources, because we don't always have time to update them. (Use the | |
1058 | @samp{/version} option to determine the version number of the binaries and | |
1059 | compare it with the source file @file{version.c} to tell whether this is | |
1060 | so.) In this case, you should use the binaries you get to recompile the | |
1061 | sources. If you must recompile, here is how: | |
1062 | ||
1063 | @enumerate | |
1064 | @item | |
1065 | Execute the command procedure @file{vmsconfig.com} to set up the files | |
1066 | @file{tm.h}, @file{config.h}, @file{aux-output.c}, and @file{md.}, and | |
1067 | to create files @file{tconfig.h} and @file{hconfig.h}. This procedure | |
1068 | also creates several linker option files used by @file{make-cc1.com} and | |
1069 | a data file used by @file{make-l2.com}.@refill | |
1070 | ||
1071 | @smallexample | |
1072 | $ @@vmsconfig.com | |
1073 | @end smallexample | |
1074 | ||
1075 | @item | |
1076 | Setup the logical names and command tables as defined above. In | |
1077 | addition, define the VMS logical name @samp{GNU_BISON} to point at the | |
1078 | to the directories where the Bison executable is kept. This should be | |
1079 | done with the command:@refill | |
1080 | ||
1081 | @smallexample | |
1082 | $ assign /system /translation=concealed - | |
1083 | disk:[bison.] gnu_bison | |
1084 | @end smallexample | |
1085 | ||
1086 | You may, if you choose, use the @file{INSTALL_BISON.COM} script in the | |
1087 | @file{[BISON]} directory. | |
1088 | ||
1089 | @item | |
1090 | Install the @samp{BISON} command with the command line:@refill | |
1091 | ||
1092 | @smallexample | |
1093 | $ set command /table=sys$common:[syslib]dcltables - | |
1094 | /output=sys$common:[syslib]dcltables - | |
1095 | gnu_bison:[000000]bison | |
1096 | $ install replace sys$common:[syslib]dcltables | |
1097 | @end smallexample | |
1098 | ||
1099 | @item | |
1100 | Type @samp{@@make-gcc} to recompile everything (alternatively, submit | |
1101 | the file @file{make-gcc.com} to a batch queue). If you wish to build | |
1102 | the GNU C++ compiler as well as the GNU CC compiler, you must first edit | |
1103 | @file{make-gcc.com} and follow the instructions that appear in the | |
1104 | comments.@refill | |
1105 | ||
1106 | @item | |
1107 | In order to use GCC, you need a library of functions which GCC compiled code | |
1108 | will call to perform certain tasks, and these functions are defined in the | |
1109 | file @file{libgcc2.c}. To compile this you should use the command procedure | |
1110 | @file{make-l2.com}, which will generate the library @file{libgcc2.olb}. | |
1111 | @file{libgcc2.olb} should be built using the compiler built from | |
1112 | the same distribution that @file{libgcc2.c} came from, and | |
1113 | @file{make-gcc.com} will automatically do all of this for you. | |
1114 | ||
1115 | To install the library, use the following commands:@refill | |
1116 | ||
1117 | @smallexample | |
1118 | $ library gnu_cc:[000000]gcclib/delete=(new,eprintf) | |
1119 | $ library gnu_cc:[000000]gcclib/delete=L_* | |
1120 | $ library libgcc2/extract=*/output=libgcc2.obj | |
1121 | $ library gnu_cc:[000000]gcclib libgcc2.obj | |
1122 | @end smallexample | |
1123 | ||
1124 | The first command simply removes old modules that will be replaced with | |
1125 | modules from @file{libgcc2} under different module names. The modules | |
1126 | @code{new} and @code{eprintf} may not actually be present in your | |
1127 | @file{gcclib.olb}---if the VMS librarian complains about those modules | |
1128 | not being present, simply ignore the message and continue on with the | |
1129 | next command. The second command removes the modules that came from the | |
1130 | previous version of the library @file{libgcc2.c}. | |
1131 | ||
1132 | Whenever you update the compiler on your system, you should also update the | |
1133 | library with the above procedure. | |
1134 | ||
1135 | @item | |
1136 | You may wish to build GCC in such a way that no files are written to the | |
1137 | directory where the source files reside. An example would be the when | |
1138 | the source files are on a read-only disk. In these cases, execute the | |
1139 | following DCL commands (substituting your actual path names): | |
1140 | ||
1141 | @smallexample | |
1142 | $ assign dua0:[gcc.build_dir.]/translation=concealed, - | |
1143 | dua1:[gcc.source_dir.]/translation=concealed gcc_build | |
1144 | $ set default gcc_build:[000000] | |
1145 | @end smallexample | |
1146 | ||
1147 | @noindent | |
1148 | where the directory @file{dua1:[gcc.source_dir]} contains the source | |
1149 | code, and the directory @file{dua0:[gcc.build_dir]} is meant to contain | |
1150 | all of the generated object files and executables. Once you have done | |
1151 | this, you can proceed building GCC as described above. (Keep in mind | |
1152 | that @file{gcc_build} is a rooted logical name, and thus the device | |
1153 | names in each element of the search list must be an actual physical | |
1154 | device name rather than another rooted logical name). | |
1155 | ||
1156 | @item | |
1157 | @strong{If you are building GNU CC with a previous version of GNU CC, | |
1158 | you also should check to see that you have the newest version of the | |
1159 | assembler}. In particular, GNU CC version 2 treats global constant | |
1160 | variables slightly differently from GNU CC version 1, and GAS version | |
1161 | 1.38.1 does not have the patches required to work with GCC version 2. | |
1162 | If you use GAS 1.38.1, then @code{extern const} variables will not have | |
1163 | the read-only bit set, and the linker will generate warning messages | |
1164 | about mismatched psect attributes for these variables. These warning | |
1165 | messages are merely a nuisance, and can safely be ignored. | |
1166 | ||
1167 | If you are compiling with a version of GNU CC older than 1.33, specify | |
1168 | @samp{/DEFINE=("inline=")} as an option in all the compilations. This | |
1169 | requires editing all the @code{gcc} commands in @file{make-cc1.com}. | |
1170 | (The older versions had problems supporting @code{inline}.) Once you | |
1171 | have a working 1.33 or newer GNU CC, you can change this file back. | |
1172 | ||
1173 | @item | |
1174 | If you want to build GNU CC with the VAX C compiler, you will need to | |
1175 | make minor changes in @file{make-cccp.com} and @file{make-cc1.com} | |
1176 | to choose alternate definitions of @code{CC}, @code{CFLAGS}, and | |
1177 | @code{LIBS}. See comments in those files. However, you must | |
1178 | also have a working version of the GNU assembler (GNU as, aka GAS) as | |
1179 | it is used as the back-end for GNU CC to produce binary object modules | |
1180 | and is not included in the GNU CC sources. GAS is also needed to | |
1181 | compile @file{libgcc2} in order to build @file{gcclib} (see above); | |
1182 | @file{make-l2.com} expects to be able to find it operational in | |
1183 | @file{gnu_cc:[000000]gnu-as.exe}. | |
1184 | ||
1185 | To use GNU CC on VMS, you need the VMS driver programs | |
1186 | @file{gcc.exe}, @file{gcc.com}, and @file{gcc.cld}. They are | |
1187 | distributed with the VMS binaries (@file{gcc-vms}) rather than the | |
1188 | GNU CC sources. GAS is also included in @file{gcc-vms}, as is Bison. | |
1189 | ||
1190 | Once you have successfully built GNU CC with VAX C, you should use the | |
1191 | resulting compiler to rebuild itself. Before doing this, be sure to | |
1192 | restore the @code{CC}, @code{CFLAGS}, and @code{LIBS} definitions in | |
1193 | @file{make-cccp.com} and @file{make-cc1.com}. The second generation | |
1194 | compiler will be able to take advantage of many optimizations that must | |
1195 | be suppressed when building with other compilers. | |
1196 | @end enumerate | |
1197 | ||
1198 | Under previous versions of GNU CC, the generated code would occasionally | |
1199 | give strange results when linked with the sharable @file{VAXCRTL} library. | |
1200 | Now this should work. | |
1201 | ||
1202 | Even with this version, however, GNU CC itself should not be linked with | |
1203 | the sharable @file{VAXCRTL}. The version of @code{qsort} in | |
1204 | @file{VAXCRTL} has a bug (known to be present in VMS versions V4.6 | |
1205 | through V5.5) which causes the compiler to fail. | |
1206 | ||
1207 | The executables are generated by @file{make-cc1.com} and | |
1208 | @file{make-cccp.com} use the object library version of @file{VAXCRTL} in | |
1209 | order to make use of the @code{qsort} routine in @file{gcclib.olb}. If | |
1210 | you wish to link the compiler executables with the shareable image | |
1211 | version of @file{VAXCRTL}, you should edit the file @file{tm.h} (created | |
1212 | by @file{vmsconfig.com}) to define the macro @code{QSORT_WORKAROUND}. | |
1213 | ||
1214 | @code{QSORT_WORKAROUND} is always defined when GNU CC is compiled with | |
1215 | VAX C, to avoid a problem in case @file{gcclib.olb} is not yet | |
1216 | available. | |
1217 | ||
1218 | @node Collect2 | |
1219 | @section @code{collect2} | |
1220 | ||
23851576 JL |
1221 | GNU CC uses a utility called @code{collect2} on nearly all systems to arrange |
1222 | to call various initialization functions at start time. | |
2284f91b DE |
1223 | |
1224 | The program @code{collect2} works by linking the program once and | |
1225 | looking through the linker output file for symbols with particular names | |
1226 | indicating they are constructor functions. If it finds any, it | |
1227 | creates a new temporary @samp{.c} file containing a table of them, | |
1228 | compiles it, and links the program a second time including that file. | |
1229 | ||
1230 | @findex __main | |
1231 | @cindex constructors, automatic calls | |
1232 | The actual calls to the constructors are carried out by a subroutine | |
1233 | called @code{__main}, which is called (automatically) at the beginning | |
1234 | of the body of @code{main} (provided @code{main} was compiled with GNU | |
1235 | CC). Calling @code{__main} is necessary, even when compiling C code, to | |
1236 | allow linking C and C++ object code together. (If you use | |
1237 | @samp{-nostdlib}, you get an unresolved reference to @code{__main}, | |
1238 | since it's defined in the standard GCC library. Include @samp{-lgcc} at | |
1239 | the end of your compiler command line to resolve this reference.) | |
1240 | ||
1241 | The program @code{collect2} is installed as @code{ld} in the directory | |
1242 | where the passes of the compiler are installed. When @code{collect2} | |
1243 | needs to find the @emph{real} @code{ld}, it tries the following file | |
1244 | names: | |
1245 | ||
1246 | @itemize @bullet | |
1247 | @item | |
1248 | @file{real-ld} in the directories listed in the compiler's search | |
1249 | directories. | |
1250 | ||
1251 | @item | |
1252 | @file{real-ld} in the directories listed in the environment variable | |
1253 | @code{PATH}. | |
1254 | ||
1255 | @item | |
1256 | The file specified in the @code{REAL_LD_FILE_NAME} configuration macro, | |
1257 | if specified. | |
1258 | ||
1259 | @item | |
1260 | @file{ld} in the compiler's search directories, except that | |
1261 | @code{collect2} will not execute itself recursively. | |
1262 | ||
1263 | @item | |
1264 | @file{ld} in @code{PATH}. | |
1265 | @end itemize | |
1266 | ||
1267 | ``The compiler's search directories'' means all the directories where | |
1268 | @code{gcc} searches for passes of the compiler. This includes | |
1269 | directories that you specify with @samp{-B}. | |
1270 | ||
1271 | Cross-compilers search a little differently: | |
1272 | ||
1273 | @itemize @bullet | |
1274 | @item | |
1275 | @file{real-ld} in the compiler's search directories. | |
1276 | ||
1277 | @item | |
1278 | @file{@var{target}-real-ld} in @code{PATH}. | |
1279 | ||
1280 | @item | |
1281 | The file specified in the @code{REAL_LD_FILE_NAME} configuration macro, | |
1282 | if specified. | |
1283 | ||
1284 | @item | |
1285 | @file{ld} in the compiler's search directories. | |
1286 | ||
1287 | @item | |
1288 | @file{@var{target}-ld} in @code{PATH}. | |
1289 | @end itemize | |
1290 | ||
1291 | @code{collect2} explicitly avoids running @code{ld} using the file name | |
1292 | under which @code{collect2} itself was invoked. In fact, it remembers | |
1293 | up a list of such names---in case one copy of @code{collect2} finds | |
1294 | another copy (or version) of @code{collect2} installed as @code{ld} in a | |
1295 | second place in the search path. | |
1296 | ||
1297 | @code{collect2} searches for the utilities @code{nm} and @code{strip} | |
1298 | using the same algorithm as above for @code{ld}. | |
1299 | ||
1300 | @node Header Dirs | |
1301 | @section Standard Header File Directories | |
1302 | ||
1303 | @code{GCC_INCLUDE_DIR} means the same thing for native and cross. It is | |
1304 | where GNU CC stores its private include files, and also where GNU CC | |
1305 | stores the fixed include files. A cross compiled GNU CC runs | |
1306 | @code{fixincludes} on the header files in @file{$(tooldir)/include}. | |
1307 | (If the cross compilation header files need to be fixed, they must be | |
1308 | installed before GNU CC is built. If the cross compilation header files | |
5490d604 | 1309 | are already suitable for ISO C and GNU CC, nothing special need be |
2284f91b DE |
1310 | done). |
1311 | ||
0d9d12fc | 1312 | @code{GPLUSPLUS_INCLUDE_DIR} means the same thing for native and cross. It |
c85f7c16 | 1313 | is where @code{g++} looks first for header files. The C++ library |
2284f91b DE |
1314 | installs only target independent header files in that directory. |
1315 | ||
1316 | @code{LOCAL_INCLUDE_DIR} is used only for a native compiler. It is | |
1317 | normally @file{/usr/local/include}. GNU CC searches this directory so | |
1318 | that users can install header files in @file{/usr/local/include}. | |
1319 | ||
1320 | @code{CROSS_INCLUDE_DIR} is used only for a cross compiler. GNU CC | |
1321 | doesn't install anything there. | |
1322 | ||
1323 | @code{TOOL_INCLUDE_DIR} is used for both native and cross compilers. It | |
1324 | is the place for other packages to install header files that GNU CC will | |
1325 | use. For a cross-compiler, this is the equivalent of | |
1326 | @file{/usr/include}. When you build a cross-compiler, | |
1327 | @code{fixincludes} processes any header files in this directory. |