Skip to content

Commit b89fef8

Browse files
[libc][docs] Update docs to reflect new headergen (#102381)
Since new headergen is now the default for building LLVM-libc, the docs need to be updated to reflect that. While I was editing those docs, I took a quick pass at updating other out-of-date pages.
1 parent c975dc1 commit b89fef8

15 files changed

+154
-242
lines changed

libc/docs/build_and_test.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ The libc can be built and tested in two different modes:
3838
3939
$> ninja libc-integration-tests
4040
41-
#. API verification test - See :ref:`api_test` for more information about
42-
the API test. It can be run by the command:
43-
44-
.. code-block:: sh
45-
46-
$> ninja libc-api-test
47-
4841
Building with VSCode
4942
====================
5043

libc/docs/contributing.rst

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Contributing to the libc Project
55
================================
66

7-
LLVM's libc is being developed as part of the LLVM project so contributions
7+
LLVM-libc is being developed as part of the LLVM project so contributions
88
to the libc project should also follow the general LLVM
99
`contribution guidelines <https://llvm.org/docs/Contributing.html>`_. Below is
1010
a list of open projects that one can start with:
@@ -31,24 +31,12 @@ a list of open projects that one can start with:
3131
directory. So, a simple but mechanical project would be to move the parts
3232
following the old styles to the new style.
3333

34-
#. **Integrating with the rest of the LLVM project** - There are two parts to
35-
this project:
36-
37-
#. One is about adding CMake facilities to optionally link the libc's overlay
38-
static archive (see :ref:`overlay_mode`) with other LLVM tools/executables.
39-
#. The other is about putting plumbing in place to release the overlay static
40-
archive (see :ref:`overlay_mode`) as part of the LLVM binary releases.
41-
4234
#. **Implement Linux syscall wrappers** - A large portion of the POSIX API can
4335
be implemented as syscall wrappers on Linux. A good number have already been
4436
implemented but many more are yet to be implemented. So, a project of medium
4537
complexity would be to implement syscall wrappers which have not yet been
4638
implemented.
4739

48-
#. **Add a better random number generator** - The current random number
49-
generator has a very small range. This has to be improved or switched over
50-
to a fast random number generator with a large range.
51-
5240
#. **Update the clang-tidy lint rules and use them in the build and/or CI** -
5341
Currently, the :ref:`clang_tidy_checks` have gone stale and are mostly unused
5442
by the developers and on the CI builders. This project is about updating

libc/docs/dev/api_test.rst

Lines changed: 0 additions & 25 deletions
This file was deleted.

libc/docs/dev/ground_truth_specification.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

libc/docs/dev/header_generation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _header_generation:
2+
13
Generating Public and Internal headers
24
======================================
35

libc/docs/dev/index.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ Navigate to the links below for information on the respective topics:
1515
config_options
1616
clang_tidy_checks
1717
fuzzing
18-
ground_truth_specification
1918
header_generation
2019
implementation_standard
2120
undefined_behavior
2221
printf_behavior
23-
api_test
24-
mechanics_of_public_api

libc/docs/dev/mechanics_of_public_api.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

libc/docs/dev/source_tree_layout.rst

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ directories::
1414
- docs
1515
- examples
1616
- fuzzing
17+
- hdr
1718
- include
1819
- lib
19-
- spec
20+
- newhdrgen
2021
- src
2122
- startup
2223
- test
@@ -62,6 +63,14 @@ The directory structure within this directory mirrors the directory structure
6263
of the top-level ``libc`` directory itself. For more details, see
6364
:doc:`fuzzing`.
6465

66+
The ``hdr`` directory
67+
---------------------
68+
69+
This directory contains proxy headers which are included from the files in the
70+
src directory. These proxy headers either include our internal type or macro
71+
definitions, or the system's type or macro definitions, depending on if we are
72+
in fullbuild or overlay mode.
73+
6574
The ``include`` directory
6675
-------------------------
6776

@@ -80,13 +89,14 @@ The ``lib`` directory
8089
This directory contains a ``CMakeLists.txt`` file listing the targets for the
8190
public libraries ``libc.a``, ``libm.a`` etc.
8291

83-
The ``spec`` directory
84-
----------------------
92+
The ``newhdrgen`` directory
93+
---------------------------
8594

86-
This directory contains the specifications for the types, macros, and entrypoint
87-
functions. These definitions come from the various standards and extensions
88-
LLVM-libc supports, and they are used along with the ``*.h.def`` files and the
89-
config files to generate the headers for fullbuild mode.
95+
This directory contains the sources and specifications for the types, macros
96+
and entrypoint functions. These definitions are organized in the ``yaml``
97+
subdirectory and match the organization of the ``*.h.def`` files. This folder
98+
also contains the python sources for new headergen, which is what generates the
99+
headers.
90100

91101
The ``src`` directory
92102
---------------------

libc/docs/full_cross_build.rst

Lines changed: 15 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,33 @@ Full Cross Build
88
:depth: 1
99
:local:
1010

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+
1116
In this document, we will present recipes to cross build the full libc. When we
1217
say *cross build* a full libc, we mean that we will build the full libc for a
1318
target system which is not the same as the system on which the libc is being
1419
built. For example, you could be building for a bare metal aarch64 *target* on a
1520
Linux x86_64 *host*.
1621

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
1823
different use case. Below is a short description of these recipes to help users
1924
pick the recipe that best suites their needs and contexts.
2025

2126
* **Standalone cross build** - Using this recipe one can build the libc using a
2227
compiler of their choice. One should use this recipe if their compiler can
2328
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.
3129
* **Bootstrap cross build** - In this recipe, one will build the ``clang``
3230
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.
3533
They get built automatically before building the libc. One should use this
3634
recipe if they intend use the built ``clang`` and the libc as part of their
3735
toolchain for the target.
3836

39-
The following sections present the three recipes in detail.
37+
The following sections present the two recipes in detail.
4038

4139
Standalone cross build
4240
======================
@@ -61,9 +59,9 @@ Below is the CMake command to configure the standalone crossbuild of the libc.
6159
$> cd build
6260
$> C_COMPILER=<C compiler> # For example "clang"
6361
$> CXX_COMPILER=<C++ compiler> # For example "clang++"
64-
$> cmake ../llvm \
62+
$> cmake ../runtimes \
6563
-G Ninja \
66-
-DLLVM_ENABLE_PROJECTS=libc \
64+
-DLLVM_ENABLE_RUNTIMES=libc \
6765
-DCMAKE_C_COMPILER=$C_COMPILER \
6866
-DCMAKE_CXX_COMPILER=$CXX_COMPILER \
6967
-DLLVM_LIBC_FULL_BUILD=ON \
@@ -72,8 +70,8 @@ Below is the CMake command to configure the standalone crossbuild of the libc.
7270
7371
We will go over the special options passed to the ``cmake`` command above.
7472

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.
7775
* **The full build option** - Since we want to build the full libc, we pass
7876
``-DLLVM_LIBC_FULL_BUILD=ON``.
7977
* **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
9492
``libm.a`` for the target specified with ``-DLIBC_TARGET_TRIPLE`` in the CMake
9593
configure step.
9694

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-
17995
Bootstrap cross build
18096
=====================
18197

@@ -203,8 +119,7 @@ CMake configure step
203119
-DLLVM_RUNTIME_TARGETS=$TARGET_TRIPLE \
204120
-DCMAKE_BUILD_TYPE=Debug
205121
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:
208123

209124
* ``clang`` is listed in ``-DLLVM_ENABLE_PROJECTS`` and ``libc`` is
210125
listed in ``-DLLVM_ENABLE_RUNTIMES``.
@@ -214,7 +129,7 @@ recipes:
214129
Build step
215130
----------
216131

217-
The build step is similar to the other two recipes:
132+
The build step is similar to the other recipe:
218133

219134
.. code-block:: sh
220135

0 commit comments

Comments
 (0)