@@ -8,35 +8,33 @@ Full Cross Build
8
8
:depth: 1
9
9
:local:
10
10
11
+ .. note ::
12
+ Fullbuild requires running headergen, which is a python program that depends on
13
+ pyyaml. The minimum versions are listed on the :ref: `header_generation `
14
+ page, as well as additional information.
15
+
11
16
In this document, we will present recipes to cross build the full libc. When we
12
17
say *cross build * a full libc, we mean that we will build the full libc for a
13
18
target system which is not the same as the system on which the libc is being
14
19
built. For example, you could be building for a bare metal aarch64 *target * on a
15
20
Linux x86_64 *host *.
16
21
17
- There are three main recipes to cross build the full libc. Each one serves a
22
+ There are two main recipes to cross build the full libc. Each one serves a
18
23
different use case. Below is a short description of these recipes to help users
19
24
pick the recipe that best suites their needs and contexts.
20
25
21
26
* **Standalone cross build ** - Using this recipe one can build the libc using a
22
27
compiler of their choice. One should use this recipe if their compiler can
23
28
build for the host as well as the target.
24
- * **Runtimes cross build ** - In this recipe, one will have to first build the
25
- libc build tools for the host separately and then use those build tools to
26
- build the libc. Users can use the compiler of their choice to build the
27
- libc build tools as well as the libc. One should use this recipe if they
28
- have to use a host compiler to build the build tools for the host and then
29
- use a target compiler (which is different from the host compiler) to build
30
- the libc.
31
29
* **Bootstrap cross build ** - In this recipe, one will build the ``clang ``
32
30
compiler and the libc build tools for the host first, and then use them to
33
- build the libc for the target. Unlike with the runtimes build recipe, the
34
- user does not have explicitly build ``clang `` and other libc build tools.
31
+ build the libc for the target. Unlike with the standalone build recipe, the
32
+ user does not have explicitly build ``clang `` and other build tools.
35
33
They get built automatically before building the libc. One should use this
36
34
recipe if they intend use the built ``clang `` and the libc as part of their
37
35
toolchain for the target.
38
36
39
- The following sections present the three recipes in detail.
37
+ The following sections present the two recipes in detail.
40
38
41
39
Standalone cross build
42
40
======================
@@ -61,9 +59,9 @@ Below is the CMake command to configure the standalone crossbuild of the libc.
61
59
$> cd build
62
60
$> C_COMPILER=< C compiler> # For example "clang"
63
61
$> CXX_COMPILER=< C++ compiler> # For example "clang++"
64
- $> cmake ../llvm \
62
+ $> cmake ../runtimes \
65
63
-G Ninja \
66
- -DLLVM_ENABLE_PROJECTS =libc \
64
+ -DLLVM_ENABLE_RUNTIMES =libc \
67
65
-DCMAKE_C_COMPILER=$C_COMPILER \
68
66
-DCMAKE_CXX_COMPILER=$CXX_COMPILER \
69
67
-DLLVM_LIBC_FULL_BUILD=ON \
@@ -72,8 +70,8 @@ Below is the CMake command to configure the standalone crossbuild of the libc.
72
70
73
71
We will go over the special options passed to the ``cmake `` command above.
74
72
75
- * **Enabled Projects ** - Since we want to build the libc project , we list
76
- ``libc `` as the enabled project .
73
+ * **Enabled Runtimes ** - Since we want to build LLVM- libc, we list
74
+ ``libc `` as the enabled runtime .
77
75
* **The full build option ** - Since we want to build the full libc, we pass
78
76
``-DLLVM_LIBC_FULL_BUILD=ON ``.
79
77
* **The target triple ** - This is the target triple of the target for which
@@ -94,88 +92,6 @@ The above ``ninja`` command will build the libc static archives ``libc.a`` and
94
92
``libm.a `` for the target specified with ``-DLIBC_TARGET_TRIPLE `` in the CMake
95
93
configure step.
96
94
97
- .. _runtimes_cross_build :
98
-
99
- Runtimes cross build
100
- ====================
101
-
102
- The *runtimes cross build * is very similar to the standalone crossbuild but the
103
- user will have to first build the libc build tools for the host separately. One
104
- should use this recipe if they want to use a different host and target compiler.
105
- Note that the libc build tools MUST be in sync with the libc. That is, the
106
- libc build tools and the libc, both should be built from the same source
107
- revision. At the time of this writing, there is only one libc build tool that
108
- has to be built separately. It is done as follows:
109
-
110
- .. code-block :: sh
111
-
112
- $> cd llvm-project # The llvm-project checkout
113
- $> mkdir build-libc-tools # A different build directory for the build tools
114
- $> cd build-libc-tools
115
- $> HOST_C_COMPILER=< C compiler for the host> # For example "clang"
116
- $> HOST_CXX_COMPILER=< C++ compiler for the host> # For example "clang++"
117
- $> cmake ../llvm \
118
- -G Ninja \
119
- -DLLVM_ENABLE_PROJECTS=libc \
120
- -DCMAKE_C_COMPILER=$HOST_C_COMPILER \
121
- -DCMAKE_CXX_COMPILER=$HOST_CXX_COMPILER \
122
- -DLLVM_LIBC_FULL_BUILD=ON \
123
- -DCMAKE_BUILD_TYPE=Debug # User can choose to use "Release" build type
124
- $> ninja libc-hdrgen
125
-
126
- The above commands should build a binary named ``libc-hdrgen ``. Copy this binary
127
- to a directory of your choice.
128
-
129
- CMake configure step
130
- --------------------
131
-
132
- After copying the ``libc-hdrgen `` binary to say ``/path/to/libc-hdrgen ``,
133
- configure the libc build using the following command:
134
-
135
- .. code-block :: sh
136
-
137
- $> cd llvm-project # The llvm-project checkout
138
- $> mkdir build
139
- $> cd build
140
- $> TARGET_C_COMPILER=< C compiler for the target>
141
- $> TARGET_CXX_COMPILER=< C++ compiler for the target>
142
- $> HDRGEN=< /path/to/libc-hdrgen>
143
- $> TARGET_TRIPLE=< Your target triple>
144
- $> cmake ../runtimes \
145
- -G Ninja \
146
- -DLLVM_ENABLE_RUNTIMES=libc \
147
- -DCMAKE_C_COMPILER=$TARGET_C_COMPILER \
148
- -DCMAKE_CXX_COMPILER=$TARGET_CXX_COMPILER \
149
- -DLLVM_LIBC_FULL_BUILD=ON \
150
- -DLIBC_HDRGEN_EXE=$HDRGEN \
151
- -DLIBC_TARGET_TRIPLE=$TARGET_TRIPLE \
152
- -DCMAKE_BUILD_TYPE=Debug # User can choose to use "Release" build type
153
-
154
- Note the differences in the above cmake command versus the one used in the
155
- CMake configure step of the standalone build recipe:
156
-
157
- * Instead of listing ``libc `` in ``LLVM_ENABLED_PROJECTS ``, we list it in
158
- ``LLVM_ENABLED_RUNTIMES ``.
159
- * Instead of using ``llvm-project/llvm `` as the root CMake source directory,
160
- we use ``llvm-project/runtimes `` as the root CMake source directory.
161
- * The path to the ``libc-hdrgen `` binary built earlier is specified with
162
- ``-DLIBC_HDRGEN_EXE=/path/to/libc-hdrgen ``.
163
-
164
- Build step
165
- ----------
166
-
167
- The build step in the runtimes build recipe is exactly the same as that of
168
- the standalone build recipe:
169
-
170
- .. code-block :: sh
171
-
172
- $> ninja libc libm
173
-
174
- As with the standalone build recipe, the above ninja command will build the
175
- libc static archives for the target specified with ``-DLIBC_TARGET_TRIPLE `` in
176
- the CMake configure step.
177
-
178
-
179
95
Bootstrap cross build
180
96
=====================
181
97
@@ -203,8 +119,7 @@ CMake configure step
203
119
-DLLVM_RUNTIME_TARGETS=$TARGET_TRIPLE \
204
120
-DCMAKE_BUILD_TYPE=Debug
205
121
206
- Note how the above cmake command differs from the one used in the other two
207
- recipes:
122
+ Note how the above cmake command differs from the one used in the other recipe:
208
123
209
124
* ``clang `` is listed in ``-DLLVM_ENABLE_PROJECTS `` and ``libc `` is
210
125
listed in ``-DLLVM_ENABLE_RUNTIMES ``.
@@ -214,7 +129,7 @@ recipes:
214
129
Build step
215
130
----------
216
131
217
- The build step is similar to the other two recipes :
132
+ The build step is similar to the other recipe :
218
133
219
134
.. code-block :: sh
220
135
0 commit comments