📄 sourcebuild.texi
字号:
@item install-manInstall man pages for the front end. This target should ignoreerrors.@item srcextraCopies its dependencies into the source directory. This generally shouldbe used for generated files such as Bison output files which are notpresent in CVS, but should be included in any release tarballs. Thistarget will be executed during a bootstrap if@samp{--enable-generated-files-in-srcdir} was specified as a@file{configure} option.@item srcinfo@itemx srcmanCopies its dependencies into the source directory. These targets will beexecuted during a bootstrap if @samp{--enable-generated-files-in-srcdir}was specified as a @file{configure} option.@item uninstallUninstall files installed by installing the compiler. This iscurrently documented not to be supported, so the hook need not doanything.@item mostlyclean@itemx clean@itemx distclean@itemx maintainer-cleanThe language parts of the standard GNU@samp{*clean} targets. @xref{Standard Targets, , Standard Targets forUsers, standards, GNU Coding Standards}, for details of the standardtargets. For GCC, @code{maintainer-clean} should deleteall generated files in the source directory that are not checked intoCVS, but should not delete anything checked into CVS@.@end table@item lang.optThis file registers the set of switches that the front end accepts onthe command line, and their @option{--help} text. @xref{Options}.@item lang-specs.hThis file provides entries for @code{default_compilers} in@file{gcc.c} which override the default of giving an error that acompiler for that language is not installed.@item @var{language}-tree.defThis file, which need not exist, defines any language-specific treecodes.@end table@node Front End Config@subsubsection The Front End @file{config-lang.in} FileEach language subdirectory contains a @file{config-lang.in} file. Inaddition the main directory contains @file{c-config-lang.in}, whichcontains limited information for the C language. This file is a shellscript that may define some variables describing the language:@table @code@item languageThis definition must be present, and gives the name of the languagefor some purposes such as arguments to @option{--enable-languages}.@item lang_requiresIf defined, this variable lists (space-separated) language front endsother than C that this front end requires to be enabled (with thenames given being their @code{language} settings). For example, theJava front end depends on the C++ front end, so sets@samp{lang_requires=c++}.@item subdir_requiresIf defined, this variable lists (space-separated) front end directoriesother than C that this front end requires to be present. For example,the Objective-C++ front end uses source files from the C++ andObjective-C front ends, so sets @samp{subdir_requires="cp objc"}.@item target_libsIf defined, this variable lists (space-separated) targets in the toplevel @file{Makefile} to build the runtime libraries for thislanguage, such as @code{target-libobjc}.@item lang_dirsIf defined, this variable lists (space-separated) top leveldirectories (parallel to @file{gcc}), apart from the runtime libraries,that should not be configured if this front end is not built.@item build_by_defaultIf defined to @samp{no}, this language front end is not built unlessenabled in a @option{--enable-languages} argument. Otherwise, frontends are built by default, subject to any special logic in@file{configure.ac} (as is present to disable the Ada front end if theAda compiler is not already installed).@item boot_languageIf defined to @samp{yes}, this front end is built in stage 1 of thebootstrap. This is only relevant to front ends written in their ownlanguages.@item compilersIf defined, a space-separated list of compiler executables that willbe run by the driver. The names here will each endwith @samp{\$(exeext)}.@item outputsIf defined, a space-separated list of files that should be generatedby @file{configure} substituting values in them. This mechanism canbe used to create a file @file{@var{language}/Makefile} from@file{@var{language}/Makefile.in}, but this is deprecated, buildingeverything from the single @file{gcc/Makefile} is preferred.@item gtfilesIf defined, a space-separated list of files that should be scanned bygengtype.c to generate the garbage collection tables and routines forthis language. This excludes the files that are common to all frontends. @xref{Type Information}.@end table@node Back End@subsection Anatomy of a Target Back EndA back end for a target architecture in GCC has the following parts:@itemize @bullet@itemA directory @file{@var{machine}} under @file{gcc/config}, containing amachine description @file{@var{machine}.md} file (@pxref{Machine Desc,, Machine Descriptions}), header files @file{@var{machine}.h} and@file{@var{machine}-protos.h} and a source file @file{@var{machine}.c}(@pxref{Target Macros, , Target Description Macros and Functions}),possibly a target Makefile fragment @file{t-@var{machine}}(@pxref{Target Fragment, , The Target Makefile Fragment}), and maybesome other files. The names of these files may be changed from thedefaults given by explicit specifications in @file{config.gcc}.@itemIf necessary, a file @file{@var{machine}-modes.def} in the@file{@var{machine}} directory, containing additional machine modes torepresent condition codes. @xref{Condition Code}, for further details.@itemAn optional @file{@var{machine}.opt} file in the @file{@var{machine}}directory, containing a list of target-specific options. You can alsoadd other option files using the @code{extra_options} variable in@file{config.gcc}. @xref{Options}.@itemEntries in @file{config.gcc} (@pxref{System Config, , The@file{config.gcc} File}) for the systems with this targetarchitecture.@itemDocumentation in @file{gcc/doc/invoke.texi} for any command-lineoptions supported by this target (@pxref{Run-time Target, , Run-timeTarget Specification}). This means both entries in the summary tableof options and details of the individual options.@itemDocumentation in @file{gcc/doc/extend.texi} for any target-specificattributes supported (@pxref{Target Attributes, , Definingtarget-specific uses of @code{__attribute__}}), including where thesame attribute is already supported on some targets, which areenumerated in the manual.@itemDocumentation in @file{gcc/doc/extend.texi} for any target-specificpragmas supported.@itemDocumentation in @file{gcc/doc/extend.texi} of any target-specificbuilt-in functions supported.@itemDocumentation in @file{gcc/doc/extend.texi} of any target-specificformat checking styles supported.@itemDocumentation in @file{gcc/doc/md.texi} of any target-specificconstraint letters (@pxref{Machine Constraints, , Constraints forParticular Machines}).@itemA note in @file{gcc/doc/contrib.texi} under the person or people whocontributed the target support.@itemEntries in @file{gcc/doc/install.texi} for all target tripletssupported with this target architecture, giving details of any specialnotes about installation for this target, or saying that there are nospecial notes if there are none.@itemPossibly other support outside the @file{gcc} directory for runtimelibraries. FIXME: reference docs for this. The libstdc++ portingmanual needs to be installed as info for this to work, or to be achapter of this manual.@end itemizeIf the back end is added to the official GCC source repository, thefollowing are also necessary:@itemize @bullet@itemAn entry for the target architecture in @file{readings.html} on theGCC web site, with any relevant links.@itemDetails of the properties of the back end and target architecture in@file{backends.html} on the GCC web site.@itemA news item about the contribution of support for that targetarchitecture, in @file{index.html} on the GCC web site.@itemNormally, one or more maintainers of that target listed in@file{MAINTAINERS}. Some existing architectures may be unmaintained,but it would be unusual to add support for a target that does not havea maintainer when support is added.@end itemize@node Testsuites@section TestsuitesGCC contains several testsuites to help maintain compiler quality.Most of the runtime libraries and language front ends in GCC havetestsuites. Currently only the C language testsuites are documentedhere; FIXME: document the others.@menu* Test Idioms:: Idioms used in testsuite code.* Test Directives:: Directives used within DejaGnu tests.* Ada Tests:: The Ada language testsuites.* C Tests:: The C language testsuites.* libgcj Tests:: The Java library testsuites.* gcov Testing:: Support for testing gcov.* profopt Testing:: Support for testing profile-directed optimizations.* compat Testing:: Support for testing binary compatibility.@end menu@node Test Idioms@subsection Idioms Used in Testsuite CodeIn general, C testcases have a trailing @file{-@var{n}.c}, startingwith @file{-1.c}, in case other testcases with similar names are addedlater. If the test is a test of some well-defined feature, it shouldhave a name referring to that feature such as@file{@var{feature}-1.c}. If it does not test a well-defined featurebut just happens to exercise a bug somewhere in the compiler, and abug report has been filed for this bug in the GCC bug database,@file{pr@var{bug-number}-1.c} is the appropriate form of name.Otherwise (for miscellaneous bugs not filed in the GCC bug database),and previously more generally, test cases are named after the date onwhich they were added. This allows people to tell at a glance whethera test failure is because of a recently found bug that has not yetbeen fixed, or whether it may be a regression, but does not give anyother information about the bug or where discussion of it may befound. Some other language testsuites follow similar conventions.In the @file{gcc.dg} testsuite, it is often necessary to test that anerror is indeed a hard error and not just a warning---for example,where it is a constraint violation in the C standard, which mustbecome an error with @option{-pedantic-errors}. The following idiom,where the first line shown is line @var{line} of the file and the linethat generates the error, is used for this:@smallexample/* @{ dg-bogus "warning" "warning in place of error" @} *//* @{ dg-error "@var{regexp}" "@var{message}" @{ target *-*-* @} @var{line} @} */@end smallexampleIt may be necessary to check that an expression is an integer constantexpression and has a certain value. To check that @code{@var{E}} hasvalue @code{@var{V}}, an idiom similar to the following is used:@smallexamplechar x[((E) == (V) ? 1 : -1)];@end smallexampleIn @file{gcc.dg} tests, @code{__typeof__} is sometimes used to makeassertions about the types of expressions. See, for example,@file{gcc.dg/c99-condexpr-1.c}. The more subtle uses depend on theexact rules for the types of conditional expressions in the Cstandard; see, for example, @file{gcc.dg/c99-intconst-1.c}.It is useful to be able to test that optimizations are being madeproperly. This cannot be done in all cases, but it can be done wherethe optimization will lead to code being optimized away (for example,where flow analysis or alias analysis should show that certain codecannot be called) or to functions not being called because they havebeen expanded as built-in functions. Such tests go in@file{gcc.c-torture/execute}. Where code should be optimized away, acall to a nonexistent function such as @code{link_failure ()} may beinserted; a definition@smallexample#ifndef __OPTIMIZE__voidlink_failure (void)@{ abort ();@}#endif@end smallexample@noindentwill also be needed so that linking still succeeds when the test isrun without optimization. When all calls to a built-in functionshould have been optimized and no calls to the non-built-in version ofthe function should remain, that function may be defined as@code{static} to call @code{abort ()} (although redeclaring a functionas static may not work on all targets).All testcases must be portable. Target-specific testcases must haveappropriate code to avoid causing failures on unsupported systems;unfortunately, the mechanisms for this differ by directory.FIXME: discuss non-C testsuites here.@node Test Directives@subsection Directives used within DejaGnu testsTest directives appear within comments in a test source file and beginwith @code{dg-}. Some of these are defined within DejaGnu and othersare local to the GCC testsuite.The order in which test directives appear in a test can be important:directives local to GCC sometimes override information used by theDejaGnu directives, which know nothing about the GCC directives, so theDejaGnu directives must precede GCC directives.Several test directives include selectors which are usually preceded bythe keyword @code{target} or @code{xfail}. A selector is: one or moretarget triplets, possibly including wildcard characters; a singleeffective-target keyword; or a logical expression. Depending on thecontext, the selector specifies whether a test is skipped and reportedas unsupported or is expected to fail. Use @samp{*-*-*} to match anytarget.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -