Skip to content

Commit d4c49a6

Browse files
moar docs
1 parent 76e422c commit d4c49a6

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

libc/docs/full_cross_build.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ Below is the CMake command to configure the standalone crossbuild of the libc.
5959
$> cd build
6060
$> C_COMPILER=<C compiler> # For example "clang"
6161
$> CXX_COMPILER=<C++ compiler> # For example "clang++"
62+
$> KERNEL_HEADERS=<path/to/built/linux/kernel/headers>
6263
$> cmake ../runtimes \
6364
-G Ninja \
6465
-DLLVM_ENABLE_RUNTIMES=libc \
6566
-DCMAKE_C_COMPILER=$C_COMPILER \
6667
-DCMAKE_CXX_COMPILER=$CXX_COMPILER \
6768
-DLLVM_LIBC_FULL_BUILD=ON \
6869
-DLIBC_TARGET_TRIPLE=<Your target triple> \
70+
-DLIBC_KERNEL_HEADERS=$KERNEL_HEADERS \
6971
-DCMAKE_BUILD_TYPE=<Release|Debug>
7072
7173
We will go over the special options passed to the ``cmake`` command above.
@@ -77,6 +79,10 @@ We will go over the special options passed to the ``cmake`` command above.
7779
* **The target triple** - This is the target triple of the target for which
7880
we are building the libc. For example, for a Linux 32-bit Arm target,
7981
one can specify it as ``arm-linux-eabi``.
82+
* **The path to the kernel headers** - (Optional) Necessary when targeting
83+
Linux. The Linux kernel headers are architecture specific and should be built
84+
from source. See :ref:`linux_headers` section for how to build the Linux
85+
kernel headers from source.
8086

8187
Build step
8288
----------
@@ -116,6 +122,7 @@ CMake configure step
116122
-DLLVM_ENABLE_PROJECTS=clang \
117123
-DLLVM_ENABLE_RUNTIMES=libc \
118124
-DLLVM_LIBC_FULL_BUILD=ON \
125+
-DLIBC_KERNEL_HEADERS=$KERNEL_HEADERS \
119126
-DLLVM_RUNTIME_TARGETS=$TARGET_TRIPLE \
120127
-DCMAKE_BUILD_TYPE=Debug
121128

libc/docs/full_host_build.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ development. In this we've set the Ninja generator, set the build type to
2828
"Debug", and enabled the Scudo allocator. This build also enables generating the
2929
documentation and verbose cmake logging, which are useful development features.
3030

31+
If targeting Linux, see :ref:`linux_headers` for how to build the Linux kernel
32+
headers from source, which llvm-libc will depend on. If not targeting Linux,
33+
the below cmake variable ``LIBC_KERNEL_HEADERS`` should be omitted.
34+
3135
.. note::
3236
if your build fails with an error saying the compiler can't find
3337
``<asm/unistd.h>`` or similar then you're probably missing the symlink from
@@ -50,6 +54,7 @@ documentation and verbose cmake logging, which are useful development features.
5054
-DLLVM_LIBC_FULL_BUILD=ON \
5155
-DCMAKE_BUILD_TYPE=Debug \
5256
-DLLVM_LIBC_INCLUDE_SCUDO=ON \
57+
-DLLVM_LIBC_KERNEL_HEADERS=/path/to/kernel/headers/ \
5358
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
5459
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
5560
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF \
@@ -133,6 +138,7 @@ allocator for LLVM-libc.
133138
-DCMAKE_CXX_COMPILER=clang++ \
134139
-DLLVM_LIBC_FULL_BUILD=ON \
135140
-DLLVM_LIBC_INCLUDE_SCUDO=ON \
141+
-DLLVM_LIBC_KERNEL_HEADERS=/path/to/kernel/headers/ \
136142
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
137143
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
138144
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF \
@@ -171,6 +177,8 @@ toolchain with which you can build practical/real-world C applications. See
171177
`<https://github.com/llvm/llvm-project/tree/main/libc/examples>`_ for examples
172178
of how to start using this new toolchain.
173179

180+
.. _linux_headers:
181+
174182
Linux Headers
175183
=============
176184

@@ -183,7 +191,9 @@ Linux headers in your sysroot. Let's build them from source.
183191
$> make LLVM=1 INSTALL_HDR_PATH=/path/to/sysroot -C /tmp/linux headers_install
184192
185193
The headers can be built to target non-host architectures by adding the
186-
``ARCH={arm|arm64|i386}`` to the above invocation of ``make``.
194+
``ARCH={arm|arm64|i386}`` to the above invocation of ``make``. Then you should
195+
set the cmake variable `-DLIBC_KERNEL_HEADERS=/path/to/sysroot` when
196+
configuring llvm-libc.
187197

188198
Using your newly built libc
189199
===========================

libc/docs/overlay_mode.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ building it with the following cmake command:
4040
$> mkdir build
4141
$> cd build
4242
$> cmake ../runtimes -G Ninja -DLLVM_ENABLE_RUNTIMES="libc" \
43+
-LIBC_USE_HOST_KERNEL_HEADERS=ON \
4344
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
4445
-DCMAKE_BUILD_TYPE=<Debug|Release> \ # Select build type
4546
-DCMAKE_INSTALL_PREFIX=<Your prefix of choice> # Optional
@@ -78,6 +79,7 @@ performance possible.
7879
7980
$> cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="clang" \
8081
-DLLVM_ENABLE_RUNTIMES="libc" \ # libc is listed as runtime and not as a project
82+
-DLIBC_USE_HOST_KERNEL_HEADERS=ON \
8183
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
8284
-DCMAKE_BUILD_TYPE=<Debug|Release> \ # Select build type
8385
-DCMAKE_INSTALL_PREFIX=<Your prefix of choice> # Optional

0 commit comments

Comments
 (0)