Files
RedBear-OS/local/recipes/dev/libclc/source/libc/examples/README.md
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

3.1 KiB

Examples

This directory contains a few example programs which illustrate how one can set up their own projects to use LLVM's libc, either as an overlay or as the only libc in their projects. See the the usage mode document for more information about the different modes in which one can build and use the libc.

Building the Examples

Each example has its own directory which contain the source code and the CMake build set up. To build an example, create a directory named build in the example's directory:

cd <example directory>
mkdir build
cd build

Each example can be built to use the libc in either the overlay mode, the full host build mode or the full cross build mode. The CMake configure step differs slightly depending on the mode you want to use the libc in.

Building against an overlay libc

Before you can link an example against the overlay libc, you will have to install it. See the documentation of the overlay mode to learn how to install the libc's overlay static archive named libllvmlibc.a. Once installed, to build an example against it, you have specify the directory in which the static archive is installed with the option LIBC_OVERLAY_ARCHIVE_DIR:

cmake ../ -G <GEN>  \
  -DLIBC_OVERLAY_ARCHIVE_DIR=<dir in which libc is installed>

Next, if Ninja is used for <GEN>, you can build the example as follows:

ninja <example name>

Building against a full libc

Before you can link an example against the full libc, you will have to first install it. See documentation for full host build mode or documentation for full cross build mode to learn how to install a full libc along with the other LLVM toolchain pieces like clang, lld and compiler-rt. The CMake build for the examples will assume that you have all of these components installed in a special sysroot (see decription of the --sysroot option here.) Once you have installed them, you have to inform CMake that we are linking against the full libc as follows:

cmake ../ -G <GEN> -DLLVM_LIBC_FULL_BUILD=ON    \
  -DCMAKE_SYSROOT=<SYSROOT>               \
  -DCMAKE_C_COMPILER=<SYSROOT>/bin/clang  \
  -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY

<SYSROOT> is the path to the sysroot directory you have set up while installing the full libc. The option -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY tells CMake to not attempt linking full executables against shared libraries. We have to use this as LLVM's libc does not yet have support for shared libraries and dynamic linking. After the above cmake command, assuming Ninja was used for <GEN>, you can build the example as follows:

ninja <example name>