1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>LLVMBuild Documentation</title>
6 <link rel="stylesheet" href="_static/llvm.css" type="text/css">
10 <h1>LLVMBuild Guide</h1>
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>
20 <!-- *********************************************************************** -->
21 <h2><a name="introduction">Introduction</a></h2>
22 <!-- *********************************************************************** -->
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>
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
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
42 <!-- *********************************************************************** -->
43 <h2><a name="projectorg">Project Organization</a></h2>
44 <!-- *********************************************************************** -->
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. -->
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>
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>
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>
68 <!-- *********************************************************************** -->
69 <h2><a name="buildintegration">Build Integration</a></h2>
70 <!-- *********************************************************************** -->
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>
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>
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>
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>
98 <!-- *********************************************************************** -->
99 <h2><a name="componentoverview">Component Overview</a></h2>
100 <!-- *********************************************************************** -->
103 <p>As mentioned earlier, LLVM projects are organized into
104 logical <em>components</em>. Every component is typically grouped into its
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
109 <p>LLVM primarily uses the following types of components:</p>
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>
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>
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>
126 <!-- FIXME: We also need shared libraries as a first class component, but this
127 is not yet implemented. -->
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>
136 <!-- *********************************************************************** -->
137 <h2><a name="formatreference">LLVMBuild Format Reference</a></h2>
138 <!-- *********************************************************************** -->
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">
147 <i>; Comments start with a semi-colon.</i>
149 <i>; Sections are declared using square brackets.</i>
152 <i>; Properties are declared using '=' and are contained in the previous section.
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>
163 <p>LLVMBuild files are expected to define a strict set of sections 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">
172 required_libraries = Archive BitReader Core Support TransformUtils
176 <p>A full description of the exact sections and properties which are allowed
179 <p>Each file may define exactly one common component, named "common". The
180 common component may define the following properties:</p>
182 <li><i>subdirectories</i> <b>[optional]</b>
183 <p>If given, a list of the names of the subdirectories from the current
184 subpath to search for additional LLVMBuild files.</p></li>
187 <p>Each file may define multiple components. Each component is described by a
188 section who name starts with "component". The remainder of the section name is
189 ignored, but each section name must be unique. Typically components are just
190 number in order for files with multiple components ("component_0",
191 "component_1", and so on).<p>
193 <p><b>Section names not matching this format (or the "common" section) are
194 currently unused and are disallowed.</b></p>
196 <p>Every component is defined by the properties in the section. The exact list
197 of properties that are allowed depends on the component
198 type. Components <b>may not</b> define any properties other than those
199 expected by the component type.</p>
201 <p>Every component must define the following properties:</p>
203 <li><i>type</i> <b>[required]</b>
204 <p>The type of the component. Supported component types are
205 detailed below. Most components will define additional properties which
206 may be required or optional.</p></li>
208 <li><i>name</i> <b>[required]</b>
209 <p>The name of the component. Names are required to be unique
210 across the entire project.</p></li>
212 <li><i>parent</i> <b>[required]</b>
213 <p>The name of the logical parent of the component. Components are
214 organized into a logical tree to make it easier to navigate and organize
215 groups of components. The parents have no semantics as far as the project
216 build is concerned, however. Typically, the parent will be the main
217 component of the parent directory.</p>
219 <!-- FIXME: Should we make the parent optional, and default to parent
220 directories component? -->
222 <p>Components may reference the root pseudo component using '$ROOT' to
223 indicate they should logically be grouped at the top-level.</p>
227 <p>Components may define the following properties:</p>
229 <li><i>dependencies</i> <b>[optional]</b>
230 <p>If specified, a list of names of components which <i>must</i> be built
231 prior to this one. This should only be exactly those components which
232 produce some tool or source code required for building the
235 <p><em>NOTE:</em> Group and LibraryGroup components have no semantics for
236 the actual build, and are not allowed to specify dependencies.</p></li>
239 <p>The following section lists the available component types, as well as the
240 properties which are associated with that component.</p>
243 <li><i>type = Group</i>
244 <p>Group components exist purely to allow additional arbitrary structuring
245 of the logical components tree. For example, one might define a
246 "Libraries" group to hold all of the root library components.</p>
248 <p>Group components have no additionally properties.</p>
251 <li><i>type = Library</i>
252 <p>Library components define an individual library which should be built
253 from the source code in the component directory.</p>
255 <p>Components with this type use the following properties:</p>
257 <li><i>library_name</i> <b>[optional]</b>
258 <p>If given, the name to use for the actual library file on disk. If
259 not given, the name is derived from the component name
262 <li><i>required_libraries</i> <b>[optional]</b>
263 <p>If given, a list of the names of Library or LibraryGroup components
264 which must also be linked in whenever this library is used. That is,
265 the link time dependencies for this component. When tools are built,
266 the build system will include the transitive closure of
267 all <i>required_libraries</i> for the components the tool needs.</p></li>
269 <li><i>add_to_library_groups</i> <b>[optional]</b>
270 <p>If given, a list of the names of LibraryGroup components which this
271 component is also part of. This allows nesting groups of
272 components. For example, the <i>X86</i> target might define a library
273 group for all of the <i>X86</i> components. That library group might
274 then be included in the <i>all-targets</i> library group.</p></li>
276 <li><i>installed</i> <b>[optional]</b> <b>[boolean]</b>
277 <p>Whether this library is installed. Libraries that are not installed
278 are only reported by <tt>llvm-config</tt> when it is run as part of a
279 development directory.</p></li>
283 <li><i>type = LibraryGroup</i>
284 <p>LibraryGroup components are a mechanism to allow easy definition of
285 useful sets of related components. In particular, we use them to easily
286 specify things like "all targets", or "all assembly printers".</p>
288 <p>Components with this type use the following properties:</p>
290 <li><i>required_libraries</i> <b>[optional]</b>
291 <p>See the Library type for a description of this property.</p></li>
293 <li><i>add_to_library_groups</i> <b>[optional]</b>
294 <p>See the Library type for a description of this property.</p></li>
298 <li><i>type = TargetGroup</i>
299 <p>TargetGroup components are an extension of LibraryGroups, specifically
300 for defining LLVM targets (which are handled specially in a few
303 <p>The name of the component should always be the name of the target.</p>
305 <p>Components with this type use the LibraryGroup properties in addition
308 <li><i>has_asmparser</i> <b>[optional]</b> <b>[boolean]</b>
309 <p>Whether this target defines an assembly parser.</p></li>
310 <li><i>has_asmprinter</i> <b>[optional]</b> <b>[boolean]</b>
311 <p>Whether this target defines an assembly printer.</p></li>
312 <li><i>has_disassembler</i> <b>[optional]</b> <b>[boolean]</b>
313 <p>Whether this target defines a disassembler.</p></li>
314 <li><i>has_jit</i> <b>[optional]</b> <b>[boolean]</b>
315 <p>Whether this target supports JIT compilation.</p></li>
319 <li><i>type = Tool</i>
320 <p>Tool components define standalone command line tools which should be
321 built from the source code in the component directory and linked.</p>
323 <p>Components with this type use the following properties:</p>
325 <li><i>required_libraries</i> <b>[optional]</b>
327 <p>If given, a list of the names of Library or LibraryGroup components
328 which this tool is required to be linked with. <b>NOTE:</b> The values
329 should be the component names, which may not always match up with the
330 actual library names on disk.</p>
332 <p>Build systems are expected to properly include all of the libraries
333 required by the linked components (i.e., the transitive closer
334 of <em>required_libraries</em>).</p>
336 <p>Build systems are also expected to understand that those library
337 components must be built prior to linking -- they do not also need to
338 be listed under <i>dependencies</i>.</p></li>
342 <li><i>type = BuildTool</i>
343 <p>BuildTool components are like Tool components, except that the tool is
344 supposed to be built for the platform where the build is running (instead
345 of that platform being targetted). Build systems are expected to handle
346 the fact that required libraries may need to be built for multiple
347 platforms in order to be able to link this tool.</p>
349 <p>BuildTool components currently use the exact same properties as Tool
350 components, the type distinction is only used to differentiate what the
351 tool is built for.</p>
356 <!-- *********************************************************************** -->
359 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
360 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
361 <a href="http://validator.w3.org/check/referer"><img
362 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
364 <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br>
365 Last modified: $Date$