blob: bb1883a12c56f4e74f01dda0382b3e8e5ce2d3b4 [file] [log] [blame]
Daniel Dunbarcf427c22011-11-03 17:55:59 +00001<!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
47place 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>
Daniel Dunbar2adb2a52011-11-03 17:56:24 +000091
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>
Daniel Dunbarcf427c22011-11-03 17:55:59 +000096</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="formatref">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 scalar values and list values, where items are separated by
155; spaces. There is no support for quoting, and so property values may not contain
156; spaces.</i>
157property_name = property_value
158list_property_name = value_1 value_2 <em>...</em> value_n
159</pre>
160 </div>
161
162 <p>LLVMBuild files are expected to define a strict set of section and
163 properties. An typical component description file for a library
164 component would look typically look like the following example:</p>
165 <div class="doc_code">
166 <pre>
167[component_0]
168type = Library
169name = Linker
170parent = Libraries
171required_libraries = Archive BitReader Core Support TransformUtils
172</pre>
173 </div class="doc_code">
174
175 <p>A full description of the exact sections and properties which are allowed
176 follows.</p>
177
178 <p>Each file may define multiple components. Each component is described by a
179 section who name starts with "component". The remainder of the section name is
180 ignored, but each section name must be unique. Typically components are just
181 number in order for files with multiple components ("component_0",
182 "component_1", and so on).<p>
183
184 <p><b>Section names not matches this format are currently
185 unused and are disallowed.</b></p>
186
187 <p>Every component is defined by the properties in the section. The exact list
188 of properties that are allowed depends on the component
189 type. Components <b>may not</b> define any properties other than those
190 expected by the component type.</p>
191
192 <p>Every component must define the following properties:</p>
193 <ul>
194 <li><i>type</i> <b>[required]</b>
195 <p>The type of the component. Supported component types are
196 detailed below. Most components will define additional properties which
197 may be required or optional.</p></li>
198
199 <li><i>name</i> <b>[required]</b>
200 <p>The name of the component. Names are required to be unique
201 across the entire project.</p></li>
202
203 <li><i>parent</i> <b>[required]</b>
204 <p>The name of the logical parent of the component. Components are
205 organized into a logical tree to make it easier to navigate and organize
206 groups of components. The parent's have no semantics as far as the project
207 build is concerned, however. Typically, the parent will be the main
208 component of the parent directory.</p>
209
210 <!-- FIXME: Should we make the parent optional, and default to parent
211 directories component? -->
212
213 <p>Components may reference the root pseudo component using '$ROOT' to
214 indicate they should logically be grouped at the top-level.</p>
215 </li>
216 </ul>
217
218 <p>Components may define the following properties:</p>
219 <ul>
220 <li><i>dependencies</i> <b>[optional]</b>
221 <p>If specified, a list of names of components which <i>must</i> be built
222 prior to this one. This should only be exactly those components which
223 produce some tool or source code required for building the
224 component.</p>
225
226 <p><em>NOTE:</em> Group and LibraryGroup components have no semantics for
227 the actual build, and are not allowed to specify dependencies.</p></li>
228 </ul>
229
230 <p>The following section lists the available component types, as well as the
231 properties which are associated with that component.</p>
232
233 <ul>
234 <li><i>type = Group</i>
235 <p>Group components exist purely to allow additional arbitrary structuring
236 of the logical components tree. For example, one might define a
237 "Libraries" group to hold all of the root library components.</p>
238
239 <p>Group components have no additionally properties.</p>
240 </li>
241
242 <li><i>type = Library</i>
243 <p>Library components define an individual library which should be built
244 from the source code in the component directory.</p>
245
246 <p>Components with this type use the following properties:</p>
247 <ul>
248 <li><i>library_name</i> <b>[optional]</b>
249 <p>If given, the name to use for the actual library file on disk. If
250 not given, the name is derived from the component name
251 itself.</p></li>
252
253 <li><i>required_libraries</i> <b>[optional]</b>
254 <p>If given, a list of the names of Library or LibraryGroup components
255 which must also be linked in whenever this library is used. That is,
256 the link time dependencies for this component. When tools are built,
257 the build system will include the transitive closer of
258 all <i>required_libraries</i> for the components the tool needs.</p></li>
259
260 <li><i>add_to_library_groups</i> <b>[optional]</b>
261 <p>If given, a list of the names of LibraryGroup components which this
262 component is also part of. This allows nesting groups of
263 components. For example, the <i>X86</i> target might define a library
264 group for all of the <i>X86</i> components. That library group might
265 then be included in the <i>all-targets</i> library group.</p></li>
266 </ul>
267 </li>
268
269 <li><i>type = LibraryGroup</i>
270 <p>LibraryGroup components are a mechanism to allow easy definition of
271 useful sets of related components. In particular, we use them to easily
272 specify things like "all targets", or "all assembly printers".</p>
273
274 <p>Components with this type use the following properties:</p>
275 <ul>
276 <li><i>required_libraries</i> <b>[optional]</b>
277 <p>See the Library type for a description of this property.</p></li>
278
279 <li><i>add_to_library_groups</i> <b>[optional]</b>
280 <p>See the Library type for a description of this property.</p></li>
281 </ul>
282 </li>
283
284 <li><i>type = Tool</i>
285 <p>Tool components define standalone command line tools which should be
286 built from the source code in the component directory and linked.</p>
287
288 <p>Components with this type use the following properties:</p>
289 <ul>
290 <li><i>required_libraries</i> <b>[optional]</b>
291
292 <p>If given, a list of the names of Library or LibraryGroup components
293 which this tool is required to be linked with. <b>NOTE:</b> The values
294 should be the component names, which may not always match up with the
295 actual library names on disk.</p>
296
297 <p>Build systems are expected to properly include all of the libraries
298 required by the linked components (i.e., the transitive closer
299 of <em>required_libraries</em>).</p>
300
301 <p>Build systems are also expected to understand that those library
302 components must be built prior to linking -- they do not also need to
303 be listed under <i>dependencies</i>.</p></li>
304 </ul>
305 </li>
306
307 <li><i>type = BuildTool</i>
308 <p>BuildTool components are like Tool components, except that the tool is
309 supposed to be built for the platform where the build is running (instead
310 of that platform being targetted). Build systems are expected to handle
311 the fact that required libraries may need to be built for multiple
312 platforms in order to be able to link this tool.</p>
313
314 <p>BuildTool components currently use the exact same properties as Tool
315 components, the type distinction is only used to differentiate what the
316 tool is built for.</p>
317 </li>
318 </ul>
319</div>
320
321<!-- *********************************************************************** -->
322<hr>
323<address>
324 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
325 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
326 <a href="http://validator.w3.org/check/referer"><img
327 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
328
329 <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br>
330 Last modified: $Date$
331</address>
332</body>
333</html>