]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-language-front-end.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gccint / source-tree-structure-and-build-system / the-gcc-subdirectory / anatomy-of-a-language-front-end.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. _front-end:
7
8Anatomy of a Language Front End
9^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10
11A front end for a language in GCC has the following parts:
12
13* A directory :samp:`{language}` under :samp:`gcc` containing source
14 files for that front end. See :ref:`front-end-directory`, for details.
15
16* A mention of the language in the list of supported languages in
17 :samp:`gcc/doc/install.texi`.
18
19* A mention of the name under which the language's runtime library is
20 recognized by :option:`--enable-shared=package` in the
21 documentation of that option in :samp:`gcc/doc/install.texi`.
22
23* A mention of any special prerequisites for building the front end in
24 the documentation of prerequisites in :samp:`gcc/doc/install.texi`.
25
26* Details of contributors to that front end in
27 :samp:`gcc/doc/contrib.texi`. If the details are in that front end's
28 own manual then there should be a link to that manual's list in
29 :samp:`contrib.texi`.
30
31* Information about support for that language in
32 :samp:`gcc/doc/frontends.texi`.
33
34* Information about standards for that language, and the front end's
35 support for them, in :samp:`gcc/doc/standards.texi`. This may be a
36 link to such information in the front end's own manual.
37
38* Details of source file suffixes for that language and :option:`-x lang`
39 options supported, in :samp:`gcc/doc/invoke.texi`.
40
41* Entries in ``default_compilers`` in :samp:`gcc.cc` for source file
42 suffixes for that language.
43
44* Preferably testsuites, which may be under :samp:`gcc/testsuite` or
45 runtime library directories.
46
47 .. todo:: document somewhere how to write testsuite harnesses
48
49* Probably a runtime library for the language, outside the :samp:`gcc`
50 directory.
51
52 .. todo:: document this further
53
54* Details of the directories of any runtime libraries in
55 :samp:`gcc/doc/sourcebuild.texi`.
56
57* Check targets in :samp:`Makefile.def` for the top-level :samp:`Makefile`
58 to check just the compiler or the compiler and runtime library for the
59 language.
60
61If the front end is added to the official GCC source repository, the
62following are also necessary:
63
64* At least one Bugzilla component for bugs in that front end and runtime
65 libraries. This category needs to be added to the Bugzilla database.
66
67* Normally, one or more maintainers of that front end listed in
68 :samp:`MAINTAINERS`.
69
70* Mentions on the GCC web site in :samp:`index.html` and
71 :samp:`frontends.html`, with any relevant links on
72 :samp:`readings.html`. (Front ends that are not an official part of
73 GCC may also be listed on :samp:`frontends.html`, with relevant links.)
74
75* A news item on :samp:`index.html`, and possibly an announcement on the
76 gcc-announce@gcc.gnu.org mailing list.
77
78* The front end's manuals should be mentioned in
79 :samp:`maintainer-scripts/update_web_docs_git` (see :ref:`building_documentation`)
80 and the online manuals should be linked to from
81 :samp:`onlinedocs/index.html`.
82
83* Any old releases or CVS repositories of the front end, before its
84 inclusion in GCC, should be made available on the GCC web site at
85 https://gcc.gnu.org/pub/gcc/old-releases/.
86
87* The release and snapshot script :samp:`maintainer-scripts/gcc_release`
88 should be updated to generate appropriate tarballs for this front end.
89
90* If this front end includes its own version files that include the
91 current date, :samp:`maintainer-scripts/update_version` should be
92 updated accordingly.
93
94.. toctree::
95 :maxdepth: 2
96
97
98.. _front-end-directory:
99
100The Front End language Directory
101~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102
103A front end :samp:`{language}` directory contains the source files
104of that front end (but not of any runtime libraries, which should be
105outside the :samp:`gcc` directory). This includes documentation, and
106possibly some subsidiary programs built alongside the front end.
107Certain files are special and other parts of the compiler depend on
108their names:
109
110:samp:`config-lang.in`
111 This file is required in all language subdirectories. See :ref:`front-end-config`, for details of
112 its contents
113
114:samp:`Make-lang.in`
115 This file is required in all language subdirectories. See :ref:`front-end-makefile`, for details of its
116 contents.
117
118:samp:`lang.opt`
119 This file registers the set of switches that the front end accepts on
120 the command line, and their :option:`--help` text. See :ref:`options`.
121
122:samp:`lang-specs.h`
123 This file provides entries for ``default_compilers`` in
124 :samp:`gcc.cc` which override the default of giving an error that a
125 compiler for that language is not installed.
126
127:samp:`{language}-tree.def`
128 This file, which need not exist, defines any language-specific tree
129 codes.
130
131.. _front-end-config:
132
133The Front End config-lang.in File
134~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135
136Each language subdirectory contains a :samp:`config-lang.in` file.
137This file is a shell script that may define some variables describing
138the language:
139
140``language``
141 This definition must be present, and gives the name of the language
142 for some purposes such as arguments to :option:`--enable-languages`.
143
144``lang_requires``
145 If defined, this variable lists (space-separated) language front ends
146 other than C that this front end requires to be enabled (with the
147 names given being their ``language`` settings). For example, the
148 Obj-C++ front end depends on the C++ and ObjC front ends, so sets
149 :samp:`lang_requires="objc c++"`.
150
151``subdir_requires``
152 If defined, this variable lists (space-separated) front end directories
153 other than C that this front end requires to be present. For example,
154 the Objective-C++ front end uses source files from the C++ and
155 Objective-C front ends, so sets :samp:`subdir_requires="cp objc"`.
156
157``target_libs``
158 If defined, this variable lists (space-separated) targets in the top
159 level :samp:`Makefile` to build the runtime libraries for this
160 language, such as ``target-libobjc``.
161
162``lang_dirs``
163 If defined, this variable lists (space-separated) top level
164 directories (parallel to :samp:`gcc`), apart from the runtime libraries,
165 that should not be configured if this front end is not built.
166
167``build_by_default``
168 If defined to :samp:`no`, this language front end is not built unless
169 enabled in a :option:`--enable-languages` argument. Otherwise, front
170 ends are built by default, subject to any special logic in
171 :samp:`configure.ac` (as is present to disable the Ada front end if the
172 Ada compiler is not already installed).
173
174``boot_language``
175 If defined to :samp:`yes`, this front end is built in stage1 of the
176 bootstrap. This is only relevant to front ends written in their own
177 languages.
178
179``compilers``
180 If defined, a space-separated list of compiler executables that will
181 be run by the driver. The names here will each end
182 with :samp:`\\$(exeext)`.
183
184``outputs``
185 If defined, a space-separated list of files that should be generated
186 by :samp:`configure` substituting values in them. This mechanism can
187 be used to create a file :samp:`{language}/Makefile` from
188 :samp:`{language}/Makefile.in`, but this is deprecated, building
189 everything from the single :samp:`gcc/Makefile` is preferred.
190
191``gtfiles``
192 If defined, a space-separated list of files that should be scanned by
193 :samp:`gengtype.cc` to generate the garbage collection tables and routines for
194 this language. This excludes the files that are common to all front
195 ends. See :ref:`type-information`.
196
197.. _front-end-makefile:
198
199The Front End Make-lang.in File
200~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201
202Each language subdirectory contains a :samp:`Make-lang.in` file. It contains
203targets ``lang.hook`` (where ``lang`` is the
204setting of ``language`` in :samp:`config-lang.in`) for the following
205values of ``hook``, and any other Makefile rules required to
206build those targets (which may if necessary use other Makefiles
207specified in ``outputs`` in :samp:`config-lang.in`, although this is
208deprecated). It also adds any testsuite targets that can use the
209standard rule in :samp:`gcc/Makefile.in` to the variable
210``lang_checks``.
211
212``all.cross`` ``start.encap`` ``rest.encap``
213
214 .. todo:: exactly what goes in each of these targets?
215
216``tags``
217 Build an :command:`etags` :samp:`TAGS` file in the language subdirectory
218 in the source tree.
219
220``info``
221 Build info documentation for the front end, in the build directory.
222 This target is only called by :samp:`make bootstrap` if a suitable
223 version of :command:`sphinx` is available, so does not need to check
224 for this, and should fail if an error occurs.
225
226``pdf``
227 Build PDF documentation for the front end, in the build directory.
228
229``html``
230 Build HTML documentation for the front end, in the build directory.
231
232``man``
233 Build generated man pages for the front end from reStructuredText format
234 (see :ref:`building_documentation`), in the build directory. This target
235 is only called if the necessary tools are available, but should ignore
236 errors so as not to stop the build if errors occur; man pages are
237 optional and the tools involved may be installed in a broken way.
238
239``install-common``
240 Install everything that is part of the front end, apart from the
241 compiler executables listed in ``compilers`` in
242 :samp:`config-lang.in`.
243
244``install-info``
245 Install info documentation for the front end, if it is present in the
246 source directory. This target should have dependencies on info files
247 that should be installed.
248
249``install-man``
250 Install man pages for the front end. This target should ignore
251 errors.
252
253``install-plugin``
254 Install headers needed for plugins.
255
256``srcextra``
257 Copies its dependencies into the source directory. This generally should
258 be used for generated files such as Bison output files which are not
259 version-controlled, but should be included in any release tarballs. This
260 target will be executed during a bootstrap if
261 :samp:`--enable-generated-files-in-srcdir` was specified as a
262 :samp:`configure` option.
263
264``srcinfo`` ``srcman``
265 Copies its dependencies into the source directory. These targets will be
266 executed during a bootstrap if :samp:`--enable-generated-files-in-srcdir`
267 was specified as a :samp:`configure` option.
268
269``uninstall``
270 Uninstall files installed by installing the compiler. This is
271 currently documented not to be supported, so the hook need not do
272 anything.
273
274``mostlyclean`` ``clean`` ``distclean`` ``maintainer-clean``
275 The language parts of the standard GNU
276 :samp:`*clean` targets. For GCC, ``maintainer-clean`` should delete
277 all generated files in the source directory that are not version-controlled,
278 but should not delete anything that is.
279
280 :samp:`Make-lang.in` must also define a variable ``lang_OBJS``
3ed1b4ce 281 to a list of host object files that are used by that language.