Skip to content

Commit 692c77f

Browse files
[libc][docs] reorder docs to be more beginner friendly (#122376)
This commit does a few things, with the intent to make it more straightforward to potential future users how to get started with llvm-libc. Answers to "What's the status and how do I use it?" are front and center, "above the fold." This commit does a few things: * reorganize the landing page's toctree: start with implementation status, arch * support, platform support, and compiler support. * Then a (new) simple getting started page using full host builds. Then more * Advanced topics such as host vs cross builds, overlay mode, gpu builds and additional configuration options. * Remove c23 status, the old fullbuild_mode landing page, and usage_modes landing pages. c23 status isn't as interesting as I originally thought it might. We should point people at full host builds to start, then link to more info on cross compilation, or overlay mode as more advanced topics. I assert most users starting out won't care about those.
1 parent a0bd40e commit 692c77f

File tree

7 files changed

+77
-223
lines changed

7 files changed

+77
-223
lines changed

libc/docs/build_and_test.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The libc can be built and tested in two different modes:
2222
static archive will be run with the above command.
2323

2424
#. **The full build mode** - In this mode, the libc is used as the only libc
25-
for the user's application. See :ref:`fullbuild_mode` for more details on
25+
for the user's application. See :ref:`full_host_build` for more details on
2626
building and using the libc in this mode. Once configured for a full libc
2727
build, you can run three kinds of tests:
2828

libc/docs/c23.rst

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

libc/docs/fullbuild_mode.rst

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

libc/docs/getting_started.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Getting Started
2+
===============
3+
4+
Let's fetch the llvm-libc sources and build them.
5+
6+
Install dependencies first:
7+
8+
.. code-block:: sh
9+
10+
$ sudo apt update
11+
$ sudo apt install git cmake ninja-build clang gcc-multilib
12+
13+
.. code-block:: sh
14+
15+
$ git clone --depth=1 [email protected]:llvm/llvm-project.git /tmp/llvm-project
16+
$ mkdir /tmp/llvm-project/build
17+
$ cd /tmp/llvm-project/build
18+
$ cmake ../runtimes -GNinja \
19+
-DLLVM_ENABLE_RUNTIMES="libc;compiler-rt" \
20+
-DCMAKE_BUILD_TYPE=Debug \
21+
-DCMAKE_CXX_COMPILER=clang++ \
22+
-DCMAKE_C_COMPILER=clang \
23+
-DLLVM_LIBC_FULL_BUILD=ON \
24+
-DLLVM_LIBC_INCLUDE_SCUDO=ON \
25+
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
26+
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
27+
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF
28+
$ ninja libc libm
29+
30+
This will produce the following artifacts:
31+
32+
.. code-block::
33+
34+
llvm-project/build/libc/lib/libc.a
35+
llvm-project/build/libc/lib/libm.a
36+
llvm-project/build/libc/startup/linux/crt1.o
37+
llvm-project/build/libc/include/**.h
38+
39+
We can then compile and run hello world via:
40+
41+
.. code-block:: c++
42+
43+
// hello.c
44+
#include <stdio.h>
45+
int main () { puts("hello world"); }
46+
47+
.. code-block:: sh
48+
49+
$ clang -nostdinc -nostdlib hello.c -I libc/include \
50+
-I $(clang -print-resource-dir)/include libc/startup/linux/crt1.o \
51+
libc/lib/libc.a
52+
$ ./a.out
53+
hello world
54+
55+
This was what we call a "full build" of llvm-libc. From here, you can visit
56+
:ref:`full_host_build` for more info, :ref:`full_cross_build` for cross
57+
compiling, :ref:`overlay_mode` for mixing llvm-libc with another libc, or
58+
:ref:`libc_gpu` for targeting GPUs.

libc/docs/index.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,31 @@ LLVM-libc aspires to a unique place in the software ecosystem. The goals are:
3838

3939
.. toctree::
4040
:hidden:
41-
:maxdepth: 2
42-
:caption: Using
41+
:maxdepth: 1
42+
:caption: Status & Support
4343

44-
usage_modes
45-
overlay_mode
46-
fullbuild_mode
47-
configure
48-
gpu/index.rst
44+
headers/index.rst
45+
arch_support
46+
platform_support
47+
compiler_support
4948

5049
.. toctree::
5150
:hidden:
5251
:maxdepth: 1
53-
:caption: Status
52+
:caption: Simple Usage
5453

55-
headers/index.rst
56-
c23
54+
getting_started
5755

5856
.. toctree::
5957
:hidden:
6058
:maxdepth: 1
61-
:caption: Support
59+
:caption: Advanced Usage
6260

63-
arch_support
64-
platform_support
65-
compiler_support
61+
full_host_build
62+
full_cross_build
63+
overlay_mode
64+
gpu/index.rst
65+
configure
6666

6767
.. toctree::
6868
:hidden:
@@ -73,13 +73,13 @@ LLVM-libc aspires to a unique place in the software ecosystem. The goals are:
7373
dev/index.rst
7474
porting
7575
contributing
76-
talks
7776

7877
.. toctree::
7978
:hidden:
8079
:maxdepth: 1
81-
:caption: External Links
80+
:caption: Useful Links
8281

82+
talks
8383
Source Code <https://github.com/llvm/llvm-project/tree/main/libc>
8484
Bug Reports <https://github.com/llvm/llvm-project/labels/libc>
8585
Discourse <https://discourse.llvm.org/c/runtimes/libc>

libc/docs/porting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The entrypoints.txt file
6868
One of the important pieces of config information is listed in a file named
6969
``entrypoints.txt``. This file lists the targets for the entrypoints (see
7070
:ref:`entrypoints`) you want to include in the static archive of the libc (for
71-
the :ref:`overlay_mode` and/or the :ref:`fullbuild_mode`.) If you are doing an
71+
the :ref:`overlay_mode` and/or the :ref:`full_host_build`.) If you are doing an
7272
architecture specific bring up, then an ``entrypoints.txt`` file should be
7373
created in the architecture subdirectory for each architecture. Else, having a
7474
single ``entrypoints.txt`` in the operating system directory is sufficient.
@@ -95,7 +95,7 @@ The headers.txt file
9595
Another important piece of config information is listed in a file named
9696
``headers.txt``. It lists the targets for the set of public headers that are
9797
provided by the libc. This is relevant only if the libc is to be used in the
98-
:ref:`fullbuild_mode` on the target operating system and architecture. As with
98+
:ref:`full_host_build` on the target operating system and architecture. As with
9999
the ``entrypoints.txt`` file, one ``headers.txt`` file should be listed for
100100
each individual target architecture if you are doing an architecture specific
101101
bring up. The Linux config has ``headers.txt`` file listed separately for the

libc/docs/usage_modes.rst

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

0 commit comments

Comments
 (0)