|
3 | 3 | This directory and its subdirectories contain source code for LLVM, |
4 | 4 | a toolkit for the construction of highly optimized compilers, |
5 | 5 | optimizers, and runtime environments. |
| 6 | + |
| 7 | +## Getting Started with the LLVM System |
| 8 | + |
| 9 | +Taken from https://llvm.org/docs/GettingStarted.html. |
| 10 | + |
| 11 | +### Overview |
| 12 | + |
| 13 | +Welcome to the LLVM project! |
| 14 | + |
| 15 | +The LLVM project has multiple components. The core of the project is |
| 16 | +itself called "LLVM". This contains all of the tools, libraries, and header |
| 17 | +files needed to process intermediate representations and converts it into |
| 18 | +object files. Tools include an assembler, disassembler, bitcode analyzer, and |
| 19 | +bitcode optimizer. It also contains basic regression tests. |
| 20 | + |
| 21 | +C-like languages use the [Clang](http://clang.llvm.org/) front end. This |
| 22 | +component compiles C, C++, Objective C, and Objective C++ code into LLVM bitcode |
| 23 | +-- and from there into object files, using LLVM. |
| 24 | + |
| 25 | +Other components include: |
| 26 | +the [libc++ C++ standard library](https://libcxx.llvm.org), |
| 27 | +the [LLD linker](https://lld.llvm.org), and more. |
| 28 | + |
| 29 | +### Getting the Source Code and Building LLVM |
| 30 | + |
| 31 | +The LLVM Getting Started documentation may be out of date. The [Clang |
| 32 | +Getting Started](http://clang.llvm.org/get_started.html) page might have more |
| 33 | +accurate information. |
| 34 | + |
| 35 | +This is an example workflow and configuration to get and build the LLVM source: |
| 36 | + |
| 37 | +1. Checkout LLVM (including related subprojects like Clang): |
| 38 | + |
| 39 | + * ``git clone https://github.com/llvm/llvm-project.git`` |
| 40 | + |
| 41 | + * Or, on windows, ``git clone --config core.autocrlf=false |
| 42 | + https://github.com/llvm/llvm-project.git`` |
| 43 | + |
| 44 | +2. Configure and build LLVM and Clang: |
| 45 | + |
| 46 | + * ``cd llvm-project`` |
| 47 | + |
| 48 | + * ``mkdir build`` |
| 49 | + |
| 50 | + * ``cd build`` |
| 51 | + |
| 52 | + * ``cmake -G <generator> [options] ../llvm`` |
| 53 | + |
| 54 | + Some common generators are: |
| 55 | + |
| 56 | + * ``Ninja`` --- for generating [Ninja](https://ninja-build.org) |
| 57 | + build files. Most llvm developers use Ninja. |
| 58 | + * ``Unix Makefiles`` --- for generating make-compatible parallel makefiles. |
| 59 | + * ``Visual Studio`` --- for generating Visual Studio projects and |
| 60 | + solutions. |
| 61 | + * ``Xcode`` --- for generating Xcode projects. |
| 62 | + |
| 63 | + Some Common options: |
| 64 | + |
| 65 | + * ``-DLLVM_ENABLE_PROJECTS='...'`` --- semicolon-separated list of the LLVM |
| 66 | + subprojects you'd like to additionally build. Can include any of: clang, |
| 67 | + clang-tools-extra, libcxx, libcxxabi, libunwind, lldb, compiler-rt, lld, |
| 68 | + polly, or debuginfo-tests. |
| 69 | + |
| 70 | + For example, to build LLVM, Clang, libcxx, and libcxxabi, use |
| 71 | + ``-DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi"``. |
| 72 | + |
| 73 | + * ``-DCMAKE_INSTALL_PREFIX=directory`` --- Specify for *directory* the full |
| 74 | + pathname of where you want the LLVM tools and libraries to be installed |
| 75 | + (default ``/usr/local``). |
| 76 | + |
| 77 | + * ``-DCMAKE_BUILD_TYPE=type`` --- Valid options for *type* are Debug, |
| 78 | + Release, RelWithDebInfo, and MinSizeRel. Default is Debug. |
| 79 | + |
| 80 | + * ``-DLLVM_ENABLE_ASSERTIONS=On`` --- Compile with assertion checks enabled |
| 81 | + (default is Yes for Debug builds, No for all other build types). |
| 82 | + |
| 83 | + * Run your build tool of choice! |
| 84 | + |
| 85 | + * The default target (i.e. ``ninja`` or ``make``) will build all of LLVM. |
| 86 | + |
| 87 | + * The ``check-all`` target (i.e. ``ninja check-all``) will run the |
| 88 | + regression tests to ensure everything is in working order. |
| 89 | + |
| 90 | + * CMake will generate build targets for each tool and library, and most |
| 91 | + LLVM sub-projects generate their own ``check-<project>`` target. |
| 92 | + |
| 93 | + * Running a serial build will be *slow*. To improve speed, try running a |
| 94 | + parallel build. That's done by default in Ninja; for ``make``, use |
| 95 | + ``make -j NNN`` (NNN is the number of parallel jobs, use e.g. number of |
| 96 | + CPUs you have.) |
| 97 | + |
| 98 | + * For more information see [CMake](https://llvm.org/docs/CMake.html) |
| 99 | + |
| 100 | +Consult the |
| 101 | +[Getting Started with LLVM](https://llvm.org/docs/GettingStarted.html#getting-started-with-llvm) |
| 102 | +page for detailed information on configuring and compiling LLVM. You can visit |
| 103 | +[Directory Layout](https://llvm.org/docs/GettingStarted.html#directory-layout) |
| 104 | +to learn about the layout of the source code tree. |
0 commit comments