Skip to content

Commit 7d84e5c

Browse files
[llvm] Proofread AdvancedBuilds.rst (llvm#155207)
1 parent e9045b3 commit 7d84e5c

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

llvm/docs/AdvancedBuilds.rst

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ Bootstrap Builds
3030
================
3131

3232
The Clang CMake build system supports bootstrap (aka multi-stage) builds. At a
33-
high level a multi-stage build is a chain of builds that pass data from one
33+
high level, a multi-stage build is a chain of builds that pass data from one
3434
stage into the next. The most common and simple version of this is a traditional
3535
bootstrap build.
3636

3737
In a simple two-stage bootstrap build, we build clang using the system compiler,
3838
then use that just-built clang to build clang again. In CMake this simplest form
3939
of a bootstrap build can be configured with a single option,
40-
CLANG_ENABLE_BOOTSTRAP.
40+
``CLANG_ENABLE_BOOTSTRAP``.
4141

4242
.. code-block:: console
4343
@@ -52,9 +52,9 @@ configurations for each stage. The next series of examples utilize CMake cache
5252
scripts to provide more complex options.
5353

5454
By default, only a few CMake options will be passed between stages.
55-
The list, called _BOOTSTRAP_DEFAULT_PASSTHROUGH, is defined in clang/CMakeLists.txt.
56-
To force the passing of the variables between stages, use the -DCLANG_BOOTSTRAP_PASSTHROUGH
57-
CMake option, each variable separated by a ";". As example:
55+
The list, called _BOOTSTRAP_DEFAULT_PASSTHROUGH, is defined in ``clang/CMakeLists.txt``.
56+
To force the passing of the variables between stages, use the ``-DCLANG_BOOTSTRAP_PASSTHROUGH``
57+
CMake option, each variable separated by a ";". For example:
5858

5959
.. code-block:: console
6060
@@ -65,9 +65,9 @@ CMake option, each variable separated by a ";". As example:
6565
<path to source>/llvm
6666
$ ninja stage2
6767
68-
CMake options starting by ``BOOTSTRAP_`` will be passed only to the stage2 build.
68+
CMake options starting with ``BOOTSTRAP_`` will be passed only to the stage2 build.
6969
This gives the opportunity to use Clang specific build flags.
70-
For example, the following CMake call will enabled '-fno-addrsig' only during
70+
For example, the following CMake call will enable ``-fno-addrsig`` only during
7171
the stage2 build for C and C++.
7272

7373
.. code-block:: console
@@ -77,7 +77,7 @@ the stage2 build for C and C++.
7777
The clang build system refers to builds as stages. A stage1 build is a standard
7878
build using the compiler installed on the host, and a stage2 build is built
7979
using the stage1 compiler. This nomenclature holds up to more stages too. In
80-
general a stage*n* build is built using the output from stage*n-1*.
80+
general, a stage*n* build is built using the output from stage*n-1*.
8181

8282
Apple Clang Builds (A More Complex Bootstrap)
8383
=============================================
@@ -90,7 +90,7 @@ compiler is a balance of optimization vs build time because it is a throwaway.
9090
The stage2 compiler is the fully optimized compiler intended to ship to users.
9191

9292
Setting up these compilers requires a lot of options. To simplify the
93-
configuration the Apple Clang build settings are contained in CMake Cache files.
93+
configuration, the Apple Clang build settings are contained in CMake Cache files.
9494
You can build an Apple Clang compiler using the following commands:
9595

9696
.. code-block:: console
@@ -99,7 +99,7 @@ You can build an Apple Clang compiler using the following commands:
9999
$ ninja stage2-distribution
100100
101101
This CMake invocation configures the stage1 host compiler, and sets
102-
CLANG_BOOTSTRAP_CMAKE_ARGS to pass the Apple-stage2.cmake cache script to the
102+
``CLANG_BOOTSTRAP_CMAKE_ARGS`` to pass the Apple-stage2.cmake cache script to the
103103
stage2 configuration step.
104104

105105
When you build the stage2-distribution target it builds the minimal stage1
@@ -113,16 +113,16 @@ build configurations.
113113
Multi-stage PGO
114114
===============
115115

116-
Profile-Guided Optimizations (PGO) is a really great way to optimize the code
116+
Profile-Guided Optimization (PGO) is a really great way to optimize the code
117117
clang generates. Our multi-stage PGO builds are a workflow for generating PGO
118118
profiles that can be used to optimize clang.
119119

120120
At a high level, the way PGO works is that you build an instrumented compiler,
121121
then you run the instrumented compiler against sample source files. While the
122122
instrumented compiler runs it will output a bunch of files containing
123-
performance counters (.profraw files). After generating all the profraw files
123+
performance counters (``.profraw`` files). After generating all the profraw files
124124
you use llvm-profdata to merge the files into a single profdata file that you
125-
can feed into the LLVM_PROFDATA_FILE option.
125+
can feed into the ``LLVM_PROFDATA_FILE`` option.
126126

127127
Our PGO.cmake cache automates that whole process. You can use it for
128128
configuration with CMake with the following command:
@@ -133,11 +133,11 @@ configuration with CMake with the following command:
133133
<path to source>/llvm
134134
135135
There are several additional options that the cache file also accepts to modify
136-
the build, particularly the PGO_INSTRUMENT_LTO option. Setting this option to
136+
the build, particularly the ``PGO_INSTRUMENT_LTO`` option. Setting this option to
137137
Thin or Full will enable ThinLTO or full LTO respectively, further enhancing
138138
the performance gains from a PGO build by enabling interprocedural
139139
optimizations. For example, to run a CMake configuration for a PGO build
140-
that also enables ThinTLO, use the following command:
140+
that also enables ThinLTO, use the following command:
141141

142142
.. code-block:: console
143143
@@ -149,10 +149,10 @@ By default, clang will generate profile data by compiling a simple
149149
hello world program. You can also tell clang use an external
150150
project for generating profile data that may be a better fit for your
151151
use case. The project you specify must either be a lit test suite
152-
(use the CLANG_PGO_TRAINING_DATA option) or a CMake project (use the
153-
CLANG_PERF_TRAINING_DATA_SOURCE_DIR option).
152+
(use the ``CLANG_PGO_TRAINING_DATA`` option) or a CMake project (use the
153+
``CLANG_PERF_TRAINING_DATA_SOURCE_DIR`` option).
154154

155-
For example, If you wanted to use the
155+
For example, if you wanted to use the
156156
`LLVM Test Suite <https://github.com/llvm/llvm-test-suite/>`_ to generate
157157
profile data you would use the following command:
158158

@@ -162,8 +162,8 @@ profile data you would use the following command:
162162
-DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR=<path to llvm-test-suite> \
163163
-DBOOTSTRAP_CLANG_PGO_TRAINING_DEPS=runtimes
164164
165-
The BOOTSTRAP\_ prefixes tells CMake to pass the variables on to the instrumented
166-
stage two build. And the CLANG_PGO_TRAINING_DEPS option let's you specify
165+
The ``BOOTSTRAP\_`` prefix tells CMake to pass the variables on to the instrumented
166+
stage two build. And the ``CLANG_PGO_TRAINING_DEPS`` option let's you specify
167167
additional build targets to build before building the external project. The
168168
LLVM Test Suite requires compiler-rt to build, so we need to add the
169169
`runtimes` target as a dependency.
@@ -182,7 +182,7 @@ build directory. This takes a really long time because it builds clang twice,
182182
and you *must* have compiler-rt in your build tree.
183183

184184
This process uses any source files under the perf-training directory as training
185-
data as long as the source files are marked up with LIT-style RUN lines.
185+
data as long as the source files are marked up with LIT-style ``RUN`` lines.
186186

187187
After it finishes you can use :code:`find . -name clang.profdata` to find it, but it
188188
should be at a path something like:
@@ -191,7 +191,7 @@ should be at a path something like:
191191
192192
<build dir>/tools/clang/stage2-instrumented-bins/utils/perf-training/clang.profdata
193193
194-
You can feed that file into the LLVM_PROFDATA_FILE option when you build your
194+
You can feed that file into the ``LLVM_PROFDATA_FILE`` option when you build your
195195
optimized compiler.
196196

197197
It may be necessary to build additional targets before running perf training, such as
@@ -214,7 +214,7 @@ The PGO cache generates the following additional targets:
214214

215215
**stage2-instrumented-generate-profdata**
216216
Depends on stage2-instrumented and will use the instrumented compiler to
217-
generate profdata based on the training files in clang/utils/perf-training
217+
generate profdata based on the training files in ``clang/utils/perf-training``
218218

219219
**stage2**
220220
Depends on stage2-instrumented-generate-profdata and will use the stage1
@@ -257,11 +257,11 @@ Then, build the BOLT-optimized binary by running the following ninja command:
257257
$ ninja clang-bolt
258258
259259
If you're seeing errors in the build process, try building with a recent
260-
version of Clang/LLVM by setting the CMAKE_C_COMPILER and
261-
CMAKE_CXX_COMPILER flags to the appropriate values.
260+
version of Clang/LLVM by setting the ``CMAKE_C_COMPILER`` and
261+
``CMAKE_CXX_COMPILER`` flags to the appropriate values.
262262

263263
It is also possible to use BOLT on top of PGO and (Thin)LTO for an even more
264-
significant runtime speedup. To configure a three stage PGO build with ThinLTO
264+
significant runtime speedup. To configure a three-stage PGO build with ThinLTO
265265
that optimizes the resulting binary with BOLT, use the following CMake
266266
configuration command:
267267

@@ -282,14 +282,14 @@ Then, to build the final optimized binary, build the stage2-clang-bolt target:
282282
3-Stage Non-Determinism
283283
=======================
284284

285-
In the ancient lore of compilers non-determinism is like the multi-headed hydra.
285+
In the ancient lore of compilers, non-determinism is like the multi-headed hydra.
286286
Whenever its head pops up, terror and chaos ensue.
287287

288-
Historically one of the tests to verify that a compiler was deterministic would
289-
be a three stage build. The idea of a three stage build is you take your sources
288+
Historically, one of the tests to verify that a compiler was deterministic would
289+
be a three-stage build. The idea of a three-stage build is that you take your sources
290290
and build a compiler (stage1), then use that compiler to rebuild the sources
291291
(stage2), then you use that compiler to rebuild the sources a third time
292-
(stage3) with an identical configuration to the stage2 build. At the end of
292+
(stage3) with a configuration identical to the stage2 build. At the end of
293293
this, you have a stage2 and stage3 compiler that should be bit-for-bit
294294
identical.
295295

@@ -301,4 +301,4 @@ following commands:
301301
$ cmake -G Ninja -C <path to source>/clang/cmake/caches/3-stage.cmake <path to source>/llvm
302302
$ ninja stage3
303303
304-
After the build you can compare the stage2 and stage3 compilers.
304+
After the build, you can compare the stage2 and stage3 compilers.

0 commit comments

Comments
 (0)