Lines Matching full:llvm
2 Getting Started with the LLVM System
11 Welcome to LLVM! In order to get started, you first need to know some basic
14 First, LLVM comes in three pieces. The first piece is the LLVM suite. This
15 contains all of the tools, libraries, and header files needed to use LLVM. It
17 also contains basic regression tests that can be used to test the LLVM tools and
20 The second piece is the `Clang <http://clang.llvm.org/>`_ front end. This
21 component compiles C, C++, Objective C, and Objective C++ code into LLVM
22 bitcode. Once compiled into LLVM bitcode, a program can be manipulated with the
23 LLVM tools from the LLVM suite.
26 with a testing harness that can be used to further test LLVM's functionality
32 The LLVM Getting Started documentation may be out of date. So, the `Clang
33 Getting Started <http://clang.llvm.org/get_started.html>`_ page might also be a
36 Here's the short story for getting up and running quickly with LLVM:
41 #. Checkout LLVM:
43 * ``cd where-you-want-llvm-to-live``
44 * ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm``
48 * ``cd where-you-want-llvm-to-live``
49 * ``cd llvm/tools``
50 * ``svn co http://llvm.org/svn/llvm-project/cfe/trunk clang``
54 * ``cd where-you-want-llvm-to-live``
55 * ``cd llvm/projects``
56 * ``svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt``
60 * ``cd where-you-want-llvm-to-live``
61 * ``cd llvm/projects``
62 * ``svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite``
64 #. Configure and build LLVM and Clang:
66 * ``cd where-you-want-to-build-llvm``
69 * ``../llvm/configure [options]``
73 where you want the LLVM tools and libraries to be installed (default
83 simultaneously. This builds both LLVM and Clang for Debug+Asserts mode.
98 Consult the `Getting Started with LLVM`_ section for detailed information on
99 configuring and compiling LLVM. See `Setting Up Your Environment`_ for tips
100 that simplify working with the Clang front end and LLVM tools. Go to `Program
106 Before you begin to use the LLVM system, review the requirements given below.
113 LLVM is known to work on the following host platforms:
137 #. To use LLVM modules on Win32-based system, you may configure LLVM
141 Note that you will need about 1-3 GB of space for a full LLVM build in Debug
148 The LLVM suite *may* compile on other platforms, but it is not guaranteed to do
149 so. If compilation is successful, the LLVM utilities should be able to
150 assemble, disassemble, analyze, and optimize LLVM bitcode. Code generation
157 Compiling LLVM requires that you have several software packages installed. The
159 for the software package that LLVM depends on. The Version column provides
160 "known to work" versions of the package. The Notes column describes how LLVM
179 other languages for LLVM's purposes. See `below` for specific version
182 ``llvm/test`` directory.
186 #. Optional, adds compression / uncompression capabilities to selected LLVM
223 LLVM is very demanding of the host C++ compiler, and as such tends to expose
227 order to build LLVM.
239 miscompiled LLVM.
242 recent version may be required to support all of the C++ features used in LLVM.
247 **GCC 4.6.3 on ARM**: Miscompiles ``llvm-readobj`` at ``-O3``. A test failure
257 times (minutes instead of seconds) when building LLVM. We recommend upgrading
262 intermittent failures when building LLVM with position independent code. The
269 recommend using the system GCC to compile LLVM and Clang in this case.
349 .. _Getting Started with LLVM:
351 Getting Started with LLVM
354 The remainder of this guide is meant to get you up and running with LLVM and to
355 give you some basic information about the LLVM environment.
357 The later sections of this guide describe the `general layout`_ of the LLVM
358 source tree, a `simple example`_ using the LLVM tool chain, and `links`_ to find
359 more information about LLVM or to get help via e-mail.
372 This is the top level directory of the LLVM source tree.
376 This is the top level directory of the LLVM object tree (i.e. the tree where
385 In order to compile and use LLVM, you may need to set some environment
390 [Optional] This environment variable helps LLVM linking tools find the
396 Unpacking the LLVM Archives
399 If you have the LLVM distribution, you will need to unpack it before you can
400 begin to compile it. LLVM is distributed as a set of two files: the LLVM suite
401 and the LLVM GCC front end compiled for your platform. There is an additional
407 ``llvm-x.y.tar.gz``
409 Source release for the LLVM libraries and tools.
411 ``llvm-test-x.y.tar.gz``
413 Source release for the LLVM test-suite.
417 Checkout LLVM from Subversion
424 * ``cd where-you-want-llvm-to-live``
425 * Read-Only: ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm``
426 * Read-Write:``svn co https://user@llvm.org/svn/llvm-project/llvm/trunk llvm``
428 This will create an '``llvm``' directory in the current directory and fully
429 populate it with the LLVM source code, Makefiles, test directories, and local
463 If you would like to get the LLVM test suite (a separate package as of 1.4), you
468 % cd llvm/projects
469 % svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite
471 By placing it in the ``llvm/projects``, it will be automatically configured by
472 the LLVM configure script as well as automatically updated when you run ``svn
478 Git mirrors are available for a number of LLVM subprojects. These mirrors sync
482 clone of LLVM via:
486 % git clone http://llvm.org/git/llvm.git
492 % cd llvm/tools
493 % git clone http://llvm.org/git/clang.git
499 % cd llvm/projects
500 % git clone http://llvm.org/git/compiler-rt.git
506 % cd llvm/projects
507 % git clone http://llvm.org/git/test-suite.git
579 % git clone http://llvm.org/git/llvm.git
580 % cd llvm
581 % git svn init https://llvm.org/svn/llvm-project/llvm/trunk --username=<username>
587 % git clone http://llvm.org/git/clang.git
589 % git svn init https://llvm.org/svn/llvm-project/cfe/trunk --username=<username>
613 For those who wish to be able to update an llvm repo/revert patches easily using
651 Local LLVM Configuration
654 Once checked out from the Subversion repository, the LLVM suite source code must
656 various ``*.in`` files, most notably ``llvm/Makefile.config`` and
657 ``llvm/include/Config/config.h``. It also populates *OBJ_ROOT* with the
658 Makefiles needed to begin building LLVM.
678 The following options can be used to set or enable LLVM specific options:
684 are using the LLVM distribution. The default behavior of a Subversion
718 LLVM can use external disassembler library for various purposes (now it's used
723 To configure LLVM, follow these steps:
731 #. Run the ``configure`` script located in the LLVM source tree:
737 Compiling the LLVM Suite Source Code
740 Once you have configured LLVM, you can build it. There are three types of
748 debugging information. To get a Debug Build using the LLVM distribution the
758 when using an LLVM distribution.
766 Once you have LLVM configured, you can build it by entering the *OBJ_ROOT*
774 GCC that is known not to compile LLVM.
784 There are several special targets which are useful when working with the LLVM
800 Installs LLVM header files, libraries, tools, and documentation in a hierarchy
806 Assuming you built LLVM into $OBJDIR, when this command is run, it will
842 Every directory in the LLVM object tree includes a ``Makefile`` to build it and
843 any subdirectories that it contains. Entering any directory inside the LLVM
848 LLVM's (non-Doxygen) documentation is produced with the
857 `Sphinx Introduction for LLVM Developers
858 <http://lld.llvm.org/sphinx_intro.html>`_.
859 After following the instructions there for installing Sphinx, build the LLVM
869 This directory corresponds to ``llvm.org/docs``.
871 ``llvm.org/docs/SphinxQuickstartTemplate.html``.
874 Cross-Compiling LLVM
877 It is possible to cross-compile LLVM itself. That is, you can create LLVM
888 <http://clang.llvm.org/docs/CrossCompilation.html>`_ for more information
891 The Location of LLVM Object Files
894 The LLVM build system is capable of sharing a single LLVM source tree among
895 several LLVM builds. Hence, it is possible to build LLVM for several different
900 * Change directory to where the LLVM object files should live:
906 * Run the ``configure`` script found in the LLVM source directory:
912 The LLVM build will place files underneath *OBJ_ROOT* in directories named after
951 execute LLVM bitcode files directly. To do this, use commands like this (the
957 % echo ':llvm:M::BC::/path/to/lli:' > /proc/sys/fs/binfmt_misc/register
961 This allows you to execute LLVM bitcode files directly. On Debian, you can also
966 % sudo update-binfmts --install llvm /path/to/lli --magic 'BC'
974 One useful source of information about the LLVM source base is the LLVM `doxygen
976 `<http://llvm.org/doxygen/>`_. The following is a brief introduction to code
979 ``llvm/examples``
982 This directory contains some simple examples of how to use the LLVM IR and JIT.
984 ``llvm/include``
987 This directory contains public header files exported from the LLVM library. The
990 ``llvm/include/llvm``
992 This directory contains all of the LLVM specific header files. This directory
993 also has subdirectories for different portions of LLVM: ``Analysis``,
996 ``llvm/include/llvm/Support``
998 This directory contains generic support libraries that are provided with LLVM
999 but not necessarily specific to LLVM. For example, some C++ STL utilities and
1002 ``llvm/include/llvm/Config``
1009 ``llvm/lib``
1012 This directory contains most of the source files of the LLVM system. In LLVM,
1016 ``llvm/lib/VMCore/``
1018 This directory holds the core LLVM source files that implement core classes
1021 ``llvm/lib/AsmParser/``
1023 This directory holds the source code for the LLVM assembly language parser
1026 ``llvm/lib/Bitcode/``
1028 This directory holds code for reading and write LLVM bitcode.
1030 ``llvm/lib/Analysis/``
1036 ``llvm/lib/Transforms/``
1038 This directory contains the source code for the LLVM to LLVM program
1043 ``llvm/lib/Target/``
1046 code generation. For example, the ``llvm/lib/Target/X86`` directory holds the
1047 X86 machine description while ``llvm/lib/Target/ARM`` implements the ARM
1050 ``llvm/lib/CodeGen/``
1055 ``llvm/lib/MC/``
1059 ``llvm/lib/Debugger/``
1062 possible to instrument LLVM programs so that a debugger could identify source
1065 ``llvm/lib/ExecutionEngine/``
1067 This directory contains libraries for executing LLVM bitcode directly at
1070 ``llvm/lib/Support/``
1073 located in ``llvm/include/ADT/`` and ``llvm/include/Support/``.
1075 ``llvm/projects``
1078 This directory contains projects that are not strictly part of LLVM but are
1079 shipped with LLVM. This is also the directory where you should create your own
1080 LLVM-based projects.
1082 ``llvm/runtime``
1085 This directory contains libraries which are compiled into LLVM bitcode and used
1090 Unlike the rest of the LLVM suite, this directory needs the LLVM GCC front end
1093 ``llvm/test``
1097 checks on the LLVM infrastructure. These are intended to run quickly and cover a
1103 This is not a directory in the normal llvm module; it is a separate Subversion
1106 suite for LLVM. It is a separate Subversion module because not every LLVM user
1113 ``llvm/tools``
1130 ``llvm-ar``
1132 The archiver produces an archive containing the given LLVM bitcode files,
1135 ``llvm-as``
1137 The assembler transforms the human readable LLVM assembly to LLVM bitcode.
1139 ``llvm-dis``
1141 The disassembler transforms the LLVM bitcode to human readable LLVM assembly.
1143 ``llvm-link``
1145 ``llvm-link``, not surprisingly, links multiple LLVM modules into a single
1150 ``lli`` is the LLVM interpreter, which can directly execute LLVM bitcode
1158 ``llc`` is the LLVM backend compiler, which translates LLVM bitcode to a
1163 ``opt`` reads LLVM bitcode, applies a series of LLVM to LLVM transformations
1166 program transformations available in LLVM.
1168 ``opt`` can also be used to run a specific analysis on an input LLVM bitcode
1172 ``llvm/utils``
1175 This directory contains utilities for working with LLVM source code, and some of
1177 are code generators for parts of LLVM infrastructure.
1190 with Emacs and XEmacs editors, providing syntax highlighting support for LLVM
1199 for example: ``xemacs `utils/getsources.sh``` from the top of your LLVM source
1204 This little tool performs an ``egrep -H -n`` on each source file in LLVM and
1213 you are in the directory ``llvm/lib/Target/Sparc``, if ``makellvm`` is in your
1215 directory, switch to directory ``llvm/tools/llc`` and build it, causing a
1227 the VIM editor, providing syntax highlighting support for LLVM assembly files
1233 An Example Using the LLVM Tool Chain
1236 This section gives an example of using LLVM with the Clang front end.
1263 #. Next, compile the C file into an LLVM bitcode file:
1267 % clang -O3 -emit-llvm hello.c -c -o hello.bc
1269 The -emit-llvm option can be used with the -S or -c options to emit an LLVM
1271 the `standard LLVM tools <CommandGuide/index.html>`_ on the bitcode file.
1285 The second examples shows how to invoke the LLVM JIT, :doc:`lli
1288 #. Use the ``llvm-dis`` utility to take a look at the LLVM assembly code:
1292 % llvm-dis < hello.bc | less
1315 ``-emit-llvm`` option is not present) does steps 6/7/8 for you.
1320 If you are having problems building or using LLVM, or if you have any other
1321 general questions about LLVM, please consult the `Frequently Asked
1329 This document is just an **introduction** on how to use LLVM to do some simple
1332 write something up!). For more information about LLVM, check out:
1334 * `LLVM Homepage <http://llvm.org/>`_
1335 * `LLVM Doxygen Tree <http://llvm.org/doxygen/>`_
1336 * `Starting a Project that Uses LLVM <http://llvm.org/docs/Projects.html>`_