Skip to main content
Once you have a basic Ladybird build working, there are many ways to extend and customize it for development, debugging, testing, and packaging work. This page covers Ninja build targets that ladybird.py does not expose, the full set of CMake build options, how to manipulate the CMake cache, setting up Clangd and Clang plugins, building a Flatpak, and advanced debugging techniques.
The Meta/ladybird.py script wraps a subset of available Ninja targets. Several targets must be invoked directly by changing into the build directory (Build/release by default) and running ninja <target>:
The following CMake options enable optional features intended for specific types of development work or introduce experimental functionality. Pass them using -DOPTION_NAME=ON (or OFF) on the initial cmake invocation, or use the cache manipulation methods described in the next section.

Sanitizers

Fuzzing

Debug and Development

Testing

Debug macro granularity

Many parts of the codebase have per-component debug logging controlled by <component_name>_DEBUG macros. These can be enabled individually rather than all at once. The full list is in Meta/CMake/all_the_debug_macros.cmake.Example — enable process debug logging on an existing build directory:
CMake caches variables in the binary directory. There are three ways to view and modify cache entries after the initial configuration:

Examples

Enable Address Sanitizer on a new build:
Limit parallel link jobs on a memory-constrained system:
Toggle a boolean option on an existing build directory:
For further reading, see the CMake guide for Running CMake and the documentation for set() cache entries.
The Meta/ladybird.py script and the Release preset in CMakePresets.json both default to Build/release as the build directory. For distribution purposes or when building multiple configurations simultaneously, you can specify a custom directory:
Install rules are defined in UI/cmake/InstallRules.cmake and control which binaries and libraries are installed into CMAKE_PREFIX_PATH or the path passed to cmake --install.
Resource files (icons, fonts, theming) are required at runtime. They are copied from ladybird/Base/res into the build directory by CMake rules. The resource path can be customized for packaging using CMAKE_INSTALL_DATADIR, which must be a path relative to CMAKE_INSTALL_PREFIX.
Some distributions ship outdated clang-format binaries. To get an up-to-date version:
  1. Debian/Ubuntu (preferred): Use the LLVM apt repositories to install the latest release:
  2. Compile LLVM from source: Follow the LLVM Getting Started guide to build and install the full LLVM suite, which includes clang-format.
The repository ships a .clangd configuration file in the root directory. One of its stanzas specifies the path to the compilation database (compile_commands.json).Depending on your build configuration (Release, Debug, Sanitizer, custom directory), the default path in .clangd may not point at the right build directory. Edit the .clangd file to point at your actual build directory:
This is necessary for clangd to provide accurate code navigation, diagnostics, and completion in your editor.
Clang plugins perform compile-time static analysis on the codebase. Currently they are used to detect JavaScript garbage collection mistakes — for example, failing to properly visit a garbage-collected type from a GC root.

Prerequisites

Clang’s development headers must be installed. On Ubuntu:

Enable the plugins

Configure ccache to avoid cache invalidation

By default, ccache includes plugin binaries in its file hashes. A plugin change will invalidate the entire cache. Prevent this with:
Add this to your shell profile (.bashrc, .zshrc, etc.) to make it persistent.
Ladybird ships an in-tree Flatpak manifest at Meta/CMake/flatpak/org.ladybird.Ladybird.json. The recommended tool for building it is flatpak-builder.

Prerequisites

  • Follow the Flatpak setup documentation to configure your environment for user Flatpak builds and to add the Flathub remote.
  • Install flatpak-builder (available in most distributions).

Build and install

This downloads and builds all of Ladybird’s dependencies. Expect the first build to take a significant amount of time. Build artifacts are placed in .flatpak-builder, Build/repo, and Build/flatpak.

Run the Flatpak

Debug the Flatpak

Drop into a shell inside the Flatpak sandbox:
In some situations, the debugger cannot inspect a variable because the compiler optimized it away:
The Debug build preset uses -Og by default. To fully disable all optimizations and make every symbol available, patch the build configuration to use -O0 instead:
Only apply this patch while actively debugging a specific issue. Do not leave it in place while running WPT tests or in-tree tests — it will make the build extremely slow and test results unreliable.
1

Apply the patch

2

Tell git to ignore the change

Prevent the patched build file from being accidentally committed:
3

Rebuild with the Debug preset

All frame variables that were previously optimized out are now inspectable in the debugger.
4

Revert when done

To enable Vulkan validation layers during a build, pass the VULKAN_VALIDATION_LAYERS_DEBUG option:
Then build normally. When Ladybird starts and creates a VulkanContext, you will see one of these messages:
  • Vulkan validation layers: active — layers are correctly set up.
  • Vulkan validation layers: not available — the validation layer package is missing from the system.
  • No output — the initial cmake command was not run, or the VulkanContext was not created.

Installing validation layers