OSDN Git Service

Merge tree-ssa-20020619-branch into mainline.
[pf3gnuchains/gcc-fork.git] / gcc / doc / sourcebuild.texi
1 @c Copyright (C) 2002, 2003, 2004 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 @node Source Tree
6 @chapter Source Tree Structure and Build System
7
8 This chapter describes the structure of the GCC source tree, and how
9 GCC is built.  The user documentation for building and installing GCC
10 is in a separate manual (@uref{http://gcc.gnu.org/install/}), with
11 which it is presumed that you are familiar.
12
13 @menu
14 * Configure Terms:: Configuration terminology and history.
15 * Top Level::       The top level source directory.
16 * gcc Directory::   The @file{gcc} subdirectory.
17 * Test Suites::     The GCC test suites.
18 @end menu
19
20 @include configterms.texi
21
22 @node Top Level
23 @section Top Level Source Directory
24
25 The top level source directory in a GCC distribution contains several
26 files and directories that are shared with other software
27 distributions such as that of GNU Binutils.  It also contains several
28 subdirectories that contain parts of GCC and its runtime libraries:
29
30 @table @file
31 @item boehm-gc
32 The Boehm conservative garbage collector, used as part of the Java
33 runtime library.
34
35 @item contrib
36 Contributed scripts that may be found useful in conjunction with GCC@.
37 One of these, @file{contrib/texi2pod.pl}, is used to generate man
38 pages from Texinfo manuals as part of the GCC build process.
39
40 @item fastjar
41 An implementation of the @command{jar} command, used with the Java
42 front end.
43
44 @item gcc
45 The main sources of GCC itself (except for runtime libraries),
46 including optimizers, support for different target architectures,
47 language front ends, and test suites.  @xref{gcc Directory, , The
48 @file{gcc} Subdirectory}, for details.
49
50 @item include
51 Headers for the @code{libiberty} library.
52
53 @item libada
54 The Ada runtime library.
55
56 @item libf2c
57 The Fortran 77 runtime library.
58
59 @item libgfortran
60 The Fortran runtime library.
61
62 @item libffi
63 The @code{libffi} library, used as part of the Java runtime library.
64
65 @item libiberty
66 The @code{libiberty} library, used for portability and for some
67 generally useful data structures and algorithms.  @xref{Top, ,
68 Introduction, libiberty, @sc{gnu} libiberty}, for more information
69 about this library.
70
71 @item libjava
72 The Java runtime library.
73
74 @item libobjc
75 The Objective-C runtime library.
76
77 @item libstdc++-v3
78 The C++ runtime library.
79
80 @item maintainer-scripts
81 Scripts used by the @code{gccadmin} account on @code{gcc.gnu.org}.
82
83 @item zlib
84 The @code{zlib} compression library, used by the Java front end and as
85 part of the Java runtime library.
86 @end table
87
88 The build system in the top level directory, including how recursion
89 into subdirectories works and how building runtime libraries for
90 multilibs is handled, is documented in a separate manual, included
91 with GNU Binutils.  @xref{Top, , GNU configure and build system,
92 configure, The GNU configure and build system}, for details.
93
94 @node gcc Directory
95 @section The @file{gcc} Subdirectory
96
97 The @file{gcc} directory contains many files that are part of the C
98 sources of GCC, other files used as part of the configuration and
99 build process, and subdirectories including documentation and a
100 test suite.  The files that are sources of GCC are documented in a
101 separate chapter.  @xref{Passes, , Passes and Files of the Compiler}.
102
103 @menu
104 * Subdirectories:: Subdirectories of @file{gcc}.
105 * Configuration::  The configuration process, and the files it uses.
106 * Build::          The build system in the @file{gcc} directory.
107 * Makefile::       Targets in @file{gcc/Makefile}.
108 * Library Files::  Library source files and headers under @file{gcc/}.
109 * Headers::        Headers installed by GCC.
110 * Documentation::  Building documentation in GCC.
111 * Front End::      Anatomy of a language front end.
112 * Back End::       Anatomy of a target back end.
113 @end menu
114
115 @node Subdirectories
116 @subsection Subdirectories of @file{gcc}
117
118 The @file{gcc} directory contains the following subdirectories:
119
120 @table @file
121 @item @var{language}
122 Subdirectories for various languages.  Directories containing a file
123 @file{config-lang.in} are language subdirectories.  The contents of
124 the subdirectories @file{cp} (for C++) and @file{objc} (for
125 Objective-C) are documented in this manual (@pxref{Passes, , Passes
126 and Files of the Compiler}); those for other languages are not.
127 @xref{Front End, , Anatomy of a Language Front End}, for details of
128 the files in these directories.
129
130 @item config
131 Configuration files for supported architectures and operating
132 systems.  @xref{Back End, , Anatomy of a Target Back End}, for
133 details of the files in this directory.
134
135 @item doc
136 Texinfo documentation for GCC, together with automatically generated
137 man pages and support for converting the installation manual to
138 HTML@.  @xref{Documentation}.
139
140 @item fixinc
141 The support for fixing system headers to work with GCC@.  See
142 @file{fixinc/README} for more information.  The headers fixed by this
143 mechanism are installed in @file{@var{libsubdir}/include}.  Along with
144 those headers, @file{README-fixinc} is also installed, as
145 @file{@var{libsubdir}/include/README}.
146
147 @item ginclude
148 System headers installed by GCC, mainly those required by the C
149 standard of freestanding implementations.  @xref{Headers, , Headers
150 Installed by GCC}, for details of when these and other headers are
151 installed.
152
153 @item intl
154 GNU @code{libintl}, from GNU @code{gettext}, for systems which do not
155 include it in libc.  Properly, this directory should be at top level,
156 parallel to the @file{gcc} directory.
157
158 @item po
159 Message catalogs with translations of messages produced by GCC into
160 various languages, @file{@var{language}.po}.  This directory also
161 contains @file{gcc.pot}, the template for these message catalogues,
162 @file{exgettext}, a wrapper around @command{gettext} to extract the
163 messages from the GCC sources and create @file{gcc.pot}, which is run
164 by @samp{make gcc.pot}, and @file{EXCLUDES}, a list of files from
165 which messages should not be extracted.
166
167 @item testsuite
168 The GCC test suites (except for those for runtime libraries).
169 @xref{Test Suites}.
170 @end table
171
172 @node Configuration
173 @subsection Configuration in the @file{gcc} Directory
174
175 The @file{gcc} directory is configured with an Autoconf-generated
176 script @file{configure}.  The @file{configure} script is generated
177 from @file{configure.ac} and @file{aclocal.m4}.  From the files
178 @file{configure.ac} and @file{acconfig.h}, Autoheader generates the
179 file @file{config.in}.  The file @file{cstamp-h.in} is used as a
180 timestamp.
181
182 @menu
183 * Config Fragments::     Scripts used by @file{configure}.
184 * System Config::        The @file{config.build}, @file{config.host}, and
185                          @file{config.gcc} files.
186 * Configuration Files::  Files created by running @file{configure}.
187 @end menu
188
189 @node Config Fragments
190 @subsubsection Scripts Used by @file{configure}
191
192 @file{configure} uses some other scripts to help in its work:
193
194 @itemize @bullet
195 @item The standard GNU @file{config.sub} and @file{config.guess}
196 files, kept in the top level directory, are used.  FIXME: when is the
197 @file{config.guess} file in the @file{gcc} directory (that just calls
198 the top level one) used?
199
200 @item The file @file{config.gcc} is used to handle configuration
201 specific to the particular target machine.  The file
202 @file{config.build} is used to handle configuration specific to the
203 particular build machine.  The file @file{config.host} is used to handle
204 configuration specific to the particular host machine.  (In general,
205 these should only be used for features that cannot reasonably be tested in
206 Autoconf feature tests.)
207 @xref{System Config, , The @file{config.build}, @file{config.host},
208 and @file{config.gcc} Files}, for details of the contents of these files.
209
210 @item Each language subdirectory has a file
211 @file{@var{language}/config-lang.in} that is used for
212 front-end-specific configuration.  @xref{Front End Config, , The Front
213 End @file{config-lang.in} File}, for details of this file.
214
215 @item A helper script @file{configure.frag} is used as part of
216 creating the output of @file{configure}.
217 @end itemize
218
219 @node System Config
220 @subsubsection The @file{config.build}, @file{config.host}, and @file{config.gcc} Files
221
222 The @file{config.build} file contains specific rules for particular systems
223 which GCC is built on.  This should be used as rarely as possible, as the
224 behavior of the build system can always be detected by autoconf.
225
226 The @file{config.host} file contains specific rules for particular systems
227 which GCC will run on.  This is rarely needed.
228
229 The @file{config.gcc} file contains specific rules for particular systems
230 which GCC will generate code for.  This is usually needed.
231
232 Each file has a list of the shell variables it sets, with descriptions, at the
233 top of the file.
234
235 FIXME: document the contents of these files, and what variables should
236 be set to control build, host and target configuration.
237
238 @include configfiles.texi
239
240 @node Build
241 @subsection Build System in the @file{gcc} Directory
242
243 FIXME: describe the build system, including what is built in what
244 stages.  Also list the various source files that are used in the build
245 process but aren't source files of GCC itself and so aren't documented
246 below (@pxref{Passes}).
247
248 @include makefile.texi
249
250 @node Library Files
251 @subsection Library Source Files and Headers under the @file{gcc} Directory
252
253 FIXME: list here, with explanation, all the C source files and headers
254 under the @file{gcc} directory that aren't built into the GCC
255 executable but rather are part of runtime libraries and object files,
256 such as @file{crtstuff.c} and @file{unwind-dw2.c}.  @xref{Headers, ,
257 Headers Installed by GCC}, for more information about the
258 @file{ginclude} directory.
259
260 @node Headers
261 @subsection Headers Installed by GCC
262
263 In general, GCC expects the system C library to provide most of the
264 headers to be used with it.  However, GCC will fix those headers if
265 necessary to make them work with GCC, and will install some headers
266 required of freestanding implementations.  These headers are installed
267 in @file{@var{libsubdir}/include}.  Headers for non-C runtime
268 libraries are also installed by GCC; these are not documented here.
269 (FIXME: document them somewhere.)
270
271 Several of the headers GCC installs are in the @file{ginclude}
272 directory.  These headers, @file{iso646.h},
273 @file{stdarg.h}, @file{stdbool.h}, and @file{stddef.h},
274 are installed in @file{@var{libsubdir}/include},
275 unless the target Makefile fragment (@pxref{Target Fragment})
276 overrides this by setting @code{USER_H}.
277
278 In addition to these headers and those generated by fixing system
279 headers to work with GCC, some other headers may also be installed in
280 @file{@var{libsubdir}/include}.  @file{config.gcc} may set
281 @code{extra_headers}; this specifies additional headers under
282 @file{config} to be installed on some systems.
283
284 GCC installs its own version of @code{<float.h>}, from @file{ginclude/float.h}.
285 This is done to cope with command-line options that change the
286 representation of floating point numbers.
287
288 GCC also installs its own version of @code{<limits.h>}; this is generated
289 from @file{glimits.h}, together with @file{limitx.h} and
290 @file{limity.h} if the system also has its own version of
291 @code{<limits.h>}.  (GCC provides its own header because it is
292 required of ISO C freestanding implementations, but needs to include
293 the system header from its own header as well because other standards
294 such as POSIX specify additional values to be defined in
295 @code{<limits.h>}.)  The system's @code{<limits.h>} header is used via
296 @file{@var{libsubdir}/include/syslimits.h}, which is copied from
297 @file{gsyslimits.h} if it does not need fixing to work with GCC; if it
298 needs fixing, @file{syslimits.h} is the fixed copy.
299
300 @node Documentation
301 @subsection Building Documentation
302
303 The main GCC documentation is in the form of manuals in Texinfo
304 format.  These are installed in Info format, and DVI versions may be
305 generated by @samp{make dvi}.  In addition, some man pages are
306 generated from the Texinfo manuals, there are some other text files
307 with miscellaneous documentation, and runtime libraries have their own
308 documentation outside the @file{gcc} directory.  FIXME: document the
309 documentation for runtime libraries somewhere.
310
311 @menu
312 * Texinfo Manuals::      GCC manuals in Texinfo format.
313 * Man Page Generation::  Generating man pages from Texinfo manuals.
314 * Miscellaneous Docs::   Miscellaneous text files with documentation.
315 @end menu
316
317 @node Texinfo Manuals
318 @subsubsection Texinfo Manuals
319
320 The manuals for GCC as a whole, and the C and C++ front ends, are in
321 files @file{doc/*.texi}.  Other front ends have their own manuals in
322 files @file{@var{language}/*.texi}.  Common files
323 @file{doc/include/*.texi} are provided which may be included in
324 multiple manuals; the following files are in @file{doc/include}:
325
326 @table @file
327 @item fdl.texi
328 The GNU Free Documentation License.
329 @item funding.texi
330 The section ``Funding Free Software''.
331 @item gcc-common.texi
332 Common definitions for manuals.
333 @item gpl.texi
334 The GNU General Public License.
335 @item texinfo.tex
336 A copy of @file{texinfo.tex} known to work with the GCC manuals.
337 @end table
338
339 DVI formatted manuals are generated by @samp{make dvi}, which uses
340 @command{texi2dvi} (via the Makefile macro @code{$(TEXI2DVI)}).  Info
341 manuals are generated by @samp{make info} (which is run as part of
342 a bootstrap); this generates the manuals in the source directory,
343 using @command{makeinfo} via the Makefile macro @code{$(MAKEINFO)},
344 and they are included in release distributions.
345
346 Manuals are also provided on the GCC web site, in both HTML and
347 PostScript forms.  This is done via the script
348 @file{maintainer-scripts/update_web_docs}.  Each manual to be
349 provided online must be listed in the definition of @code{MANUALS} in
350 that file; a file @file{@var{name}.texi} must only appear once in the
351 source tree, and the output manual must have the same name as the
352 source file.  (However, other Texinfo files, included in manuals but
353 not themselves the root files of manuals, may have names that appear
354 more than once in the source tree.)  The manual file
355 @file{@var{name}.texi} should only include other files in its own
356 directory or in @file{doc/include}.  HTML manuals will be generated by
357 @samp{makeinfo --html} and PostScript manuals by @command{texi2dvi}
358 and @command{dvips}.  All Texinfo files that are parts of manuals must
359 be checked into CVS, even if they are generated files, for the
360 generation of online manuals to work.
361
362 The installation manual, @file{doc/install.texi}, is also provided on
363 the GCC web site.  The HTML version is generated by the script
364 @file{doc/install.texi2html}.
365
366 @node Man Page Generation
367 @subsubsection Man Page Generation
368
369 Because of user demand, in addition to full Texinfo manuals, man pages
370 are provided which contain extracts from those manuals.  These man
371 pages are generated from the Texinfo manuals using
372 @file{contrib/texi2pod.pl} and @command{pod2man}.  (The man page for
373 @command{g++}, @file{cp/g++.1}, just contains a @samp{.so} reference
374 to @file{gcc.1}, but all the other man pages are generated from
375 Texinfo manuals.)
376
377 Because many systems may not have the necessary tools installed to
378 generate the man pages, they are only generated if the
379 @file{configure} script detects that recent enough tools are
380 installed, and the Makefiles allow generating man pages to fail
381 without aborting the build.  Man pages are also included in release
382 distributions.  They are generated in the source directory.
383
384 Magic comments in Texinfo files starting @samp{@@c man} control what
385 parts of a Texinfo file go into a man page.  Only a subset of Texinfo
386 is supported by @file{texi2pod.pl}, and it may be necessary to add
387 support for more Texinfo features to this script when generating new
388 man pages.  To improve the man page output, some special Texinfo
389 macros are provided in @file{doc/include/gcc-common.texi} which
390 @file{texi2pod.pl} understands:
391
392 @table @code
393 @item @@gcctabopt
394 Use in the form @samp{@@table @@gcctabopt} for tables of options,
395 where for printed output the effect of @samp{@@code} is better than
396 that of @samp{@@option} but for man page output a different effect is
397 wanted.
398 @item @@gccoptlist
399 Use for summary lists of options in manuals.
400 @item @@gol
401 Use at the end of each line inside @samp{@@gccoptlist}.  This is
402 necessary to avoid problems with differences in how the
403 @samp{@@gccoptlist} macro is handled by different Texinfo formatters.
404 @end table
405
406 FIXME: describe the @file{texi2pod.pl} input language and magic
407 comments in more detail.
408
409 @node Miscellaneous Docs
410 @subsubsection Miscellaneous Documentation
411
412 In addition to the formal documentation that is installed by GCC,
413 there are several other text files with miscellaneous documentation:
414
415 @table @file
416 @item ABOUT-GCC-NLS
417 Notes on GCC's Native Language Support.  FIXME: this should be part of
418 this manual rather than a separate file.
419 @item ABOUT-NLS
420 Notes on the Free Translation Project.
421 @item COPYING
422 The GNU General Public License.
423 @item COPYING.LIB
424 The GNU Lesser General Public License.
425 @item *ChangeLog*
426 @itemx */ChangeLog*
427 Change log files for various parts of GCC@.
428 @item LANGUAGES
429 Details of a few changes to the GCC front-end interface.  FIXME: the
430 information in this file should be part of general documentation of
431 the front-end interface in this manual.
432 @item ONEWS
433 Information about new features in old versions of GCC@.  (For recent
434 versions, the information is on the GCC web site.)
435 @item README.Portability
436 Information about portability issues when writing code in GCC@.  FIXME:
437 why isn't this part of this manual or of the GCC Coding Conventions?
438 @item SERVICE
439 A pointer to the GNU Service Directory.
440 @end table
441
442 FIXME: document such files in subdirectories, at least @file{config},
443 @file{cp}, @file{objc}, @file{testsuite}.
444
445 @node Front End
446 @subsection Anatomy of a Language Front End
447
448 A front end for a language in GCC has the following parts:
449
450 @itemize @bullet
451 @item
452 A directory @file{@var{language}} under @file{gcc} containing source
453 files for that front end.  @xref{Front End Directory, , The Front End
454 @file{@var{language}} Directory}, for details.
455 @item
456 A mention of the language in the list of supported languages in
457 @file{gcc/doc/install.texi}.
458 @item
459 Details of contributors to that front end in
460 @file{gcc/doc/contrib.texi}.  If the details are in that front end's
461 own manual then there should be a link to that manual's list in
462 @file{contrib.texi}.
463 @item
464 Information about support for that language in
465 @file{gcc/doc/frontends.texi}.
466 @item
467 Information about standards for that language, and the front end's
468 support for them, in @file{gcc/doc/standards.texi}.  This may be a
469 link to such information in the front end's own manual.
470 @item
471 Details of source file suffixes for that language and @option{-x
472 @var{lang}} options supported, in @file{gcc/doc/invoke.texi}.
473 @item
474 Entries in @code{default_compilers} in @file{gcc.c} for source file
475 suffixes for that language.
476 @item
477 Preferably test suites, which may be under @file{gcc/testsuite} or
478 runtime library directories.  FIXME: document somewhere how to write
479 test suite harnesses.
480 @item
481 Probably a runtime library for the language, outside the @file{gcc}
482 directory.  FIXME: document this further.
483 @item
484 Details of the directories of any runtime libraries in
485 @file{gcc/doc/sourcebuild.texi}.
486 @end itemize
487
488 If the front end is added to the official GCC CVS repository, the
489 following are also necessary:
490
491 @itemize @bullet
492 @item
493 At least one Bugzilla component for bugs in that front end and runtime
494 libraries.  This category needs to be mentioned in
495 @file{gcc/gccbug.in}, as well as being added to the Bugzilla database.
496 @item
497 Normally, one or more maintainers of that front end listed in
498 @file{MAINTAINERS}.
499 @item
500 Mentions on the GCC web site in @file{index.html} and
501 @file{frontends.html}, with any relevant links on
502 @file{readings.html}.  (Front ends that are not an official part of
503 GCC may also be listed on @file{frontends.html}, with relevant links.)
504 @item
505 A news item on @file{index.html}, and possibly an announcement on the
506 @email{gcc-announce@@gcc.gnu.org} mailing list.
507 @item
508 The front end's manuals should be mentioned in
509 @file{maintainer-scripts/update_web_docs} (@pxref{Texinfo Manuals})
510 and the online manuals should be linked to from
511 @file{onlinedocs/index.html}.
512 @item
513 Any old releases or CVS repositories of the front end, before its
514 inclusion in GCC, should be made available on the GCC FTP site
515 @uref{ftp://gcc.gnu.org/pub/gcc/old-releases/}.
516 @item
517 The release and snapshot script @file{maintainer-scripts/gcc_release}
518 should be updated to generate appropriate tarballs for this front end.
519 The associated @file{maintainer-scripts/snapshot-README} and
520 @file{maintainer-scripts/snapshot-index.html} files should be updated
521 to list the tarballs and diffs for this front end.
522 @item
523 If this front end includes its own version files that include the
524 current date, @file{maintainer-scripts/update_version} should be
525 updated accordingly.
526 @item
527 @file{CVSROOT/modules} in the GCC CVS repository should be updated.
528 @end itemize
529
530 @menu
531 * Front End Directory::  The front end @file{@var{language}} directory.
532 * Front End Config::     The front end @file{config-lang.in} file.
533 @end menu
534
535 @node Front End Directory
536 @subsubsection The Front End @file{@var{language}} Directory
537
538 A front end @file{@var{language}} directory contains the source files
539 of that front end (but not of any runtime libraries, which should be
540 outside the @file{gcc} directory).  This includes documentation, and
541 possibly some subsidiary programs build alongside the front end.
542 Certain files are special and other parts of the compiler depend on
543 their names:
544
545 @table @file
546 @item config-lang.in
547 This file is required in all language subdirectories.  @xref{Front End
548 Config, , The Front End @file{config-lang.in} File}, for details of
549 its contents
550 @item Make-lang.in
551 This file is required in all language subdirectories.  It contains
552 targets @code{@var{lang}.@var{hook}} (where @code{@var{lang}} is the
553 setting of @code{language} in @file{config-lang.in}) for the following
554 values of @code{@var{hook}}, and any other Makefile rules required to
555 build those targets (which may if necessary use other Makefiles
556 specified in @code{outputs} in @file{config-lang.in}, although this is
557 deprecated).  Some hooks are defined by using a double-colon rule for
558 @code{@var{hook}}, rather than by using a target of form
559 @code{@var{lang}.@var{hook}}.  These hooks are called ``double-colon
560 hooks'' below.  It also adds any testsuite targets that can use the
561 standard rule in @file{gcc/Makefile.in} to the variable
562 @code{lang_checks}.
563
564 @table @code
565 @item all.build
566 @itemx all.cross
567 @itemx start.encap
568 @itemx rest.encap
569 FIXME: exactly what goes in each of these targets?
570 @item tags
571 Build an @command{etags} @file{TAGS} file in the language subdirectory
572 in the source tree.
573 @item info
574 Build info documentation for the front end, in the build directory.
575 This target is only called by @samp{make bootstrap} if a suitable
576 version of @command{makeinfo} is available, so does not need to check
577 for this, and should fail if an error occurs.
578 @item dvi
579 Build DVI documentation for the front end, in the build directory.
580 This should be done using @code{$(TEXI2DVI)}, with appropriate
581 @option{-I} arguments pointing to directories of included files.
582 This hook is a double-colon hook.
583 @item man
584 Build generated man pages for the front end from Texinfo manuals
585 (@pxref{Man Page Generation}), in the build directory.  This target
586 is only called if the necessary tools are available, but should ignore
587 errors so as not to stop the build if errors occur; man pages are
588 optional and the tools involved may be installed in a broken way.
589 @item install-normal
590 FIXME: what is this target for?
591 @item install-common
592 Install everything that is part of the front end, apart from the
593 compiler executables listed in @code{compilers} in
594 @file{config-lang.in}.
595 @item install-info
596 Install info documentation for the front end, if it is present in the
597 source directory.  This target should have dependencies on info files
598 that should be installed.  This hook is a double-colon hook.
599 @item install-man
600 Install man pages for the front end.  This target should ignore
601 errors.
602 @item srcextra
603 Copies its dependencies into the source directory.  This generally should
604 be used for generated files such as @file{gcc/c-parse.c} which are not
605 present in CVS, but should be included in any release tarballs.  This
606 target will be executed during a bootstrap if
607 @samp{--enable-generated-files-in-srcdir} was specified as a
608 @file{configure} option.
609 @item srcinfo
610 @itemx srcman
611 Copies its dependencies into the source directory.  These targets will be
612 executed during a bootstrap if @samp{--enable-generated-files-in-srcdir}
613 was specified as a @file{configure} option.
614 @item uninstall
615 Uninstall files installed by installing the compiler.  This is
616 currently documented not to be supported, so the hook need not do
617 anything.
618 @item mostlyclean
619 @itemx clean
620 @itemx distclean
621 @itemx maintainer-clean
622 The language parts of the standard GNU
623 @samp{*clean} targets. @xref{Standard Targets, , Standard Targets for
624 Users, standards, GNU Coding Standards}, for details of the standard
625 targets.  For GCC, @code{maintainer-clean} should delete
626 all generated files in the source directory that are not checked into
627 CVS, but should not delete anything checked into CVS@.
628 @item stage1
629 @itemx stage2
630 @itemx stage3
631 @itemx stage4
632 @itemx stageprofile
633 @itemx stagefeedback
634 Move to the stage directory files not included in @code{stagestuff} in
635 @file{config-lang.in} or otherwise moved by the main @file{Makefile}.
636 @end table
637
638 @item lang.opt
639 This file registers the set of switches that the front end accepts on
640 the command line, and their --help text.  The file format is
641 documented in the file @file{c.opt}.  These files are processed by the
642 script @file{opts.sh}.
643 @item lang-specs.h
644 This file provides entries for @code{default_compilers} in
645 @file{gcc.c} which override the default of giving an error that a
646 compiler for that language is not installed.
647 @item @var{language}-tree.def
648 This file, which need not exist, defines any language-specific tree
649 codes.
650 @end table
651
652 @node Front End Config
653 @subsubsection The Front End @file{config-lang.in} File
654
655 Each language subdirectory contains a @file{config-lang.in} file.  In
656 addition the main directory contains @file{c-config-lang.in}, which
657 contains limited information for the C language.  This file is a shell
658 script that may define some variables describing the language:
659
660 @table @code
661 @item language
662 This definition must be present, and gives the name of the language
663 for some purposes such as arguments to @option{--enable-languages}.
664 @item lang_requires
665 If defined, this variable lists (space-separated) language front ends
666 other than C that this front end requires to be enabled (with the
667 names given being their @code{language} settings).  For example, the
668 Java front end depends on the C++ front end, so sets
669 @samp{lang_requires=c++}.
670 @item target_libs
671 If defined, this variable lists (space-separated) targets in the top
672 level @file{Makefile} to build the runtime libraries for this
673 language, such as @code{target-libobjc}.
674 @item lang_dirs
675 If defined, this variable lists (space-separated) top level
676 directories (parallel to @file{gcc}), apart from the runtime libraries,
677 that should not be configured if this front end is not built.
678 @item build_by_default
679 If defined to @samp{no}, this language front end is not built unless
680 enabled in a @option{--enable-languages} argument.  Otherwise, front
681 ends are built by default, subject to any special logic in
682 @file{configure.ac} (as is present to disable the Ada front end if the
683 Ada compiler is not already installed).
684 @item boot_language
685 If defined to @samp{yes}, this front end is built in stage 1 of the
686 bootstrap.  This is only relevant to front ends written in their own
687 languages.
688 @item compilers
689 If defined, a space-separated list of compiler executables that will
690 be run by the driver.  The names here will each end
691 with @samp{\$(exeext)}.
692 @item stagestuff
693 If defined, a space-separated list of files that should be moved to
694 the @file{stage@var{n}} directories in each stage of bootstrap.
695 @item outputs
696 If defined, a space-separated list of files that should be generated
697 by @file{configure} substituting values in them.  This mechanism can
698 be used to create a file @file{@var{language}/Makefile} from
699 @file{@var{language}/Makefile.in}, but this is deprecated, building
700 everything from the single @file{gcc/Makefile} is preferred.
701 @item gtfiles
702 If defined, a space-separated list of files that should be scanned by
703 gengtype.c to generate the garbage collection tables and routines for
704 this language.  This excludes the files that are common to all front
705 ends. @xref{Type Information}.
706 @item need_gmp
707 If defined  to @samp{yes}, this frontend requires the GMP library.
708 Enables configure tests for GMP, which set @code{GMPLIBS} and
709 @code{GMPINC} appropriately.
710
711 @end table
712
713 @node Back End
714 @subsection Anatomy of a Target Back End
715
716 A back end for a target architecture in GCC has the following parts:
717
718 @itemize @bullet
719 @item
720 A directory @file{@var{machine}} under @file{gcc/config}, containing a
721 machine description @file{@var{machine}.md} file (@pxref{Machine Desc,
722 , Machine Descriptions}), header files @file{@var{machine}.h} and
723 @file{@var{machine}-protos.h} and a source file @file{@var{machine}.c}
724 (@pxref{Target Macros, , Target Description Macros and Functions}),
725 possibly a target Makefile fragment @file{t-@var{machine}}
726 (@pxref{Target Fragment, , The Target Makefile Fragment}), and maybe
727 some other files.  The names of these files may be changed from the
728 defaults given by explicit specifications in @file{config.gcc}.
729 @item
730 If necessary, a file @file{@var{machine}-modes.def} in the
731 @file{@var{machine}} directory, containing additional machine modes to
732 represent condition codes.  @xref{Condition Code}, for further details.
733 @item
734 Entries in @file{config.gcc} (@pxref{System Config, , The
735 @file{config.gcc} File}) for the systems with this target
736 architecture.
737 @item
738 Documentation in @file{gcc/doc/invoke.texi} for any command-line
739 options supported by this target (@pxref{Run-time Target, , Run-time
740 Target Specification}).  This means both entries in the summary table
741 of options and details of the individual options.
742 @item
743 Documentation in @file{gcc/doc/extend.texi} for any target-specific
744 attributes supported (@pxref{Target Attributes, , Defining
745 target-specific uses of @code{__attribute__}}), including where the
746 same attribute is already supported on some targets, which are
747 enumerated in the manual.
748 @item
749 Documentation in @file{gcc/doc/extend.texi} for any target-specific
750 pragmas supported.
751 @item
752 Documentation in @file{gcc/doc/extend.texi} of any target-specific
753 built-in functions supported.
754 @item
755 Documentation in @file{gcc/doc/md.texi} of any target-specific
756 constraint letters (@pxref{Machine Constraints, , Constraints for
757 Particular Machines}).
758 @item
759 A note in @file{gcc/doc/contrib.texi} under the person or people who
760 contributed the target support.
761 @item
762 Entries in @file{gcc/doc/install.texi} for all target triplets
763 supported with this target architecture, giving details of any special
764 notes about installation for this target, or saying that there are no
765 special notes if there are none.
766 @item
767 Possibly other support outside the @file{gcc} directory for runtime
768 libraries.  FIXME: reference docs for this.  The libstdc++ porting
769 manual needs to be installed as info for this to work, or to be a
770 chapter of this manual.
771 @end itemize
772
773 If the back end is added to the official GCC CVS repository, the
774 following are also necessary:
775
776 @itemize @bullet
777 @item
778 An entry for the target architecture in @file{readings.html} on the
779 GCC web site, with any relevant links.
780 @item
781 Details of the properties of the back end and target architecture in
782 @file{backends.html} on the GCC web site.
783 @item
784 A news item about the contribution of support for that target
785 architecture, in @file{index.html} on the GCC web site.
786 @item
787 Normally, one or more maintainers of that target listed in
788 @file{MAINTAINERS}.  Some existing architectures may be unmaintained,
789 but it would be unusual to add support for a target that does not have
790 a maintainer when support is added.
791 @end itemize
792
793 @node Test Suites
794 @section Test Suites
795
796 GCC contains several test suites to help maintain compiler quality.
797 Most of the runtime libraries and language front ends in GCC have test
798 suites.  Currently only the C language test suites are documented
799 here; FIXME: document the others.
800
801 @menu
802 * Test Idioms::     Idioms used in test suite code.
803 * Ada Tests::       The Ada language test suites.
804 * C Tests::         The C language test suites.
805 * libgcj Tests::    The Java library test suites.
806 * gcov Testing::    Support for testing gcov.
807 * profopt Testing:: Support for testing profile-directed optimizations.
808 * compat Testing::  Support for testing binary compatibility.
809 @end menu
810
811 @node Test Idioms
812 @subsection Idioms Used in Test Suite Code
813
814 In general C testcases have a trailing @file{-@var{n}.c}, starting
815 with @file{-1.c}, in case other testcases with similar names are added
816 later.  If the test is a test of some well-defined feature, it should
817 have a name referring to that feature such as
818 @file{@var{feature}-1.c}.  If it does not test a well-defined feature
819 but just happens to exercise a bug somewhere in the compiler, and a
820 bug report has been filed for this bug in the GCC bug database,
821 @file{pr@var{bug-number}-1.c} is the appropriate form of name.
822 Otherwise (for miscellaneous bugs not filed in the GCC bug database),
823 and previously more generally, test cases are named after the date on
824 which they were added.  This allows people to tell at a glance whether
825 a test failure is because of a recently found bug that has not yet
826 been fixed, or whether it may be a regression, but does not give any
827 other information about the bug or where discussion of it may be
828 found.  Some other language testsuites follow similar conventions.
829
830 In the @file{gcc.dg} test suite, it is often necessary to test that an
831 error is indeed a hard error and not just a warning---for example,
832 where it is a constraint violation in the C standard, which must
833 become an error with @option{-pedantic-errors}.  The following idiom,
834 where the first line shown is line @var{line} of the file and the line
835 that generates the error, is used for this:
836
837 @smallexample
838 /* @{ dg-bogus "warning" "warning in place of error" @} */
839 /* @{ dg-error "@var{regexp}" "@var{message}" @{ target *-*-* @} @var{line} @} */
840 @end smallexample
841
842 It may be necessary to check that an expression is an integer constant
843 expression and has a certain value.  To check that @code{@var{E}} has
844 value @code{@var{V}}, an idiom similar to the following is used:
845
846 @smallexample
847 char x[((E) == (V) ? 1 : -1)];
848 @end smallexample
849
850 In @file{gcc.dg} tests, @code{__typeof__} is sometimes used to make
851 assertions about the types of expressions.  See, for example,
852 @file{gcc.dg/c99-condexpr-1.c}.  The more subtle uses depend on the
853 exact rules for the types of conditional expressions in the C
854 standard; see, for example, @file{gcc.dg/c99-intconst-1.c}.
855
856 It is useful to be able to test that optimizations are being made
857 properly.  This cannot be done in all cases, but it can be done where
858 the optimization will lead to code being optimized away (for example,
859 where flow analysis or alias analysis should show that certain code
860 cannot be called) or to functions not being called because they have
861 been expanded as built-in functions.  Such tests go in
862 @file{gcc.c-torture/execute}.  Where code should be optimized away, a
863 call to a nonexistent function such as @code{link_failure ()} may be
864 inserted; a definition
865
866 @smallexample
867 #ifndef __OPTIMIZE__
868 void
869 link_failure (void)
870 @{
871   abort ();
872 @}
873 #endif
874 @end smallexample
875
876 @noindent
877 will also be needed so that linking still succeeds when the test is
878 run without optimization.  When all calls to a built-in function
879 should have been optimized and no calls to the non-built-in version of
880 the function should remain, that function may be defined as
881 @code{static} to call @code{abort ()} (although redeclaring a function
882 as static may not work on all targets).
883
884 All testcases must be portable.  Target-specific testcases must have
885 appropriate code to avoid causing failures on unsupported systems;
886 unfortunately, the mechanisms for this differ by directory.
887
888 FIXME: discuss non-C test suites here.
889
890 @node Ada Tests
891 @subsection Ada Language Test Suites
892
893 The Ada test suite includes executable tests from the ACATS 2.5 test
894 suite, publicly available at @uref{http://www.adaic.org/compilers/acats/2.5}
895
896 These tests are integrated in the GCC test suite in the
897 @file{gcc/testsuite/ada/acats} directory, and
898 enabled automatically when running @code{make check}, assuming
899 the Ada language has been enabled when configuring GCC.
900
901 You can also run the Ada test suite independently, using
902 @code{make check-ada}, or run a subset of the tests by specifying which
903 chapter to run, e.g:
904
905 @smallexample
906 $ make check-ada CHAPTERS="c3 c9"
907 @end smallexample
908
909 The tests are organized by directory, each directory corresponding to
910 a chapter of the Ada Reference Manual. So for example, c9 corresponds
911 to chapter 9, which deals with tasking features of the language.
912
913 There is also an extra chapter called @file{gcc} containing a template for
914 creating new executable tests.
915
916 The tests are run using two 'sh' scripts: run_acats and run_all.sh
917 To run the tests using a simulator or a cross target, see the small
918 customization section at the top of run_all.sh
919
920 These tests are run using the build tree: they can be run without doing
921 a @code{make install}.
922
923 @node C Tests
924 @subsection C Language Test Suites
925
926 GCC contains the following C language test suites, in the
927 @file{gcc/testsuite} directory:
928
929 @table @file
930 @item gcc.dg
931 This contains tests of particular features of the C compiler, using the
932 more modern @samp{dg} harness.  Correctness tests for various compiler
933 features should go here if possible.
934
935 Magic comments determine whether the file
936 is preprocessed, compiled, linked or run.  In these tests, error and warning
937 message texts are compared against expected texts or regular expressions
938 given in comments.  These tests are run with the options @samp{-ansi -pedantic}
939 unless other options are given in the test.  Except as noted below they
940 are not run with multiple optimization options.
941 @item gcc.dg/compat
942 This subdirectory contains tests for binary compatibility using
943 @file{compat.exp}, which in turn uses the language-independent support
944 (@pxref{compat Testing, , Support for testing binary compatibility}).
945 @item gcc.dg/cpp
946 This subdirectory contains tests of the preprocessor.
947 @item gcc.dg/debug
948 This subdirectory contains tests for debug formats.  Tests in this
949 subdirectory are run for each debug format that the compiler supports.
950 @item gcc.dg/format
951 This subdirectory contains tests of the @option{-Wformat} format
952 checking.  Tests in this directory are run with and without
953 @option{-DWIDE}.
954 @item gcc.dg/noncompile
955 This subdirectory contains tests of code that should not compile and
956 does not need any special compilation options.  They are run with
957 multiple optimization options, since sometimes invalid code crashes
958 the compiler with optimization.
959 @item gcc.dg/special
960 FIXME: describe this.
961
962 @item gcc.c-torture
963 This contains particular code fragments which have historically broken easily.
964 These tests are run with multiple optimization options, so tests for features
965 which only break at some optimization levels belong here.  This also contains
966 tests to check that certain optimizations occur.  It might be worthwhile to
967 separate the correctness tests cleanly from the code quality tests, but
968 it hasn't been done yet.
969
970 @item gcc.c-torture/compat
971 FIXME: describe this.
972
973 This directory should probably not be used for new tests.
974 @item gcc.c-torture/compile
975 This test suite contains test cases that should compile, but do not
976 need to link or run.  These test cases are compiled with several
977 different combinations of optimization options.  All warnings are
978 disabled for these test cases, so this directory is not suitable if
979 you wish to test for the presence or absence of compiler warnings.
980 While special options can be set, and tests disabled on specific
981 platforms, by the use of @file{.x} files, mostly these test cases
982 should not contain platform dependencies.  FIXME: discuss how defines
983 such as @code{NO_LABEL_VALUES} and @code{STACK_SIZE} are used.
984 @item gcc.c-torture/execute
985 This test suite contains test cases that should compile, link and run;
986 otherwise the same comments as for @file{gcc.c-torture/compile} apply.
987 @item gcc.c-torture/execute/ieee
988 This contains tests which are specific to IEEE floating point.
989 @item gcc.c-torture/unsorted
990 FIXME: describe this.
991
992 This directory should probably not be used for new tests.
993 @item gcc.c-torture/misc-tests
994 This directory contains C tests that require special handling.  Some
995 of these tests have individual expect files, and others share
996 special-purpose expect files:
997
998 @table @file
999 @item @code{bprob*.c}
1000 Test @option{-fbranch-probabilities} using @file{bprob.exp}, which
1001 in turn uses the generic, language-independent framework
1002 (@pxref{profopt Testing, , Support for testing profile-directed
1003 optimizations}).
1004
1005 @item @code{dg-*.c}
1006 Test the testsuite itself using @file{dg-test.exp}.
1007
1008 @item @code{gcov*.c}
1009 Test @command{gcov} output using @file{gcov.exp}, which in turn uses the
1010 language-independent support (@pxref{gcov Testing, , Support for testing gcov}).
1011
1012 @item @code{i386-pf-*.c}
1013 Test i386-specific support for data prefetch using @file{i386-prefetch.exp}.
1014 @end table
1015
1016 @end table
1017
1018 FIXME: merge in @file{testsuite/README.gcc} and discuss the format of
1019 test cases and magic comments more.
1020
1021 @node libgcj Tests
1022 @subsection The Java library test suites.
1023
1024 Runtime tests are executed via @samp{make check} in the
1025 @file{@var{target}/libjava/testsuite} directory in the build
1026 tree.  Additional runtime tests can be checked into this testsuite.
1027
1028 Regression testing of the core packages in libgcj is also covered by the
1029 Mauve test suite.  The @uref{http://sources.redhat.com/mauve/,,Mauve Project}
1030 develops tests for the Java Class Libraries.  These tests are run as part
1031 of libgcj testing by placing the Mauve tree within the libjava testsuite
1032 sources at @file{libjava/testsuite/libjava.mauve/mauve}, or by specifying
1033 the location of that tree when invoking @samp{make}, as in
1034 @samp{make MAUVEDIR=~/mauve check}.
1035
1036 To detect regressions, a mechanism in @file{mauve.exp} compares the
1037 failures for a test run against the list of expected failures in
1038 @file{libjava/testsuite/libjava.mauve/xfails} from the source hierarchy.
1039 Update this file when adding new failing tests to Mauve, or when fixing
1040 bugs in libgcj that had caused Mauve test failures.
1041
1042 The @uref{http://oss.software.ibm.com/developerworks/opensource/jacks/,,
1043 Jacks} project provides a test suite for Java compilers that can be used
1044 to test changes that affect the GCJ front end.  This test suite is run as
1045 part of Java testing by placing the Jacks tree within the the libjava
1046 testsuite sources at @file{libjava/testsuite/libjava.jacks/jacks}.
1047
1048 We encourage developers to contribute test cases to Mauve and Jacks.
1049
1050 @node gcov Testing
1051 @subsection Support for testing @command{gcov}
1052
1053 Language-independent support for testing @command{gcov}, and for checking
1054 that branch profiling produces expected values, is provided by the
1055 expect file @file{gcov.exp}.  @command{gcov} tests also rely on procedures
1056 in @file{gcc.dg.exp} to compile and run the test program.  A typical
1057 @command{gcov} test contains the following DejaGNU commands within comments:
1058
1059 @smallexample
1060 @{ dg-options "-fprofile-arcs -ftest-coverage" @}
1061 @{ dg-do run @{ target native @} @}
1062 @{ dg-final @{ run-gcov sourcefile @} @}
1063 @end smallexample
1064
1065 Checks of @command{gcov} output can include line counts, branch percentages,
1066 and call return percentages.  All of these checks are requested via
1067 commands that appear in comments in the test's source file.
1068 Commands to check line counts are processed by default.
1069 Commands to check branch percentages and call return percentages are
1070 processed if the @command{run-gcov} command has arguments @code{branches}
1071 or @code{calls}, respectively.  For example, the following specifies
1072 checking both, as well as passing @code{-b} to @command{gcov}:
1073
1074 @smallexample
1075 @{ dg-final @{ run-gcov branches calls @{ -b sourcefile @} @} @}
1076 @end smallexample
1077
1078 A line count command appears within a comment on the source line
1079 that is expected to get the specified count and has the form
1080 @code{count(@var{cnt})}.  A test should only check line counts for
1081 lines that will get the same count for any architecture.
1082
1083 Commands to check branch percentages (@code{branch}) and call
1084 return percentages (@code{returns}) are very similar to each other.
1085 A beginning command appears on or before the first of a range of
1086 lines that will report the percentage, and the ending command
1087 follows that range of lines.  The beginning command can include a
1088 list of percentages, all of which are expected to be found within
1089 the range.  A range is terminated by the next command of the same
1090 kind.  A command @code{branch(end)} or @code{returns(end)} marks
1091 the end of a range without starting a new one.  For example:
1092
1093 @smallexample
1094 if (i > 10 && j > i && j < 20)  /* branch(27 50 75) */
1095                                 /* branch(end) */
1096   foo (i, j);
1097 @end smallexample
1098
1099 For a call return percentage, the value specified is the
1100 percentage of calls reported to return.  For a branch percentage,
1101 the value is either the expected percentage or 100 minus that
1102 value, since the direction of a branch can differ depending on the
1103 target or the optimization level.
1104
1105 Not all branches and calls need to be checked.  A test should not
1106 check for branches that might be optimized away or replaced with
1107 predicated instructions.  Don't check for calls inserted by the
1108 compiler or ones that might be inlined or optimized away.
1109
1110 A single test can check for combinations of line counts, branch
1111 percentages, and call return percentages.  The command to check a
1112 line count must appear on the line that will report that count, but
1113 commands to check branch percentages and call return percentages can
1114 bracket the lines that report them.
1115
1116 @node profopt Testing
1117 @subsection Support for testing profile-directed optimizations
1118
1119 The file @file{profopt.exp} provides language-independent support for
1120 checking correct execution of a test built with profile-directed
1121 optimization.  This testing requires that a test program be built and
1122 executed twice.  The first time it is compiled to generate profile
1123 data, and the second time it is compiled to use the data that was
1124 generated during the first execution.  The second execution is to
1125 verify that the test produces the expected results.
1126
1127 To check that the optimization actually generated better code, a
1128 test can be built and run a third time with normal optimizations to
1129 verify that the performance is better with the profile-directed
1130 optimizations.  @file{profopt.exp} has the beginnings of this kind
1131 of support.
1132
1133 @file{profopt.exp} provides generic support for profile-directed
1134 optimizations.  Each set of tests that uses it provides information
1135 about a specific optimization:
1136
1137 @table @code
1138 @item tool
1139 tool being tested, e.g., @command{gcc}
1140
1141 @item profile_option
1142 options used to generate profile data
1143
1144 @item feedback_option
1145 options used to optimize using that profile data
1146
1147 @item prof_ext
1148 suffix of profile data files
1149
1150 @item PROFOPT_OPTIONS
1151 list of options with which to run each test, similar to the lists for
1152 torture tests
1153 @end table
1154
1155 @node compat Testing
1156 @subsection Support for testing binary compatibility
1157
1158 The file @file{compat.exp} provides language-independent support for
1159 binary compatibility testing.  It supports testing interoperability
1160 of two compilers that follow the same ABI, or of multiple sets of
1161 compiler options that should not affect binary compatibility.
1162 It is intended to be used for test suites that complement ABI test
1163 suites.
1164
1165 A test supported by this framework has three parts, each in a
1166 separate source file: a main program and two pieces that interact
1167 with each other to split up the functionality being tested.
1168
1169 @table @file
1170 @item @var{testname}_main.@var{suffix}
1171 Contains the main program, which calls a function in file
1172 @file{@var{testname}_x.@var{suffix}}.
1173
1174 @item @var{testname}_x.@var{suffix}
1175 Contains at least one call to a function in
1176 @file{@var{testname}_y.@var{suffix}}.
1177
1178 @item @var{testname}_y.@var{suffix}
1179 Shares data with, or gets arguments from,
1180 @file{@var{testname}_x.@var{suffix}}.
1181 @end table
1182
1183 Within each test, the main program and one functional piece are
1184 compiled by the GCC under test.  The other piece can be compiled by
1185 an alternate compiler.  If no alternate compiler is specified,
1186 then all three source files are all compiled by the GCC under test.
1187 It's also possible to specify a pair of lists of compiler options,
1188 one list for each compiler, so that each test will be compiled with
1189 each pair of options.
1190
1191 @file{compat.exp} defines default pairs of compiler options.
1192 These can be overridden by defining the environment variable
1193 @env{COMPAT_OPTIONS} as:
1194
1195 @smallexample
1196 COMPAT_OPTIONS="[list [list @{@var{tst1}@} @{@var{alt1}@}]
1197   ...[list @{@var{tstn}@} @{@var{altn}@}]]"
1198 @end smallexample
1199
1200 where @var{tsti} and @var{alti} are lists of options, with @var{tsti}
1201 used by the compiler under test and @var{alti} used by the alternate
1202 compiler.  For example, with
1203 @code{[list [list @{-g -O0@} @{-O3@}] [list @{-fpic@} @{-fPIC -O2@}]]},
1204 the test is first built with @code{-g -O0} by the compiler under
1205 test and with @code{-O3} by the alternate compiler.  The test is
1206 built a second time using @code{-fpic} by the compiler under test
1207 and @code{-fPIC -O2} by the alternate compiler.
1208
1209 An alternate compiler is specified by defining an environment
1210 variable; for C++ define @env{ALT_CXX_UNDER_TEST} to be the full
1211 pathname of an installed compiler.  That will be written to the
1212 @file{site.exp} file used by DejaGNU.  The default is to build each
1213 test with the compiler under test using the first of each pair of
1214 compiler options from @env{COMPAT_OPTIONS}.  When
1215 @env{ALT_CXX_UNDER_TEST} is @code{same}, each test is built using
1216 the compiler under test but with combinations of the options from
1217 @env{COMPAT_OPTIONS}.
1218
1219 To run only the C++ compatibility suite using the compiler under test
1220 and another version of GCC using specific compiler options, do the
1221 following from @file{@var{objdir}/gcc}:
1222
1223 @smallexample
1224 rm site.exp
1225 make -k \
1226   ALT_CXX_UNDER_TEST=$@{alt_prefix@}/bin/g++ \
1227   COMPAT_OPTIONS="lists as shown above" \
1228   check-c++ \
1229   RUNTESTFLAGS="compat.exp"
1230 @end smallexample
1231
1232 A test that fails when the source files are compiled with different
1233 compilers, but passes when the files are compiled with the same
1234 compiler, demonstrates incompatibility of the generated code or
1235 runtime support.  A test that fails for the alternate compiler but
1236 passes for the compiler under test probably tests for a bug that was
1237 fixed in the compiler under test but is present in the alternate
1238 compiler.