Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 055d438

Browse files
committed
[docs] Typographical and rewording fixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190333 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5bfc796 commit 055d438

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

docs/CrossCompilation.rst

+42-41
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ Cross-compilation using Clang/LLVM
55
Introduction
66
============
77

8-
This document will guide you in choosing the right cross-compilation options
9-
to hopefully help you target your code to a different architecture. It assumes
10-
you already know how to compile the code in question for the host architecture,
8+
This document will guide you in choosing the right Clang options
9+
for cross-compiling your code to a different architecture. It assumes you
10+
already know how to compile the code in question for the host architecture,
1111
and that you know how to choose additional include and library paths.
1212

13-
However, this document is `not` a `HowTo` and wont help you setting your build
14-
system or Makefiles, nor choosing the right CMake options. Also, it does not
15-
cover all the possible options, nor it contains specific examples for specific
16-
architectures. There are other documents in LLVM that do that in greater
17-
details (ex. http://llvm.org/docs/HowToCrossCompileLLVM.html).
13+
However, this document is *not* a "how to" and won't help you setting your
14+
build system or Makefiles, nor choosing the right CMake options, etc.
15+
Also, it does not cover all the possible options, nor does it contain
16+
specific examples for specific architectures. For a concrete example, the
17+
`instructions for cross-compiling LLVM itself
18+
<http://llvm.org/docs/HowToCrossCompileLLVM.html>`_ may be of interest.
1819

1920
After reading this document, you should be familiar with the main issues
20-
related to, and what main compiler options Clang provides for performing
21-
cross-compilation.
21+
related to cross-compilation, and what main compiler options Clang provides
22+
for performing cross-compilation.
2223

2324
Cross compilation issues
2425
========================
@@ -30,36 +31,36 @@ that compiler, that will know about its location and find all it needs to
3031
when compiling your code.
3132

3233
On the other hand, Clang/LLVM is natively a cross-compiler, meaning that
33-
one set of programs can compile to all targets by setting the -target
34-
option. That makes it a lot easier to programers wishing to compile to
35-
different platforms and architectures, and to compiler developers that
36-
only have to maintain one build system, and to OS distributions, that
34+
one set of programs can compile to all targets by setting the ``-target``
35+
option. That makes it a lot easier for programers wishing to compile to
36+
different platforms and architectures, and for compiler developers that
37+
only have to maintain one build system, and for OS distributions, that
3738
need only one set of main packages.
3839

3940
But, as is true to any cross-compiler, and given the complexity of
40-
different architectures, OSs and options, it's not always easy finding
41+
different architectures, OS's and options, it's not always easy finding
4142
the headers, libraries or binutils to generate target specific code.
4243
So you'll need special options to help Clang understand what target
43-
you're compiling to, where are your tools, etc.
44+
you're compiling to, where your tools are, etc.
4445

4546
Another problem is that compilers come with standard libraries only (like
46-
icompiler-rt, libcxx, libgcc, libm, etc), so you'll have to find and make
47-
available to the build system, every other library required to build your
48-
software, that is specific to your target. It's not enough to have your
49-
host's libraries installed.
47+
``compiler-rt``, ``libcxx``, ``libgcc``, ``libm``, etc), so you'll have to
48+
find and make available to the build system, every other library required
49+
to build your software, that is specific to your target. It's not enough to
50+
have your host's libraries installed.
5051

5152
Finally, not all toolchains are the same, and consequently, not every Clang
52-
option will work magically. Some options, like --sysroot (which
53+
option will work magically. Some options, like ``--sysroot`` (which
5354
effectively changes the logical root for headers and libraries), assume
5455
all your binaries and libraries are in the same directory, which may not
5556
true when your cross-compiler was installed by the distribution's package
5657
management. So, for each specific case, you may use more than one
57-
option, and in most cases, you'll end up setting include paths (-I) and
58-
library paths (-L) manually.
58+
option, and in most cases, you'll end up setting include paths (``-I``) and
59+
library paths (``-L``) manually.
5960

6061
To sum up, different toolchains can:
6162
* be host/target specific or more flexible
62-
* be in a single directory, or spread out your system
63+
* be in a single directory, or spread out across your system
6364
* have different sets of libraries and headers by default
6465
* need special options, which your build system won't be able to figure
6566
out by itself
@@ -77,11 +78,11 @@ go ahead, creating code for the host platform, which will break later
7778
on when assembling or linking.
7879

7980
The triple has the general format ``<arch><sub>-<vendor>-<sys>-<abi>``, where:
80-
* ``arch`` = x86, arm, thumb, mips, etc.
81-
* ``sub`` = for ex. on ARM: v5, v6m, v7a, v7m, etc.
82-
* ``vendor`` = pc, apple, nvidia, ibm, etc.
83-
* ``sys`` = none, linux, win32, darwin, cuda, etc.
84-
* ``abi`` = eabi, gnu, android, macho, elf, etc.
81+
* ``arch`` = ``x86``, ``arm``, ``thumb``, ``mips``, etc.
82+
* ``sub`` = for ex. on ARM: ``v5``, ``v6m``, ``v7a``, ``v7m``, etc.
83+
* ``vendor`` = ``pc``, ``apple``, ``nvidia``, ``ibm``, etc.
84+
* ``sys`` = ``none``, ``linux``, ``win32``, ``darwin``, ``cuda``, etc.
85+
* ``abi`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
8586

8687
The sub-architecture options are available for their own architectures,
8788
of course, so "x86v7a" doesn't make sense. The vendor needs to be
@@ -92,9 +93,9 @@ The system name is generally the OS (linux, darwin), but could be special
9293
like the bare-metal "none".
9394

9495
When a parameter is not important, they can be omitted, or you can
95-
choose "unknown" and the defaults will be used. If you choose a parameter
96-
that Clang doesn't know, like "blerg", it'll ignore and assume `Unknown`,
97-
which is not always desired, so be careful.
96+
choose ``unknown`` and the defaults will be used. If you choose a parameter
97+
that Clang doesn't know, like ``blerg``, it'll ignore and assume
98+
``unknown``, which is not always desired, so be careful.
9899

99100
Finally, the ABI option is something that will pick default CPU/FPU,
100101
define the specific behaviour of your code (PCS, extensions),
@@ -118,17 +119,17 @@ generate code that breaks. But that also means you won't get the best
118119
code for your specific hardware, which may mean orders of magnitude
119120
slower than you expect.
120121

121-
For example, if your target is "arm-none-eabi", the default CPU will
122-
be "arm7tdmi" using soft float, which is extremely slow on modern cores,
123-
whereas if your triple is "armv7a-none-eabi", it'll be Cortex-A8 with
122+
For example, if your target is ``arm-none-eabi``, the default CPU will
123+
be ``arm7tdmi`` using soft float, which is extremely slow on modern cores,
124+
whereas if your triple is ``armv7a-none-eabi``, it'll be Cortex-A8 with
124125
NEON, but still using soft-float, which is much better, but still not
125126
great.
126127

127128
Toolchain Options
128129
-----------------
129130

130-
There are four main options to control access to your cross-compiler:
131-
``--sysroot``, ``-I`` and ``-L``. The two last ones are well known,
131+
There are three main options to control access to your cross-compiler:
132+
``--sysroot``, ``-I``, and ``-L``. The two last ones are well known,
132133
but they're particularly important for additional libraries
133134
and headers that are specific to your target.
134135

@@ -145,7 +146,7 @@ There are two main ways to have a cross-compiler:
145146

146147
#. When you have installed via a package manager (modern Linux
147148
distributions have cross-compiler packages available), make
148-
sure the target triple you set is `also` the prefix of your
149+
sure the target triple you set is *also* the prefix of your
149150
cross-compiler toolchain.
150151

151152
In this case, Clang will find the other binaries (assembler,
@@ -163,7 +164,7 @@ Target-Specific Libraries
163164
All libraries that you compile as part of your build will be
164165
cross-compiled to your target, and your build system will probably
165166
find them in the right place. But all dependencies that are
166-
normally checked against (like libxml or libz etc) will match
167+
normally checked against (like ``libxml`` or ``libz`` etc) will match
167168
against the host platform, not the target.
168169

169170
So, if the build system is not aware that you want to cross-compile
@@ -172,7 +173,7 @@ will fail during build time, not configure time.
172173

173174
Also, finding the libraries for your target are not as easy
174175
as for your host machine. There aren't many cross-libraries available
175-
as packages to most OSs, so you'll have to either cross-compile them
176+
as packages to most OS's, so you'll have to either cross-compile them
176177
from source, or download the package for your target platform,
177178
extract the libraries and headers, put them in specific directories
178179
and add ``-I`` and ``-L`` pointing to them.
@@ -199,5 +200,5 @@ uses hard-float), Clang will pick the ``armv7l-linux-gnueabi-ld``
199200

200201
The same is true if you're compiling for different ABIs, like ``gnueabi``
201202
and ``androideabi``, and might even link and run, but produce run-time
202-
errors, which are much harder to track and fix.
203+
errors, which are much harder to track down and fix.
203204

0 commit comments

Comments
 (0)