llvm-build: Add an explicit component type to represent targets.
[oota-llvm.git] / docs / LLVMBuild.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5   <title>LLVMBuild Documentation</title>
6   <link rel="stylesheet" href="llvm.css" type="text/css">
7 </head>
8 <body>
9
10 <h1>LLVMBuild Guide</h1>
11
12 <ol>
13   <li><a href="#introduction">Introduction</a></li>
14   <li><a href="#projectorg">Project Organization</a></li>
15   <li><a href="#buildintegration">Build Integration</a></li>
16   <li><a href="#componentoverview">Component Overview</a></li>
17   <li><a href="#formatreference">Format Reference</a></li>
18 </ol>
19
20 <!-- *********************************************************************** -->
21 <h2><a name="introduction">Introduction</a></h2>
22 <!-- *********************************************************************** -->
23
24 <div>
25   <p>This document describes the <tt>LLVMBuild</tt> organization and files which
26   we use to describe parts of the LLVM ecosystem. For description of specific
27   LLVMBuild related tools, please see the command guide.</p>
28
29   <p>LLVM is designed to be a modular set of libraries which can be flexibly
30   mixed together in order to build a variety of tools, like compilers, JITs,
31   custom code generators, optimization passes, interpreters, and so on. Related
32   projects in the LLVM system like Clang and LLDB also tend to follow this
33   philosophy.</p>
34
35   <p>In order to support this usage style, LLVM has a fairly strict structure as
36   to how the source code and various components are organized. The
37   <tt>LLVMBuild.txt</tt> files are the explicit specification of that structure,
38   and are used by the build systems and other tools in order to develop the LLVM
39   project.</p>
40 </div>
41
42 <!-- *********************************************************************** -->
43 <h2><a name="projectorg">Project Organization</a></h2>
44 <!-- *********************************************************************** -->
45
46 <!-- FIXME: We should probably have an explicit top level project object. Good
47 place to hang project level data, name, etc. Also useful for serving as the
48 $ROOT of project trees for things which can be checked out separately. -->
49
50 <div>
51   <p>The source code for LLVM projects using the LLVMBuild system (LLVM, Clang,
52   and LLDB) is organized into <em>components</em>, which define the separate
53   pieces of functionality that make up the project. These projects may consist
54   of many libraries, associated tools, build tools, or other utility tools (for
55   example, testing tools).</p>
56
57   <p>For the most part, the project contents are organized around defining one
58   main component per each subdirectory. Each such directory contains
59   an <tt>LLVMBuild.txt</tt> which contains the component definitions.</p>
60
61   <p>The component descriptions for the project as a whole are automatically
62   gathered by the LLVMBuild tools. The tools automatically traverse the source
63   directory structure to find all of the component description files. NOTE: For
64   performance/sanity reasons, we only traverse into subdirectories when the
65   parent itself contains an <tt>LLVMBuild.txt</tt> description file.</p>
66 </div>
67
68 <!-- *********************************************************************** -->
69 <h2><a name="buildintegration">Build Integration</a></h2>
70 <!-- *********************************************************************** -->
71
72 <div>
73   <p>The LLVMBuild files themselves are just a declarative way to describe the
74   project structure. The actual building of the LLVM project is handled by
75   another build system (currently we support
76   both <a href="MakefileGuide.html">Makefiles</a>
77   and <a href="CMake.html">CMake</a>.</p>
78
79   <p>The build system implementation will load the relevant contents of the
80   LLVMBuild files and use that to drive the actual project build. Typically, the
81   build system will only need to load this information at "configure" time, and
82   use it to generative native information. Build systems will also handle
83   automatically reconfiguring their information when the contents of
84   the <i>LLVMBuild.txt</i> files change.</p>
85
86   <p>Developers generally are not expected to need to be aware of the details of
87   how the LLVMBuild system is integrated into their build. Ideally, LLVM
88   developers who are not working on the build system would only ever need to
89   modify the contents of the <i>LLVMBuild.txt</i> description files (although we
90   have not reached this goal yet).</p>
91
92   <p>For more information on the utility tool we provide to help interfacing
93   with the build system, please see
94   the <a href="CommandGuide/html/llvm-build.html">llvm-build</a>
95   documentation.</p>
96 </div>
97
98 <!-- *********************************************************************** -->
99 <h2><a name="componentoverview">Component Overview</a></h2>
100 <!-- *********************************************************************** -->
101
102 <div>
103   <p>As mentioned earlier, LLVM projects are organized into
104   logical <em>components</em>. Every component is typically grouped into it's
105   own subdirectory. Generally, a component is organized around a coherent group
106   of sources which have some kind of clear API separation from other parts of
107   the code.</p>
108
109   <p>LLVM primarily uses the following types of components:</p>
110   <ul>
111     <li><em>Libraries</em> - Library components define a distinct API which can
112     be independently linked into LLVM client applications. Libraries typically
113     have private and public header files, and may specify a link of required
114     libraries that they build on top of.</li>
115
116     <li><em>Build Tools</em> - Build tools are applications which are designed
117     to be run as part of the build process (typically to generate other source
118     files). Currently, LLVM uses one main build tool
119     called <a href="TableGenFundamentals.html">TableGen</a> to generate a
120     variety of source files.</li>
121
122     <li><em>Tools</em> - Command line applications which are built using the
123     LLVM component libraries. Most LLVM tools are small and are primarily
124     frontends to the library interfaces.</li>
125
126 <!-- FIXME: We also need shared libraries as a first class component, but this
127      is not yet implemented. -->
128   </ul>
129
130   <p>Components are described using <em>LLVMBuild.txt</em> files in the
131   directories that define the component. See
132   the <a href="#formatreference">Format Reference</a> section for information on
133   the exact format of these files.</p>
134 </div>
135
136 <!-- *********************************************************************** -->
137 <h2><a name="formatreference">LLVMBuild Format Reference</a></h2>
138 <!-- *********************************************************************** -->
139
140 <div>
141   <p>LLVMBuild files are written in a simple variant of the INI or configuration
142   file format (<a href="http://en.wikipedia.org/wiki/INI_file">Wikipedia
143   entry</a>). The format defines a list of sections each of which may contain
144   some number of properties. A simple example of the file format is below:</p>
145   <div class="doc_code">
146   <pre>
147 <i>; Comments start with a semi-colon.</i>
148
149 <i>; Sections are declared using square brackets.</i>
150 [component 0]
151
152 <i>; Properties are declared using '=' and are contained in the previous section.
153 ;
154 ; We support simple string and boolean scalar values and list values, where
155 ; items are separated by spaces. There is no support for quoting, and so
156 ; property values may not contain spaces.</i>
157 property_name = property_value
158 list_property_name = value_1 value_2 <em>...</em> value_n
159 boolean_property_name = 1 <em>(or 0)</em>
160 </pre>
161   </div>
162
163   <p>LLVMBuild files are expected to define a strict set of section and
164   properties. An typical component description file for a library
165   component would look typically look like the following example:</p>
166   <div class="doc_code">
167   <pre>
168 [component_0]
169 type = Library
170 name = Linker
171 parent = Libraries
172 required_libraries = Archive BitReader Core Support TransformUtils
173 </pre>
174   </div class="doc_code">
175
176   <p>A full description of the exact sections and properties which are allowed
177  follows.</p>
178
179   <p>Each file may define multiple components. Each component is described by a
180   section who name starts with "component". The remainder of the section name is
181   ignored, but each section name must be unique. Typically components are just
182   number in order for files with multiple components ("component_0",
183   "component_1", and so on).<p>
184
185   <p><b>Section names not matches this format are currently
186   unused and are disallowed.</b></p>
187
188   <p>Every component is defined by the properties in the section. The exact list
189   of properties that are allowed depends on the component
190   type. Components <b>may not</b> define any properties other than those
191   expected by the component type.</p>
192
193   <p>Every component must define the following properties:</p>
194   <ul>
195     <li><i>type</i> <b>[required]</b>
196       <p>The type of the component. Supported component types are
197       detailed below. Most components will define additional properties which
198       may be required or optional.</p></li>
199
200     <li><i>name</i> <b>[required]</b>
201       <p>The name of the component. Names are required to be unique
202       across the entire project.</p></li>
203
204     <li><i>parent</i> <b>[required]</b>
205       <p>The name of the logical parent of the component. Components are
206       organized into a logical tree to make it easier to navigate and organize
207       groups of components. The parent's have no semantics as far as the project
208       build is concerned, however. Typically, the parent will be the main
209       component of the parent directory.</p>
210
211       <!-- FIXME: Should we make the parent optional, and default to parent
212       directories component? -->
213
214       <p>Components may reference the root pseudo component using '$ROOT' to
215       indicate they should logically be grouped at the top-level.</p>
216     </li>
217   </ul>
218
219   <p>Components may define the following properties:</p>
220   <ul>
221     <li><i>dependencies</i> <b>[optional]</b>
222       <p>If specified, a list of names of components which <i>must</i> be built
223       prior to this one. This should only be exactly those components which
224       produce some tool or source code required for building the
225       component.</p>
226
227       <p><em>NOTE:</em> Group and LibraryGroup components have no semantics for
228       the actual build, and are not allowed to specify dependencies.</p></li>
229   </ul>
230
231   <p>The following section lists the available component types, as well as the
232   properties which are associated with that component.</p>
233
234   <ul>
235     <li><i>type = Group</i>
236       <p>Group components exist purely to allow additional arbitrary structuring
237       of the logical components tree. For example, one might define a
238       "Libraries" group to hold all of the root library components.</p>
239
240       <p>Group components have no additionally properties.</p>
241     </li>
242
243     <li><i>type = Library</i>
244       <p>Library components define an individual library which should be built
245       from the source code in the component directory.</p>
246
247       <p>Components with this type use the following properties:</p>
248       <ul>
249         <li><i>library_name</i> <b>[optional]</b>
250           <p>If given, the name to use for the actual library file on disk. If
251           not given, the name is derived from the component name
252           itself.</p></li>
253
254         <li><i>required_libraries</i> <b>[optional]</b>
255           <p>If given, a list of the names of Library or LibraryGroup components
256           which must also be linked in whenever this library is used. That is,
257           the link time dependencies for this component. When tools are built,
258           the build system will include the transitive closer of
259           all <i>required_libraries</i> for the components the tool needs.</p></li>
260
261         <li><i>add_to_library_groups</i> <b>[optional]</b>
262           <p>If given, a list of the names of LibraryGroup components which this
263           component is also part of. This allows nesting groups of
264           components. For example, the <i>X86</i> target might define a library
265           group for all of the <i>X86</i> components. That library group might
266           then be included in the <i>all-targets</i> library group.</p></li>
267       </ul>
268     </li>
269
270     <li><i>type = LibraryGroup</i>
271       <p>LibraryGroup components are a mechanism to allow easy definition of
272       useful sets of related components. In particular, we use them to easily
273       specify things like "all targets", or "all assembly printers".</p>
274
275       <p>Components with this type use the following properties:</p>
276       <ul>
277         <li><i>required_libraries</i> <b>[optional]</b>
278           <p>See the Library type for a description of this property.</p></li>
279
280         <li><i>add_to_library_groups</i> <b>[optional]</b>
281           <p>See the Library type for a description of this property.</p></li>
282       </ul>
283     </li>
284
285     <li><i>type = TargetGroup</i>
286       <p>TargetGroup components are an extension of LibraryGroups, specifically
287       for defining LLVM targets (which are handled specially in a few
288       places).</p>
289
290       <p>The name of the component should always be the name of the target.</p>
291
292       <p>Components with this type use the LibraryGroup properties in addition
293       to:</p>
294       <ul>
295         <li><i>has_jit</i> <b>[optional]</b> <b>[boolean]</b>
296           <p>Whether this target supports JIT compilation.</p></li>
297       </ul>
298     </li>
299
300     <li><i>type = Tool</i>
301       <p>Tool components define standalone command line tools which should be
302       built from the source code in the component directory and linked.</p>
303
304       <p>Components with this type use the following properties:</p>
305       <ul>
306         <li><i>required_libraries</i> <b>[optional]</b>
307
308           <p>If given, a list of the names of Library or LibraryGroup components
309           which this tool is required to be linked with. <b>NOTE:</b> The values
310           should be the component names, which may not always match up with the
311           actual library names on disk.</p>
312
313           <p>Build systems are expected to properly include all of the libraries
314           required by the linked components (i.e., the transitive closer
315           of <em>required_libraries</em>).</p>
316
317           <p>Build systems are also expected to understand that those library
318           components must be built prior to linking -- they do not also need to
319           be listed under <i>dependencies</i>.</p></li>
320       </ul>
321     </li>
322
323     <li><i>type = BuildTool</i>
324       <p>BuildTool components are like Tool components, except that the tool is
325       supposed to be built for the platform where the build is running (instead
326       of that platform being targetted). Build systems are expected to handle
327       the fact that required libraries may need to be built for multiple
328       platforms in order to be able to link this tool.</p>
329
330       <p>BuildTool components currently use the exact same properties as Tool
331       components, the type distinction is only used to differentiate what the
332       tool is built for.</p>
333     </li>
334   </ul>
335 </div>
336
337 <!-- *********************************************************************** -->
338 <hr>
339 <address>
340   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
341   src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
342   <a href="http://validator.w3.org/check/referer"><img
343   src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
344
345   <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br>
346   Last modified: $Date$
347 </address>
348 </body>
349 </html>