llvm.org GIT mirror llvm / 0b45920
Corrected the Table of Contents. Corrected capitalization of subheadings. Created a new subsection for compiling the C front end and moved all references to it there. Updated the disk space requirements to reflect the need for the binary C front end and the optional C front end source. Added information on unpacking the distribution to the summary section. Moved autoconf environment variables to the autoconf section. Changed make to gmake. Removed some of the precise directions for unpacking the archives. Fixed some formatting inconsistencies (headings that were not centered). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7132 91177308-0d34-0410-b5e6-96231b3b80d8 John Criswell 16 years ago
1 changed file(s) with 248 addition(s) and 163 deletion(s). Raw diff Collapse all Expand all
2626
2727
  • Getting started with LLVM
  • 2828
    29
  • Getting started quickly (a summary)
  • 29
  • Getting Started Quickly (A Summary)
  • 3030
  • Terminology and Notation
  • 31
  • Setting up your environment
  • 31
  • Setting Up Your Environment
  • 3232
  • Unpacking the LLVM Archives
  • 3333
  • Checkout LLVM from CVS
  • 34
  • Local LLVM Configuration
  • 34
  • Install the C Front End
  • 35
  • Local LLVM Configuration
  • 3536
  • Compiling the LLVM Suite Source Code
  • 36
  • Compiling the LLVM C Front End
  • 37
  • The location for object files
  • 37
  • The Location of LLVM Object Files
  • 3838
    3939
  • Program layout
  • 4040
    41
  • CVS directories
  • 41
  • CVS directories
  • 4242
  • llvm/include
  • 4343
  • llvm/lib
  • 4444
  • llvm/test
  • 4545
  • llvm/tools
  • 4646
    47
  • An example using the LLVM tool chain
  • 47
  • Compiling the LLVM C Front End
  • 48
  • An Example Using the LLVM Tool Chain
  • 49
  • Common Problems
  • 4850
  • Links
  • 4951
    5052
    6264 First, LLVM comes in two pieces. The first piece is the LLVM suite. This
    6365 contains all of the tools, libraries, and header files needed to use the
    6466 low level virtual machine. It also contains a test suite that can be used
    65 to test the LLVM tools and the GCC front end.
    66

    67 The second piece is the GCC front end. This component provides a version
    67 to test the LLVM tools and the C front end.
    68

    69 The second piece is the C front end. This component provides a version
    6870 of GCC that compiles C code into LLVM bytecode. Currently, the C front end
    6971 is a modified version of GCC 3.4 (we track the GCC 3.4 development).
    7072 Once compiled into LLVM bytecode, a program can be manipulated with the
    71 LLVM tools.
    73 LLVM tools from the LLVM suite.
    7274
    7375
    7476

    Requirements

    8587
    8688
  • Linux on x86
  • 8789
    88
  • Approximately 700 MB of Free Disk Space
  • 90
  • Approximately 760 MB of Free Disk Space
  • 8991
    9092
  • Source code: 30 MB
  • 9193
  • Object code: 670 MB
  • 94
  • C front end: 60 MB
  • 9295
    9396
    97
    98

    99
    94100
  • Solaris on SparcV9 (Ultrasparc)
  • 95101
    96
  • Approximately 1.03 GB of Free Disk Space
  • 102
  • Approximately 1.24 GB of Free Disk Space
  • 97103
    98104
  • Source code: 30 MB
  • 99105
  • Object code: 1000 MB
  • 106
  • C front end: 210 MB
  • 100107
    101108
    102109
    103110
    111

    112 If you want to compile your own version of the C front end, you will need
    113 additional disk space:
    114

    115
    116
    117
  • Linux on x86
  • 118
    119
  • Approximately 249 MB of Free Disk Space
  • 120
    121
  • Source code: 146 MB
  • 122
  • Object code: 82 MB
  • 123
  • Installed binaries: 21 MB
  • 124
    125
    126
    127

    128
    129
  • Solaris on Sparc
  • 130
    131
  • Approximately 264 MB of Free Disk Space
  • 132
    133
  • Source code: 146 MB
  • 134
  • Object code: 93 MB
  • 135
  • Installed binaries: 25 MB
  • 136
    137
    138
    139
    140

    104141 LLVM may compile on other platforms. The LLVM utilities should work
    105142 on other platforms, so it should be possible to generate and produce LLVM
    106143 bytecode on unsupported platforms (although bytecode generated on one
    107144 platform may not work on another platform). However, the code generators
    108145 and Just-In-Time (JIT) compilers only generate SparcV9 or x86 machine code.
    146

    109147
    110148
    111149

    Software

    183221
    184222
    185223
    186

    Getting Started

    224

    Getting Started with LLVM

    187225
    188226
    189227
    193231
    194232 Here's the short story for getting up and running quickly with LLVM:
    195233
    196
  • Build the LLVM suite
  • 234
  • Install the C front end:
  • 197235
    198
  • Find the path to the CVS repository containing LLVM (we'll call this CVSROOTDIR).
  • 199
  • cd where-you-want-llvm-to-live
  • 200
  • cvs -d CVSROOTDIR checkout llvm
  • 201
  • cd llvm
  • 202
  • Run configure to configure the Makefiles and header files.
  • 203 Useful options include:
    204
    205
  • --with-objroot=directory
  • 206
    207 Specify where object files should be placed during the build.
    208
    209
  • --with-llvmgccdir=directory
  • 210
    211 Specify where the LLVM C frontend is going to be installed.
    212
    213
  • Set your LLVM_LIB_SEARCH_PATH environment variable.
  • 214
  • gmake -k |& tee gnumake.out
  • 236
  • cd where-you-want-the-C-front-end-to-live
  • 237
  • gunzip --stdout cfrontend.platform.tar.gz | tar -xvf
  • 238 -
    239
    240
    241

    242
    243
  • Get the Source Code
  • 244
    245
  • With the distributed files:
  • 246
    247
  • cd where-you-want-llvm-to-live
  • 248
  • gunzip --stdout llvm.tar.gz | tar -xvf -
  • 249
  • gunzip --stdout cfrontend.platform.tar.gz | tar -xvf -
  • 250
  • cd llvm
  • 251
    252
    253

    254
    255
  • With anonymous CVS access:
  • 256
    257
  • Find the path to the CVS repository containing LLVM (we'll call this CVSROOTDIR).
  • 258
  • cd where-you-want-llvm-to-live
  • 259
  • cvs -d CVSROOTDIR checkout llvm
  • 260
  • cd llvm
  • 261
    262
    263
    264
    265

    266
    267
  • Configure the LLVM Build Environment
  • 268
    269
  • Run configure to configure the Makefiles and header
  • 270 files for the default platform.
    271 Useful options include:
    272
    273
  • --with-objroot=directory
  • 274
    275 Specify where object files should be placed during the build.
    276
    277
  • --with-llvmgccdir=directory
  • 278
    279 Specify where the LLVM C frontend is going to be installed.
    280
    281
    282
    283

    284
    285
  • Build the LLVM Suite
  • 286
    287
  • Set your LLVM_LIB_SEARCH_PATH environment variable.
  • 288
  • gmake -k |& tee gnumake.out
  • 215289    # this is csh or tcsh syntax
    216290
    217

    218
  • Build the LLVM C Front End (optional)
  • 219
    220
  • Create a directory for the object files to live.
  • 221
  • cd object file directory
  • 222
  • Run Pathname-to-where-the-source-code-lives/configure --prefix=LLVMGCCDIR to configure GCC.
  • 223
  • make bootstrap
  • 224
  • make install
  • 225
    291
    292

    293
    226294
    227295
    228

    See Setting up your environment on tips to

    296

    See Setting Up Your Environment on tips to

    229297 simplify working with the LLVM front-end and compiled tools. See the
    230298 other sub-sections below for other useful details in working with LLVM,
    231299 or go straight to Program Layout to learn about the
    232 layout of the source code tree.
    300 layout of the source code tree. For information on building the C front
    301 end yourself, see Compiling the LLVM C Front End for
    302 information.
    233303
    234304
    235305

    Terminology and Notation

    279349
    280350
    281351
    282

    Setting up your environment

    352

    Setting Up Your Environment

    283353
    284354
    285355

    295365 libraries that it will need for compilation.
    296366

    297367
    298
    PATH=${PATH}:OBJ_ROOT/llvm/tools/Debug
    299
    300 Adding this directory to the end of your path will allow the
    301 compilation of the C front end to find the LLVM tools. The LLVM tools
    302 are needed for the C front end compile.
    303

    304
    305
    CC=Pathname to your GCC compiler
    306
    307 The GCC compiler that you want to use must be the first C compiler in
    308 your PATH. Otherwise, set this variable so that
    309 configure will use the GCC compiler that you want to use.
    310

    311
    312
    CXX=Pathname to your GCC C++ compiler
    313
    314 The GCC compiler that you want to use must be the first C++ compiler in
    315 your PATH. Otherwise, set this variable so that
    316 configure will use the GCC compiler that you want to use.
    317

    318
    319
    CVSROOT=CVSROOT
    320
    321 This environment variable tells CVS where to find the CVS repository.
    322

    323
    324368
    alias llvmgcc LLVMGCCDIR/bin/llvm-gcc
    325369
    326370 This alias allows you to use the LLVM C front end without putting it in
    337381 file is a TAR archive that is compressed with the gzip program.
    338382

    339383
    340

    The four files are the following:

    384

    The four files are as follows:

    341385
    342386
    llvm.tar.gz
    343387
    This is the source code to the LLVM suite.
    355399
    This is the source code release of the C front end.
    356400

    357401
    358
    359

    360 To unpack the files, take each one, unzip it, and then untar it. A fast
    361 way to do that is with the following:
    362

    363
    364 gunzip --stdout name of file | tar -xvf -
    365
    366

    367 For example, to extract the LLVM source code, use the following command:
    368

    369
    370 gunzip --stdout llvm.tar.gz | tar -xvf -
    371402
    372403
    373404

    Checkout LLVM from CVS

    392423

    393424
    394425
    426

    Install the C Front End

    427
    428
    429

    430 Before configuring and compiling the LLVM suite, it is best to extract the
    431 LLVM C front end. While not used in building, the C front end is used by
    432 the LLVM test suite, and its location must be given to the
    433 configure script before the LLVM suite can be built.
    434

    435
    436

    437 To install the C front end, do the following:
    438
    439
  • cd where-you-want-the-front-end-to-live
  • 440
  • gunzip --stdout cfrontend.platform.tar.gz | tar -xvf
  • 441 -
    442
    443
    444
    395445

    Local LLVM Configuration

    396446
    397447
    401451 llvm/include/Config/config.h.
    402452
    403453

    404 The following environment variables are used by configure to
    405 configure Makefile.config:
    406

    407
    408
    409

  • CXX = Pathname of the C++ compiler to use.
  • 410

  • CC = Pathname of the C compiler to use.
  • 411
    412
    454 The following environment variables are used by the configure
    455 script to configure the build system:
    456

    457
    458
    459
    460 Variable
    461
    462 Purpose
    463
    464
    465
    466
    467 CC
    468
    469 Tells configure which C compiler to use. By default,
    470 configure will look for the first GCC compiler in
    471 PATH. Use this variable to override
    472 configure's default behavior.
    473
    474
    475
    476
    477 CXX
    478
    479 Tells configure which C++ compiler to use. By default,
    480 configure will look for the first GCC compiler in
    481 PATH. Use this variable to override
    482 configure's default behavior.
    483
    484
    485
    486
    487

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

    414490
    415491
    416492
    --with-objroot=OBJ_ROOT
    421497 within the source code tree. If left unspecified, the default value is
    422498 ..
    423499 (See the Section on
    424 The location for LLVM object files
    500 The Location of LLVM Object Files
    425501 for more information.)
    426502

    427503
    --with-llvmgccdir=LLVMGCCDIR
    479555 These builds are for use with profiling. They compile profiling
    480556 information into the code for use with programs like gprof.
    481557 Profile builds must be started by setting variables on the
    482 make command line.
    558 gmake command line.
    483559
    484560
    485561 Once you have LLVM configured, you can build it by entering the top level
    486562 llvm directory and issuing the following command:
    487563

    488 make
    564 gmake
    489565
    490566

    491567 If you have multiple processors in your machine, you may wish to use some
    494570

    495571
    496572

    497 make -j2
    573 gmake -j2
    498574
    499575

    500576 There are several other targets which are useful when working with the LLVM
    501577 source code:
    502578
    503579
    504
    make clean
    580
    gmake clean
    505581
    506582 Removes all files generated by the build. This includes object files,
    507583 generated C/C++ files, libraries, and executables.
    508584

    509585
    510
    make distclean
    511
    512 Removes everything that make clean does, but also removes
    586
    gmake distclean
    587
    588 Removes everything that gmake clean does, but also removes
    513589 files generated by configure. It attempts to return the
    514590 source tree to the original state in which it was shipped.
    515591

    519595 declaring variables on the command line. The following are some examples:
    520596
    521597
    522
    make ENABLE_OPTIMIZED=1
    598
    gmake ENABLE_OPTIMIZED=1
    523599
    524600 Perform a Release (Optimized) build.
    525601

    526602
    527
    make ENABLE_PROFILING=1
    603
    gmake ENABLE_PROFILING=1
    528604
    529605 Perform a Profiling build.
    530606

    531607
    532
    make VERBOSE=1
    533
    534 Print what make is doing on standard output.
    608
    gmake VERBOSE=1
    609
    610 Print what gmake is doing on standard output.
    535611

    536612
    537613
    538614 Every directory in the LLVM source tree includes a Makefile to
    539615 build it and any subdirectories that it contains. Entering any directory
    540 inside the LLVM source tree and typing make should rebuild
    616 inside the LLVM source tree and typing gmake should rebuild
    541617 anything in or below that directory that is out of date.
    542618
    543619
    544

    Compiling the LLVM C Front End

    545
    546
    547
    548

    549 This step is optional if you have the C front end binary distrubtion for
    550 your platform.
    551

    552
    553
    554 Now that you have the LLVM Suite built, you can build the C front end. For
    555 those of you that have built GCC before, the process is very similar.
    556

    557 Be forewarned, though: the build system for the C front end is not as
    558 polished as the rest of the LLVM code, so there will be many warnings and
    559 errors that you will need to ignore for now:
    560
    561
    562
  • Ensure that OBJ_ROOT/llvm/tools/Debug is at the
  • 563 end of your PATH environment variable.
    564
    565
  • cd GCCOBJ
  • 566
    567
  • Configure the source code:
  • 568
    569
  • On Linux/x86, use
  • 570
    571
  • GCCSRC/configure --prefix=LLVMGCCDIR
  • 572 --enable-languages=c
    573
    574
    575
  • On Solaris/Sparc, use
  • 576
    577
  • GCCSRC/configure --prefix=LLVMGCCDIR
  • 578 --enable-languages=c --target=sparcv9-sun-solaris2
    579
    580
    581
    582
  • make
  • 583
    584
  • The build will eventually fail. Don't worry; chances are good that
  • 585 everything that needed to build is built.
    586
    587
  • make -k install
  • 588
    589
    590 At this point, you should have a working copy of the LLVM C front end
    591 installed in LLVMGCCDIR.
    592
    593
    594

    The location for LLVM object files

    620

    The Location of LLVM Object Files

    595621
    596622
    597623

    The LLVM build system sends most output files generated during the build

    824850 what an analysis does.

    825851
    826852
    827
    828
    829

    An example using the LLVM tool chain

    853
    854
    855

    Compiling the LLVM C Front End

    856
    857
    858

    859
    860 This step is optional if you have the C front end binary distrubtion for
    861 your platform.
    862
    863

    864
    865 Now that you have the LLVM suite built, you can build the C front end. For
    866 those of you that have built GCC before, the process is very similar.
    867

    868 Be forewarned, though: the build system for the C front end is not as
    869 polished as the rest of the LLVM code, so there will be many warnings and
    870 errors that you will need to ignore for now:
    871
    872
    873
  • Ensure that OBJ_ROOT/llvm/tools/Debug is at the
  • 874 end of your PATH environment variable. The front end
    875 build needs to know where to find the LLVM tools, but you want to
    876 ensure that these tools are not found before the system assembler and
    877 linker that you normally use for compilation.
    878
    879
  • cd GCCOBJ
  • 880
    881
  • Configure the source code:
  • 882
    883
  • On Linux/x86, use
  • 884
    885
  • GCCSRC/configure --prefix=LLVMGCCDIR
  • 886 --enable-languages=c
    887
    888
    889
  • On Solaris/Sparc, use
  • 890
    891
  • GCCSRC/configure --prefix=LLVMGCCDIR
  • 892 --enable-languages=c --target=sparcv9-sun-solaris2
    893
    894
    895
    896
  • gmake
  • 897
    898
  • The build will eventually fail. Don't worry; chances are good that
  • 899 everything that needed to build is built.
    900
    901
  • gmake -k install
  • 902
    903
    904

    905 Once this is done, you should have a built front end compiler in
    906 LLVMGCCDIR.
    907

    908
    909
    910

    911
    An Example Using the LLVM Tool Chain
    912
    830913
    831914
    832915
    880963
    881964
    882965
    883

    Common Problems

    966

    967
    Common Problems
    968
    884969
    885970
    886971 Below are common problems and their remedies:
    9321017
    9331018
    9341019
    935

    <a name="links">Links>

    1020

    <center>Links>

    9361021
    9371022
    9381023

    This document is just an introduction to how to use LLVM to do