This file is indexed.

/usr/share/doc/llvm-3.5-doc/html/Projects.html is in llvm-3.5-doc 1:3.5-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Creating an LLVM Project &mdash; LLVM 3.5 documentation</title>
    
    <link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '3.5',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="LLVM 3.5 documentation" href="index.html" />
    <link rel="next" title="LLVMBuild Guide" href="LLVMBuild.html" />
    <link rel="prev" title="LLVM Makefile Guide" href="MakefileGuide.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head>
  <body>
<div class="logo">
  <a href="index.html">
    <img src="_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="LLVMBuild.html" title="LLVMBuild Guide"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="MakefileGuide.html" title="LLVM Makefile Guide"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>
 
      </ul>
    </div>


    <div class="document">
      <div class="documentwrapper">
          <div class="body">
            
  <div class="section" id="creating-an-llvm-project">
<h1>Creating an LLVM Project<a class="headerlink" href="#creating-an-llvm-project" title="Permalink to this headline"></a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#overview" id="id1">Overview</a></li>
<li><a class="reference internal" href="#source-tree-layout" id="id2">Source Tree Layout</a></li>
<li><a class="reference internal" href="#writing-llvm-style-makefiles" id="id3">Writing LLVM Style Makefiles</a><ul>
<li><a class="reference internal" href="#required-variables" id="id4">Required Variables</a></li>
<li><a class="reference internal" href="#variables-for-building-subdirectories" id="id5">Variables for Building Subdirectories</a></li>
<li><a class="reference internal" href="#variables-for-building-libraries" id="id6">Variables for Building Libraries</a></li>
<li><a class="reference internal" href="#variables-for-building-programs" id="id7">Variables for Building Programs</a></li>
<li><a class="reference internal" href="#miscellaneous-variables" id="id8">Miscellaneous Variables</a></li>
</ul>
</li>
<li><a class="reference internal" href="#placement-of-object-code" id="id9">Placement of Object Code</a></li>
<li><a class="reference internal" href="#further-help" id="id10">Further Help</a></li>
</ul>
</div>
<div class="section" id="overview">
<h2><a class="toc-backref" href="#id1">Overview</a><a class="headerlink" href="#overview" title="Permalink to this headline"></a></h2>
<p>The LLVM build system is designed to facilitate the building of third party
projects that use LLVM header files, libraries, and tools.  In order to use
these facilities, a <tt class="docutils literal"><span class="pre">Makefile</span></tt> from a project must do the following things:</p>
<ul class="simple">
<li>Set <tt class="docutils literal"><span class="pre">make</span></tt> variables. There are several variables that a <tt class="docutils literal"><span class="pre">Makefile</span></tt> needs
to set to use the LLVM build system:<ul>
<li><tt class="docutils literal"><span class="pre">PROJECT_NAME</span></tt> - The name by which your project is known.</li>
<li><tt class="docutils literal"><span class="pre">LLVM_SRC_ROOT</span></tt> - The root of the LLVM source tree.</li>
<li><tt class="docutils literal"><span class="pre">LLVM_OBJ_ROOT</span></tt> - The root of the LLVM object tree.</li>
<li><tt class="docutils literal"><span class="pre">PROJ_SRC_ROOT</span></tt> - The root of the project&#8217;s source tree.</li>
<li><tt class="docutils literal"><span class="pre">PROJ_OBJ_ROOT</span></tt> - The root of the project&#8217;s object tree.</li>
<li><tt class="docutils literal"><span class="pre">PROJ_INSTALL_ROOT</span></tt> - The root installation directory.</li>
<li><tt class="docutils literal"><span class="pre">LEVEL</span></tt> - The relative path from the current directory to the
project&#8217;s root <tt class="docutils literal"><span class="pre">($PROJ_OBJ_ROOT)</span></tt>.</li>
</ul>
</li>
<li>Include <tt class="docutils literal"><span class="pre">Makefile.config</span></tt> from <tt class="docutils literal"><span class="pre">$(LLVM_OBJ_ROOT)</span></tt>.</li>
<li>Include <tt class="docutils literal"><span class="pre">Makefile.rules</span></tt> from <tt class="docutils literal"><span class="pre">$(LLVM_SRC_ROOT)</span></tt>.</li>
</ul>
<p>There are two ways that you can set all of these variables:</p>
<ul class="simple">
<li>You can write your own <tt class="docutils literal"><span class="pre">Makefiles</span></tt> which hard-code these values.</li>
<li>You can use the pre-made LLVM sample project. This sample project includes
<tt class="docutils literal"><span class="pre">Makefiles</span></tt>, a configure script that can be used to configure the location
of LLVM, and the ability to support multiple object directories from a single
source directory.</li>
</ul>
<p>If you want to devise your own build system, studying other projects and LLVM
<tt class="docutils literal"><span class="pre">Makefiles</span></tt> will probably provide enough information on how to write your own
<tt class="docutils literal"><span class="pre">Makefiles</span></tt>.</p>
</div>
<div class="section" id="source-tree-layout">
<h2><a class="toc-backref" href="#id2">Source Tree Layout</a><a class="headerlink" href="#source-tree-layout" title="Permalink to this headline"></a></h2>
<p>In order to use the LLVM build system, you will want to organize your source
code so that it can benefit from the build system&#8217;s features.  Mainly, you want
your source tree layout to look similar to the LLVM source tree layout.</p>
<p>Underneath your top level directory, you should have the following directories:</p>
<p><strong>lib</strong></p>
<blockquote>
<div><p>This subdirectory should contain all of your library source code.  For each
library that you build, you will have one directory in <strong>lib</strong> that will
contain that library&#8217;s source code.</p>
<p>Libraries can be object files, archives, or dynamic libraries.  The <strong>lib</strong>
directory is just a convenient place for libraries as it places them all in
a directory from which they can be linked later.</p>
</div></blockquote>
<p><strong>include</strong></p>
<blockquote>
<div><p>This subdirectory should contain any header files that are global to your
project. By global, we mean that they are used by more than one library or
executable of your project.</p>
<p>By placing your header files in <strong>include</strong>, they will be found
automatically by the LLVM build system.  For example, if you have a file
<strong>include/jazz/note.h</strong>, then your source files can include it simply with
<strong>#include &#8220;jazz/note.h&#8221;</strong>.</p>
</div></blockquote>
<p><strong>tools</strong></p>
<blockquote>
<div>This subdirectory should contain all of your source code for executables.
For each program that you build, you will have one directory in <strong>tools</strong>
that will contain that program&#8217;s source code.</div></blockquote>
<p><strong>test</strong></p>
<blockquote>
<div><p>This subdirectory should contain tests that verify that your code works
correctly.  Automated tests are especially useful.</p>
<p>Currently, the LLVM build system provides basic support for tests. The LLVM
system provides the following:</p>
</div></blockquote>
<ul>
<li><p class="first">LLVM contains regression tests in <tt class="docutils literal"><span class="pre">llvm/test</span></tt>.  These tests are run by the
<a class="reference internal" href="CommandGuide/lit.html"><em>Lit</em></a> testing tool.  This test procedure uses <tt class="docutils literal"><span class="pre">RUN</span></tt>
lines in the actual test case to determine how to run the test.  See the
<a class="reference internal" href="TestingGuide.html"><em>LLVM Testing Infrastructure Guide</em></a> for more details.</p>
</li>
<li><p class="first">LLVM contains an optional package called <tt class="docutils literal"><span class="pre">llvm-test</span></tt>, which provides
benchmarks and programs that are known to compile with the Clang front
end. You can use these programs to test your code, gather statistical
information, and compare it to the current LLVM performance statistics.</p>
<p>Currently, there is no way to hook your tests directly into the <tt class="docutils literal"><span class="pre">llvm/test</span></tt>
testing harness. You will simply need to find a way to use the source
provided within that directory on your own.</p>
</li>
</ul>
<p>Typically, you will want to build your <strong>lib</strong> directory first followed by your
<strong>tools</strong> directory.</p>
</div>
<div class="section" id="writing-llvm-style-makefiles">
<h2><a class="toc-backref" href="#id3">Writing LLVM Style Makefiles</a><a class="headerlink" href="#writing-llvm-style-makefiles" title="Permalink to this headline"></a></h2>
<p>The LLVM build system provides a convenient way to build libraries and
executables.  Most of your project Makefiles will only need to define a few
variables.  Below is a list of the variables one can set and what they can
do:</p>
<div class="section" id="required-variables">
<h3><a class="toc-backref" href="#id4">Required Variables</a><a class="headerlink" href="#required-variables" title="Permalink to this headline"></a></h3>
<p><tt class="docutils literal"><span class="pre">LEVEL</span></tt></p>
<blockquote>
<div>This variable is the relative path from this <tt class="docutils literal"><span class="pre">Makefile</span></tt> to the top
directory of your project&#8217;s source code.  For example, if your source code
is in <tt class="docutils literal"><span class="pre">/tmp/src</span></tt>, then the <tt class="docutils literal"><span class="pre">Makefile</span></tt> in <tt class="docutils literal"><span class="pre">/tmp/src/jump/high</span></tt>
would set <tt class="docutils literal"><span class="pre">LEVEL</span></tt> to <tt class="docutils literal"><span class="pre">&quot;../..&quot;</span></tt>.</div></blockquote>
</div>
<div class="section" id="variables-for-building-subdirectories">
<h3><a class="toc-backref" href="#id5">Variables for Building Subdirectories</a><a class="headerlink" href="#variables-for-building-subdirectories" title="Permalink to this headline"></a></h3>
<p><tt class="docutils literal"><span class="pre">DIRS</span></tt></p>
<blockquote>
<div>This is a space separated list of subdirectories that should be built.  They
will be built, one at a time, in the order specified.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">PARALLEL_DIRS</span></tt></p>
<blockquote>
<div>This is a list of directories that can be built in parallel. These will be
built after the directories in DIRS have been built.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">OPTIONAL_DIRS</span></tt></p>
<blockquote>
<div>This is a list of directories that can be built if they exist, but will not
cause an error if they do not exist.  They are built serially in the order
in which they are listed.</div></blockquote>
</div>
<div class="section" id="variables-for-building-libraries">
<h3><a class="toc-backref" href="#id6">Variables for Building Libraries</a><a class="headerlink" href="#variables-for-building-libraries" title="Permalink to this headline"></a></h3>
<p><tt class="docutils literal"><span class="pre">LIBRARYNAME</span></tt></p>
<blockquote>
<div>This variable contains the base name of the library that will be built.  For
example, to build a library named <tt class="docutils literal"><span class="pre">libsample.a</span></tt>, <tt class="docutils literal"><span class="pre">LIBRARYNAME</span></tt> should
be set to <tt class="docutils literal"><span class="pre">sample</span></tt>.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">BUILD_ARCHIVE</span></tt></p>
<blockquote>
<div>By default, a library is a <tt class="docutils literal"><span class="pre">.o</span></tt> file that is linked directly into a
program.  To build an archive (also known as a static library), set the
<tt class="docutils literal"><span class="pre">BUILD_ARCHIVE</span></tt> variable.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">SHARED_LIBRARY</span></tt></p>
<blockquote>
<div>If <tt class="docutils literal"><span class="pre">SHARED_LIBRARY</span></tt> is defined in your Makefile, a shared (or dynamic)
library will be built.</div></blockquote>
</div>
<div class="section" id="variables-for-building-programs">
<h3><a class="toc-backref" href="#id7">Variables for Building Programs</a><a class="headerlink" href="#variables-for-building-programs" title="Permalink to this headline"></a></h3>
<p><tt class="docutils literal"><span class="pre">TOOLNAME</span></tt></p>
<blockquote>
<div>This variable contains the name of the program that will be built.  For
example, to build an executable named <tt class="docutils literal"><span class="pre">sample</span></tt>, <tt class="docutils literal"><span class="pre">TOOLNAME</span></tt> should be set
to <tt class="docutils literal"><span class="pre">sample</span></tt>.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">USEDLIBS</span></tt></p>
<blockquote>
<div><p>This variable holds a space separated list of libraries that should be
linked into the program.  These libraries must be libraries that come from
your <strong>lib</strong> directory.  The libraries must be specified without their
<tt class="docutils literal"><span class="pre">lib</span></tt> prefix.  For example, to link <tt class="docutils literal"><span class="pre">libsample.a</span></tt>, you would set
<tt class="docutils literal"><span class="pre">USEDLIBS</span></tt> to <tt class="docutils literal"><span class="pre">sample.a</span></tt>.</p>
<p>Note that this works only for statically linked libraries.</p>
</div></blockquote>
<p><tt class="docutils literal"><span class="pre">LLVMLIBS</span></tt></p>
<blockquote>
<div><p>This variable holds a space separated list of libraries that should be
linked into the program.  These libraries must be LLVM libraries.  The
libraries must be specified without their <tt class="docutils literal"><span class="pre">lib</span></tt> prefix.  For example, to
link with a driver that performs an IR transformation you might set
<tt class="docutils literal"><span class="pre">LLVMLIBS</span></tt> to this minimal set of libraries <tt class="docutils literal"><span class="pre">LLVMSupport.a</span> <span class="pre">LLVMCore.a</span>
<span class="pre">LLVMBitReader.a</span> <span class="pre">LLVMAsmParser.a</span> <span class="pre">LLVMAnalysis.a</span> <span class="pre">LLVMTransformUtils.a</span>
<span class="pre">LLVMScalarOpts.a</span> <span class="pre">LLVMTarget.a</span></tt>.</p>
<p>Note that this works only for statically linked libraries. LLVM is split
into a large number of static libraries, and the list of libraries you
require may be much longer than the list above. To see a full list of
libraries use: <tt class="docutils literal"><span class="pre">llvm-config</span> <span class="pre">--libs</span> <span class="pre">all</span></tt>.  Using <tt class="docutils literal"><span class="pre">LINK_COMPONENTS</span></tt> as
described below, obviates the need to set <tt class="docutils literal"><span class="pre">LLVMLIBS</span></tt>.</p>
</div></blockquote>
<p><tt class="docutils literal"><span class="pre">LINK_COMPONENTS</span></tt></p>
<blockquote>
<div>This variable holds a space separated list of components that the LLVM
<tt class="docutils literal"><span class="pre">Makefiles</span></tt> pass to the <tt class="docutils literal"><span class="pre">llvm-config</span></tt> tool to generate a link line for
the program. For example, to link with all LLVM libraries use
<tt class="docutils literal"><span class="pre">LINK_COMPONENTS</span> <span class="pre">=</span> <span class="pre">all</span></tt>.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">LIBS</span></tt></p>
<blockquote>
<div><p>To link dynamic libraries, add <tt class="docutils literal"><span class="pre">-l&lt;library</span> <span class="pre">base</span> <span class="pre">name&gt;</span></tt> to the <tt class="docutils literal"><span class="pre">LIBS</span></tt>
variable.  The LLVM build system will look in the same places for dynamic
libraries as it does for static libraries.</p>
<p>For example, to link <tt class="docutils literal"><span class="pre">libsample.so</span></tt>, you would have the following line in
your <tt class="docutils literal"><span class="pre">Makefile</span></tt>:</p>
<blockquote>
<div><div class="highlight-makefile"><div class="highlight"><pre><span class="nv">LIBS</span> <span class="o">+=</span> -lsample
</pre></div>
</div>
</div></blockquote>
</div></blockquote>
<p>Note that <tt class="docutils literal"><span class="pre">LIBS</span></tt> must occur in the Makefile after the inclusion of
<tt class="docutils literal"><span class="pre">Makefile.common</span></tt>.</p>
</div>
<div class="section" id="miscellaneous-variables">
<h3><a class="toc-backref" href="#id8">Miscellaneous Variables</a><a class="headerlink" href="#miscellaneous-variables" title="Permalink to this headline"></a></h3>
<p><tt class="docutils literal"><span class="pre">CFLAGS</span></tt> &amp; <tt class="docutils literal"><span class="pre">CPPFLAGS</span></tt></p>
<blockquote>
<div><p>This variable can be used to add options to the C and C++ compiler,
respectively.  It is typically used to add options that tell the compiler
the location of additional directories to search for header files.</p>
<p>It is highly suggested that you append to <tt class="docutils literal"><span class="pre">CFLAGS</span></tt> and <tt class="docutils literal"><span class="pre">CPPFLAGS</span></tt> as
opposed to overwriting them.  The master <tt class="docutils literal"><span class="pre">Makefiles</span></tt> may already have
useful options in them that you may not want to overwrite.</p>
</div></blockquote>
</div>
</div>
<div class="section" id="placement-of-object-code">
<h2><a class="toc-backref" href="#id9">Placement of Object Code</a><a class="headerlink" href="#placement-of-object-code" title="Permalink to this headline"></a></h2>
<p>The final location of built libraries and executables will depend upon whether
you do a <tt class="docutils literal"><span class="pre">Debug</span></tt>, <tt class="docutils literal"><span class="pre">Release</span></tt>, or <tt class="docutils literal"><span class="pre">Profile</span></tt> build.</p>
<p>Libraries</p>
<blockquote>
<div>All libraries (static and dynamic) will be stored in
<tt class="docutils literal"><span class="pre">PROJ_OBJ_ROOT/&lt;type&gt;/lib</span></tt>, where <em>type</em> is <tt class="docutils literal"><span class="pre">Debug</span></tt>, <tt class="docutils literal"><span class="pre">Release</span></tt>, or
<tt class="docutils literal"><span class="pre">Profile</span></tt> for a debug, optimized, or profiled build, respectively.</div></blockquote>
<p>Executables</p>
<blockquote>
<div>All executables will be stored in <tt class="docutils literal"><span class="pre">PROJ_OBJ_ROOT/&lt;type&gt;/bin</span></tt>, where <em>type</em>
is <tt class="docutils literal"><span class="pre">Debug</span></tt>, <tt class="docutils literal"><span class="pre">Release</span></tt>, or <tt class="docutils literal"><span class="pre">Profile</span></tt> for a debug, optimized, or
profiled build, respectively.</div></blockquote>
</div>
<div class="section" id="further-help">
<h2><a class="toc-backref" href="#id10">Further Help</a><a class="headerlink" href="#further-help" title="Permalink to this headline"></a></h2>
<p>If you have any questions or need any help creating an LLVM project, the LLVM
team would be more than happy to help.  You can always post your questions to
the <a class="reference external" href="http://lists.cs.uiuc.edu/pipermail/llvmdev/">LLVM Developers Mailing List</a>.</p>
</div>
</div>


          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="LLVMBuild.html" title="LLVMBuild Guide"
             >next</a> |</li>
        <li class="right" >
          <a href="MakefileGuide.html" title="LLVM Makefile Guide"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>
 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2003-2014, LLVM Project.
      Last updated on 2015-02-27.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>