3 =============================
4 Building and Testing the libc
5 =============================
10 The libc can be built and tested in two different modes:
12 #. **The overlay mode** - In this mode, one uses the static archive from LLVM's
13 libc along with the system libc. See :ref:`overlay_mode` for more details
14 on building and using the libc in this mode. You can only run the libc
15 unittests in this mode. To run them, one simply does:
21 Note that, unittests for only those functions which are part of the overlay
22 static archive will be run with the above command.
24 #. **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
26 building and using the libc in this mode. Once configured for a full libc
27 build, you can run three kinds of tests:
29 #. Unit tests - You can run unittests by the command:
35 #. Integration tests - You can run integration tests by the command:
39 $> ninja libc-integration-tests
44 As a quickstart to using VSCode for development, install the cmake extension
45 and put the following in your settings.json file:
47 .. code-block:: javascript
50 "cmake.sourceDirectory": "${workspaceFolder}/llvm",
51 "cmake.configureSettings": {
52 "LLVM_ENABLE_PROJECTS" : "libc",
53 "LLVM_LIBC_FULL_BUILD" : true,
54 "LLVM_ENABLE_SPHINX" : true,
55 "LIBC_INCLUDE_DOCS" : true
62 #. To build with Bazel, use the following command:
66 $> bazel build --config=generic_clang @llvm-project//libc/...
68 #. To run the unit tests with bazel, use the following command:
72 $> bazel test --config=generic_clang @llvm-project//libc/...
74 #. The bazel target layout of `libc` is located at: `utils/bazel/llvm-project-overlay/libc/BUILD.bazel <https://github.com/llvm/llvm-project/tree/main/utils/bazel/llvm-project-overlay/libc/BUILD.bazel>`_.
76 Building in a container for a different architecture
77 ====================================================
79 `Podman <https://podman.io/>`_ can be used together with
80 `QEMU <https://www.qemu.org/>`_ to run container images built for architectures
81 other than the host's. This can be used to build and test the libc on other
82 supported architectures for which you do not have access to hardware. It can
83 also be used if the hardware is slower than emulation of its architecture on a
84 more powerful machine under a different architecture.
86 As an example, to build and test in a container for 32-bit Arm:
88 #. To install the necessary packages on Arch Linux:
92 $> pacman -S podman qemu-user-static qemu-user-static-binfmt \
95 #. To run Bash interactively in an Ubuntu 22.04 container for 32-bit Arm and
96 bind-mount an existing checkout of llvm-project on the host:
101 -v </host/path/to/llvm-project>:</container/path/to/llvm-project> \
102 --arch arm docker.io/ubuntu:jammy bash
104 #. Install necessary packages, invoke CMake, build, and run tests.