This was made as an attempt to write down as much of what I know about LLVM-libc as possible. The process involved using an LLM agent to interview me about what wasn't clear from the codebase and then write docs based on my answers. After that were several rounds of revisions where I tweaked phrasing and corrected more issues. The final documents are an accurate reflection of my understanding of the state of LLVM-libc. Assisted-by: Automated tooling, human reviewed.
2.7 KiB
(building_docs)=
Building the Documentation
This page explains how to build the LLVM-libc HTML documentation locally so you can preview changes before submitting a patch.
Prerequisites
The LLVM documentation build uses Sphinx. The key packages required are:
sphinx— the documentation generatorfuro— the theme used by LLVM-libcmyst-parser— Markdown support alongside RSTsphinx-reredirects— handles page redirect entries inconf.py
On Debian/Ubuntu, all required packages are available via apt:
sudo apt-get install python3-sphinx python3-myst-parser \
python3-sphinx-reredirects furo
On other systems, install everything from the shared requirements file:
pip install -r llvm/docs/requirements.txt
CMake Configuration
Enable the Sphinx documentation build by adding these flags to your CMake invocation:
cmake ../runtimes \
-DLLVM_ENABLE_RUNTIMES="libc" \
-DLLVM_ENABLE_SPHINX=ON \
-DLIBC_INCLUDE_DOCS=ON \
...
The LLVM_ENABLE_SPHINX=ON flag enables Sphinx globally for all LLVM
subprojects. LIBC_INCLUDE_DOCS=ON is specific to libc and tells CMake to
register the libc doc targets.
Building
Once configured, build the HTML docs with:
ninja docs-libc-html
The output is written to <build-dir>/tools/libc/docs/html/. Open
index.html in a browser to view the site.
Header Status Pages (Auto-generated)
The per-header implementation status pages under docs/headers/ are
not hand-written Markdown. They are generated at build time by
libc/utils/docgen/docgen.py, which:
- Reads YAML function and macro definitions from
libc/utils/docgen/<header>.yaml. - Checks implementation status against platform
entrypoints.txtfiles (excludingTODOstubs). - Checks
libc/include/llvm-libc-macros/andlibc/include/<header>.yamlfor macro definitions. - Emits a MyST Markdown page with styled HTML tables showing each symbol's implementation status, C standard section, and POSIX link.
If you add a new function and regenerate, these pages update automatically.
Do not hand-edit the generated .md files in docs/headers/ — your
changes will be overwritten the next time the docs are built.
Troubleshooting
Extension error: Could not import extension myst_parser- On Debian/Ubuntu:
sudo apt-get install python3-myst-parser. Otherwise:pip install -r llvm/docs/requirements.txt. WARNING: document isn't included in any toctree- A new Markdown file needs a
toctreeentry. Add it to the appropriateindex.mdor its parent toctree. Extension error: No module named 'sphinx_reredirects'- Same fix:
pip install -r llvm/docs/requirements.txt.