Skip to content

Commit 65548ff

Browse files
committed
[docs] Update README and GettingStarted
Funnel fetching and building LLVM instructions into GettingStarted. Modernize the build steps a little. Remove comments saying CMAKE_BUILD_TYPE defaults to Debug as that's not true anymore (must explicitly pass it). Reviewed By: MaskRay, hans Differential Revision: https://reviews.llvm.org/D145413
1 parent 2afce71 commit 65548ff

File tree

3 files changed

+51
-127
lines changed

3 files changed

+51
-127
lines changed

README.md

+14-97
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
# The LLVM Compiler Infrastructure
22

3-
This directory and its sub-directories contain the source code for LLVM,
4-
a toolkit for the construction of highly optimized compilers,
5-
optimizers, and run-time environments.
6-
7-
The README briefly describes how to get started with building LLVM.
8-
For more information on how to contribute to the LLVM project, please
9-
take a look at the
10-
[Contributing to LLVM](https://llvm.org/docs/Contributing.html) guide.
11-
12-
## Getting Started with the LLVM System
13-
14-
Taken from [here](https://llvm.org/docs/GettingStarted.html).
15-
16-
### Overview
17-
183
Welcome to the LLVM project!
194

5+
This repository contains the source code for LLVM, a toolkit for the
6+
construction of highly optimized compilers, optimizers, and run-time
7+
environments.
8+
209
The LLVM project has multiple components. The core of the project is
2110
itself called "LLVM". This contains all of the tools, libraries, and header
2211
files needed to process intermediate representations and convert them into
2312
object files. Tools include an assembler, disassembler, bitcode analyzer, and
24-
bitcode optimizer. It also contains basic regression tests.
13+
bitcode optimizer.
2514

2615
C-like languages use the [Clang](http://clang.llvm.org/) frontend. This
2716
component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode
@@ -31,92 +20,20 @@ Other components include:
3120
the [libc++ C++ standard library](https://libcxx.llvm.org),
3221
the [LLD linker](https://lld.llvm.org), and more.
3322

34-
### Getting the Source Code and Building LLVM
35-
36-
The LLVM Getting Started documentation may be out of date. The [Clang
37-
Getting Started](http://clang.llvm.org/get_started.html) page might have more
38-
accurate information.
39-
40-
This is an example work-flow and configuration to get and build the LLVM source:
41-
42-
1. Checkout LLVM (including related sub-projects like Clang):
43-
44-
* ``git clone https://github.com/llvm/llvm-project.git``
45-
46-
* Or, on windows, ``git clone --config core.autocrlf=false
47-
https://github.com/llvm/llvm-project.git``
48-
49-
2. Configure and build LLVM and Clang:
50-
51-
* ``cd llvm-project``
52-
53-
* ``cmake -S llvm -B build -G <generator> [options]``
54-
55-
Some common build system generators are:
56-
57-
* ``Ninja`` --- for generating [Ninja](https://ninja-build.org)
58-
build files. Most llvm developers use Ninja.
59-
* ``Unix Makefiles`` --- for generating make-compatible parallel makefiles.
60-
* ``Visual Studio`` --- for generating Visual Studio projects and
61-
solutions.
62-
* ``Xcode`` --- for generating Xcode projects.
63-
64-
Some common options:
65-
66-
* ``-DLLVM_ENABLE_PROJECTS='...'`` and ``-DLLVM_ENABLE_RUNTIMES='...'`` ---
67-
semicolon-separated list of the LLVM sub-projects and runtimes you'd like to
68-
additionally build. ``LLVM_ENABLE_PROJECTS`` can include any of: clang,
69-
clang-tools-extra, cross-project-tests, flang, libc, libclc, lld, lldb,
70-
mlir, openmp, polly, or pstl. ``LLVM_ENABLE_RUNTIMES`` can include any of
71-
libcxx, libcxxabi, libunwind, compiler-rt, libc or openmp. Some runtime
72-
projects can be specified either in ``LLVM_ENABLE_PROJECTS`` or in
73-
``LLVM_ENABLE_RUNTIMES``.
74-
75-
For example, to build LLVM, Clang, libcxx, and libcxxabi, use
76-
``-DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"``.
77-
78-
* ``-DCMAKE_INSTALL_PREFIX=directory`` --- Specify for *directory* the full
79-
path name of where you want the LLVM tools and libraries to be installed
80-
(default ``/usr/local``). Be careful if you install runtime libraries: if
81-
your system uses those provided by LLVM (like libc++ or libc++abi), you
82-
must not overwrite your system's copy of those libraries, since that
83-
could render your system unusable. In general, using something like
84-
``/usr`` is not advised, but ``/usr/local`` is fine.
85-
86-
* ``-DCMAKE_BUILD_TYPE=type`` --- Valid options for *type* are Debug,
87-
Release, RelWithDebInfo, and MinSizeRel. Default is Debug.
88-
89-
* ``-DLLVM_ENABLE_ASSERTIONS=On`` --- Compile with assertion checks enabled
90-
(default is Yes for Debug builds, No for all other build types).
91-
92-
* ``cmake --build build [-- [options] <target>]`` or your build system specified above
93-
directly.
94-
95-
* The default target (i.e. ``ninja`` or ``make``) will build all of LLVM.
96-
97-
* The ``check-all`` target (i.e. ``ninja check-all``) will run the
98-
regression tests to ensure everything is in working order.
99-
100-
* CMake will generate targets for each tool and library, and most
101-
LLVM sub-projects generate their own ``check-<project>`` target.
102-
103-
* Running a serial build will be **slow**. To improve speed, try running a
104-
parallel build. That's done by default in Ninja; for ``make``, use the option
105-
``-j NNN``, where ``NNN`` is the number of parallel jobs to run.
106-
In most cases, you get the best performance if you specify the number of CPU threads you have.
107-
On some Unix systems, you can specify this with ``-j$(nproc)``.
108-
109-
* For more information see [CMake](https://llvm.org/docs/CMake.html).
23+
## Getting the Source Code and Building LLVM
11024

11125
Consult the
112-
[Getting Started with LLVM](https://llvm.org/docs/GettingStarted.html#getting-started-with-llvm)
113-
page for detailed information on configuring and compiling LLVM. You can visit
114-
[Directory Layout](https://llvm.org/docs/GettingStarted.html#directory-layout)
115-
to learn about the layout of the source code tree.
26+
[Getting Started with LLVM](https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm)
27+
page for information on building and running LLVM.
28+
29+
For information on how to contribute to the LLVM project, please take a look at
30+
the [Contributing to LLVM](https://llvm.org/docs/Contributing.html) guide.
11631

11732
## Getting in touch
11833

119-
Join [LLVM Discourse forums](https://discourse.llvm.org/), [discord chat](https://discord.gg/xS7Z362) or #llvm IRC channel on [OFTC](https://oftc.net/).
34+
Join the [LLVM Discourse forums](https://discourse.llvm.org/), [Discord
35+
chat](https://discord.gg/xS7Z362), or #llvm IRC channel on
36+
[OFTC](https://oftc.net/).
12037

12138
The LLVM project has adopted a [code of conduct](https://llvm.org/docs/CodeOfConduct.html) for
12239
participants to all modes of communication within the project.

llvm/docs/CMake.rst

-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ used variables that control features of LLVM and enabled subprojects.
191191

192192
**CMAKE_BUILD_TYPE**:STRING
193193
This configures the optimization level for ``make`` or ``ninja`` builds.
194-
The default ``CMAKE_BUILD_TYPE`` is set to ``Debug`` but you should
195-
carefully read the list below to figure out what configuration matches
196-
your use case the best.
197194

198195
Possible values:
199196

llvm/docs/GettingStarted.rst

+37-27
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,23 @@ the `LLD linker <https://lld.llvm.org>`_, and more.
2727
Getting the Source Code and Building LLVM
2828
=========================================
2929

30-
The LLVM Getting Started documentation may be out of date. The `Clang
31-
Getting Started <https://clang.llvm.org/get_started.html>`_ page might have more
32-
accurate information.
33-
34-
This is an example workflow and configuration to get and build the LLVM source:
35-
36-
#. Checkout LLVM (including related subprojects like Clang):
30+
#. Check out LLVM (including subprojects like Clang):
3731

3832
* ``git clone https://github.com/llvm/llvm-project.git``
39-
* Or, on windows, ``git clone --config core.autocrlf=false
33+
* Or, on windows:
34+
35+
``git clone --config core.autocrlf=false
4036
https://github.com/llvm/llvm-project.git``
4137
* To save storage and speed-up the checkout time, you may want to do a
4238
`shallow clone <https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---depthltdepthgt>`_.
4339
For example, to get the latest revision of the LLVM project, use
40+
4441
``git clone --depth 1 https://github.com/llvm/llvm-project.git``
4542

4643
#. Configure and build LLVM and Clang:
4744

4845
* ``cd llvm-project``
49-
* ``mkdir build``
50-
* ``cd build``
51-
* ``cmake -G <generator> -DCMAKE_BUILD_TYPE=<type> [options] ../llvm``
46+
* ``cmake -S llvm -B build -G <generator> [options]``
5247

5348
Some common build system generators are:
5449

@@ -59,27 +54,30 @@ This is an example workflow and configuration to get and build the LLVM source:
5954
solutions.
6055
* ``Xcode`` --- for generating Xcode projects.
6156

62-
Some Common options:
57+
* See the `CMake docs
58+
<https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html>`_
59+
for a more comprehensive list.
60+
61+
Some common options:
6362

6463
* ``-DLLVM_ENABLE_PROJECTS='...'`` --- semicolon-separated list of the LLVM
6564
subprojects you'd like to additionally build. Can include any of: clang,
66-
clang-tools-extra, lldb, compiler-rt, lld, polly, or cross-project-tests.
65+
clang-tools-extra, lldb, lld, polly, or cross-project-tests.
6766

68-
For example, to build LLVM, Clang, libcxx, and libcxxabi, use
69-
``-DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"``.
67+
For example, to build LLVM, Clang, and LLD, use
68+
``-DLLVM_ENABLE_PROJECTS="clang;lld"``.
7069

7170
* ``-DCMAKE_INSTALL_PREFIX=directory`` --- Specify for *directory* the full
7271
pathname of where you want the LLVM tools and libraries to be installed
7372
(default ``/usr/local``).
7473

75-
* ``-DCMAKE_BUILD_TYPE=type`` --- Controls optimization level and debug information
76-
of the build. The default value is ``Debug`` which fits people who want
77-
to work on LLVM or its libraries. ``Release`` is a better fit for most
78-
users of LLVM and Clang. For more detailed information see
79-
:ref:`CMAKE_BUILD_TYPE <cmake_build_type>`.
74+
* ``-DCMAKE_BUILD_TYPE=type`` --- Controls optimization level and debug
75+
information of the build. Valid options for *type* are ``Debug``,
76+
``Release``, ``RelWithDebInfo``, and ``MinSizeRel``. For more detailed
77+
information see :ref:`CMAKE_BUILD_TYPE <cmake_build_type>`.
8078

81-
* ``-DLLVM_ENABLE_ASSERTIONS=On`` --- Compile with assertion checks enabled
82-
(default is Yes for Debug builds, No for all other build types).
79+
* ``-DLLVM_ENABLE_ASSERTIONS=ON`` --- Compile with assertion checks enabled
80+
(default is ON for Debug builds, OFF for all other build types).
8381

8482
* ``cmake --build . [--target <target>]`` or the build system specified
8583
above directly.
@@ -98,10 +96,19 @@ This is an example workflow and configuration to get and build the LLVM source:
9896
option ``-j NN``, where ``NN`` is the number of parallel jobs, e.g. the
9997
number of available CPUs.
10098

101-
* For more information see `CMake <CMake.html>`__
99+
* A basic CMake and build/test invocation which only builds LLVM and no other
100+
subprojects:
101+
102+
``cmake -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug``
103+
104+
``ninja -C build check-llvm``
105+
106+
This will setup an LLVM build with debugging info, then compile LLVM and
107+
run LLVM tests.
108+
109+
* For more detailed information on CMake options, see `CMake <CMake.html>`__
102110

103-
* If you get an "internal compiler error (ICE)" or test failures, see
104-
`below`_.
111+
* If you get build or test failures, see `below`_.
105112

106113
Consult the `Getting Started with LLVM`_ section for detailed information on
107114
configuring and compiling LLVM. Go to `Directory Layout`_ to learn about the
@@ -601,8 +608,11 @@ used by people developing LLVM.
601608
| | out-of-tree targets. The default value includes: |
602609
| | ``AArch64, AMDGPU, ARM, AVR, BPF, Hexagon, Lanai, |
603610
| | Mips, MSP430, NVPTX, PowerPC, RISCV, Sparc, |
604-
| | SystemZ, WebAssembly, X86, XCore``. |
605-
| | |
611+
| | SystemZ, WebAssembly, X86, XCore``. Setting this |
612+
| | to ``"host"`` will only compile the host |
613+
| | architecture (e.g. equivalent to specifying ``X86``|
614+
| | on an x86 host machine) can |
615+
| | significantly speed up compile and test times. |
606616
+-------------------------+----------------------------------------------------+
607617
| LLVM_ENABLE_DOXYGEN | Build doxygen-based documentation from the source |
608618
| | code This is disabled by default because it is |

0 commit comments

Comments
 (0)