aboutsummaryrefslogtreecommitdiff
path: root/docs/GettingStarted.html
blob: 70b56c94088b805759a6eb3680a5e7da9a9be07f (plain)
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Getting Started with LLVM System</title>
  </head>

  <body bgcolor=white>
    <center><h1>Getting Started with the LLVM System<br><font size=3>By: <a
    href="mailto:gshi1@uiuc.edu">Guochun Shi</a>,
    <a href="mailto:sabre@nondot.org">Chris Lattner</a> and
    <a href="http://www.cs.uiuc.edu/~vadve">Vikram Adve</a>
    </font></h1></center>

    <!--=====================================================================-->
    <h2><a name="Contents">Contents</a></h2>
    <!--=====================================================================-->

    <ul>
      <li><a href="#overview">Overview</a>
      <li><a href="#starting">Getting started with LLVM</a>
        <ol>
          <li><a href="#requirements">Requirements</a>
          <ol>
              <li><a href="#hardware">Hardware</a>
              <li><a href="#software">Software</a>
          </ol>
          <li><a href="#quickstart">Getting started quickly (a summary)</a>
          <li><a href="#checkout">Checkout LLVM from CVS</a>
          <li><a href="#terminology">Terminology and Notation</tt></a>
          <li><a href="#objfiles">The location for object files</tt></a>
	  <li><a href="#config">Local Configuration Options</tt></a>
          <li><a href="#environment">Setting up your environment</a>
          <li><a href="#compile">Compiling the source code</a>
        </ol>
      <li><a href="#layout">Program layout</a>
	<ol>
          <li><a href="#cvsdir">CVS directories</a>
	  <li><a href="#dd"><tt>Depend</tt>, <tt>Debug</tt>, &amp;
               <tt>Release</tt> directories</a></li>
	  <li><a href="#include"><tt>llvm/include</tt></a>
	  <li><a href="#lib"><tt>llvm/lib</tt></a>
	  <li><a href="#test"><tt>llvm/test</tt></a>
	  <li><a href="#tools"><tt>llvm/tools</tt></a>  
	</ol>
      <li><a href="#tutorial">An example using the LLVM tool chain</a>
      <li><a href="#links">Links</a>
    </ul>


    <!--=====================================================================-->
    <center>
    <h2><a name="overview"><b>Overview</b></a></h2>
    </center>
    <!--=====================================================================-->

    <p>The <a href"starting">next section</a> of this guide is meant to get
    you up and running with LLVM and to give you some basic information about
    the LLVM environment.  The <a href"#quickstart">first subsection</a> gives
    a short summary for those who are already familiar with the system and
    want to get started as quickly as possible.

    <p>The later sections of this guide describe the <a
    href"#layout">general layout</a> of the the LLVM source-tree, a <a
    href="#tutorial">simple example</a> using the LLVM tool chain, and <a
    href="#links">links</a> to find more information about LLVM or to get
    help via e-mail.

    <!--=====================================================================-->
    <center>
    <h2><a name="starting"><b>Getting Started</b></a></h2>
    </center>
    <!--=====================================================================-->

    <!--=====================================================================-->
    <h3><a name="requirements"><b>Requirements</b></a></h3>
    <!--=====================================================================-->

    <!--=====================================================================-->
    <h4><a name="hardware"><b>Hardware</b></a></h4>
    <!--=====================================================================-->
    LLVM is known to work on the following platforms:
    <ul>
        <li> Linux on x86
        <ul>
            <li> Approximately 700 MB of Free Disk Space
            <ul>
                <li>Source code: 30 MB
                <li>Object code: 670 MB
            </ul>
        </ul>
        <li> Solaris on Sparc
        <ul>
            <li> Approximately 1.03 GB of Free Disk Space
            <ul>
                <li>Source code: 30 MB
                <li>Object code: 1000 MB
            </ul>
        </ul>
    </ul>

    LLVM may compile on other platforms.  While the LLVM utilities should work,
    they will only generate Sparc or x86 machine code.

    <!--=====================================================================-->
    <h4><a name="software"><b>Software</b></a></h4>
    <!--=====================================================================-->
    <p>
    Compiling LLVM requires that you have several different software packages
    installed:

    <ul>
        <li> GCC
        <p>
        The GNU Compiler Collection must be installed with C and C++ language
        support.  GCC 3.x is supported, although some effort has been made to
        support GCC 2.96.
        </p>

        <p>
        Note that we currently do not support any other C++ compiler.
        </p>

        <li> GNU Make
        <p>
        The LLVM build system relies upon GNU Make extensions.  Therefore, you
        will need GNU Make (sometimes known as gmake) to build LLVM.
        </p>

        <li> Flex and Bison
        <p>
        The LLVM source code is built using flex and bison.  You will not be
        able to configure and compile LLVM without them.
        </p>
    </ul>

    <p>
    There are some additional tools that you may want to have when working with
    LLVM:
    </p>

    <ul>
        <li> GNU Autoconf and GNU M4
        <p>
        If you want to make changes to the autoconf scripts which configure LLVM
        for compilation, you will need GNU autoconf, and consequently, GNU M4.
        LLVM was built with autoconf 2.53, so that release and any later
        release should work.
        </p>
    </ul>

    <!--=====================================================================-->
    <h3><a name="quickstart"><b>Getting Started Quickly (A Summary)</b></a></h3>
    <!--=====================================================================-->

    Here's the short story for getting up and running quickly with LLVM:
    <ol>
    <li>Find the path to the CVS repository containing LLVM (we'll call this <i>CVSROOTDIR</i>).
    <li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
    <li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt>
    <li><tt>cd llvm</tt>
    <li>Run <tt>configure</tt> to configure the Makefiles and header files.
    Useful options include:
        <ul>
            <li><tt>--with-objroot=<i>directory</i></tt>
            <br>
            Specifiy where object files should be placed during the build.

            <li><tt>--with-llvmgccdir=<i>directory</i></tt>
            <br>
            Specifiy where the LLVM C frontend has been installed.
        </ul>
    <li>Set your LLVM_LIB_SEARCH_PATH environment variable.
    <li><tt>gmake -k |& tee gnumake.out
	    &nbsp;&nbsp;&nbsp;# this is csh or tcsh syntax</tt>
    </ol>

    <p>See <a href="#environment">Setting up your environment</a> on tips to
    simplify working with the LLVM front-end and compiled tools.  See the
    other sub-sections below for other useful details in working with LLVM,
    or go straight to <a href="#layout">Program Layout</a> to learn about the
    layout of the source code tree.

    <!------------------------------------------------------------------------->
    <h3><a name="terminology">Terminology and Notation</a></h3>
    <!------------------------------------------------------------------------->

    <p>Throughout this manual, the following names are used to denote paths
    specific to the local system and working environment.  <i>These are not
    environment variables you need to set but just strings used in the rest
    of this document below</i>.  In any of the examples below, simply replace
    each of these names with the appropriate pathname on your local system.
    All these paths are absolute:</p>
    <ul>
    </ul>

    <!------------------------------------------------------------------------->
    <h3><a name="checkout">Checkout LLVM from CVS</a></h3>
    <!------------------------------------------------------------------------->

    <p>Before checking out the source code, you will need to know the path to
    the CVS repository containing the LLVM source code (we'll call this
    <i>CVSROOTDIR</i> below).  Ask the person responsible for your local LLVM
    installation to give you this path.

    <p>To get a fresh copy of the entire source code, all you
    need to do is check it out from CVS as follows:
    <ul>
    <li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
    <li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt></p>
    </ul>

    <p>This will create an '<tt>llvm</tt>' directory in the current
    directory and fully populate it with the LLVM source code, Makefiles,
    test directories, and local copies of documentation files.</p>

    <!------------------------------------------------------------------------->
    <h3><a name="config">Local Configuration Options</a></h3>
    <!------------------------------------------------------------------------->

    <p>Once checked out from the CVS repository, options and pathnames specific
    to an installation of LLVM can be set via the <tt>configure</tt> script.
    This script sets variables in <tt>llvm/Makefile.config</tt> and
    <tt>llvm/include/Config/config.h</tt>.

    <p>
    The following environment variables are used by <tt>configure</tt> to
    configure Makefile.config:
    </p>

    <ul>
    <p><li><i>CXX</i> = Pathname of the C++ compiler to use.
    <p><li><i>CC</i> = Pathname of the C compiler to use.
    </ul>

    The following options can be used to set or enable LLVM specific options:

    <ul>
    <p><li><i>--with-objroot=LLVM_OBJ_ROOT</i> =
        Path to the directory where
		object files, libraries, and executables should be placed.
		(See the Section on <a href=#objfiles>
		The location for LLVM object files</a>
		for more information.)
    <p><li><i>--with-llvmgccdir=LLVMGCCDIR</i>   =
        Path to the location of the LLVM front-end
		binaries and associated libraries.
    <p><li><i>--enable-optimized</i>       =
        Enables optimized compilation (debugging symbols are removed and GCC
        optimization flags are enabled).
    <p><li><i>--enable-profiling</i>       =
        Enables profiling compilation (compiler flags needed to add profiling
        data are enabled).
    <p><li><i>--enable-verbose</i>       =
        Enables verbose messages during the compile.
    <p><li><i>--enable-jit</i>       =
        Compile the Just In Time (JIT) functionality.  This is not available
        on all platforms.
    </ul>

    In addition to running <tt>configure</tt>, you must set the
    <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable in your startup scripts.
    This environment variable is used to locate "system" libraries like
    "<tt>-lc</tt>" and "<tt>-lm</tt>" when linking.  This variable should be set
    to the absolute path for the bytecode-libs subdirectory of the C front-end
    install.  For example, one might set <tt>LLVM_LIB_SEARCH_PATH</tt> to
    <tt>/home/vadve/lattner/local/x86/llvm-gcc/bytecode-libs</tt> for the X86
    version of the C front-end on our research machines.<p>

    <!------------------------------------------------------------------------->
    <h3><a name="objfiles">The location for LLVM object files</a></h3>
    <!------------------------------------------------------------------------->

    <p>The LLVM make system sends most output files generated during the build
    into the directory defined by the variable OBJ_ROOT in
    <tt>llvm/Makefile.config</tt>.  This can be either just your normal LLVM
    source tree or some other directory writable by you.  You may wish to put
    object files on a different filesystem either to keep them from being backed
    up or to speed up local builds.

    <p>If you wish to place output files into a separate directory, use the
    <tt>--with-objroot=<i>directory</i></tt> option of <tt>configure</tt> to
    set the top level directory of where the object files will go.  Otherwise,
    leave this option unspecified, and <tt>configure</tt> will place files
    within the LLVM source tree.

    <!------------------------------------------------------------------------->
    <h3><a name="environment">Setting up your environment</a></h3>
    <!------------------------------------------------------------------------->

    <i>NOTE: This step is optional but will set up your environment so you
    can use the compiled LLVM tools with as little hassle as
     possible.</i>)

    <p>Add the following lines to your <tt>.cshrc</tt> (or the corresponding
    lines to your <tt>.profile</tt> if you use a bourne shell derivative).

    <pre>
       # Make the C front end easy to use...
       alias llvmgcc <i>LLVMGCCDIR</i><tt>/bin/llvm-gcc</tt>

       # Make the LLVM tools easy to use...
       setenv PATH <i>OBJ_ROOT</i>/llvm/tools/Debug:${PATH}
    </pre>
    The <tt>llvmgcc</tt> alias is useful because the C compiler is not
    included in the CVS tree you just checked out.

    <p>The other <a href="#tools">LLVM tools</a> are part of the LLVM
    source base and built when compiling LLVM.  They will be built into the
    <tt><i>OBJ_ROOT</i>/tools/Debug</tt> directory.</p>

    <!------------------------------------------------------------------------->
    <h3><a name="compile">Compiling the source code</a></h3>
    <!------------------------------------------------------------------------->