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.
Ninja Build Targets
Ninja Build Targets
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>:CMake Build Options
CMake Build Options
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 Cache Manipulation
CMake Cache Manipulation
CMake caches variables in the binary directory. There are three ways to view and modify cache entries after the initial configuration: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.
Examples
Enable Address Sanitizer on a new build:Custom CMake Build Directory
Custom CMake Build Directory
The Install rules are defined in
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: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.Clang-Format Updates
Clang-Format Updates
Some distributions ship outdated
clang-format binaries. To get an up-to-date version:-
Debian/Ubuntu (preferred): Use the LLVM apt repositories to install the latest release:
-
Compile LLVM from source: Follow the LLVM Getting Started guide to build and install the full LLVM suite, which includes
clang-format.
Clangd Configuration
Clangd Configuration
The repository ships a This is necessary for clangd to provide accurate code navigation, diagnostics, and completion in your editor.
.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:Clang Plugins for GC Validation
Clang Plugins for GC Validation
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.Add this to your shell profile (
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:.bashrc, .zshrc, etc.) to make it persistent.Building the Flatpak
Building the Flatpak
Ladybird ships an in-tree Flatpak manifest at 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
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
.flatpak-builder, Build/repo, and Build/flatpak.Run the Flatpak
Debug the Flatpak
Drop into a shell inside the Flatpak sandbox:Debugging Without Optimizations (-O0)
Debugging Without Optimizations (-O0)
In some situations, the debugger cannot inspect a variable because the compiler optimized it away:The Debug build preset uses All frame variables that were previously optimized out are now inspectable in the debugger.
-Og by default. To fully disable all optimizations and make every symbol available, patch the build configuration to use -O0 instead: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
4
Revert when done
Vulkan Validation Layers
Vulkan Validation Layers
To enable Vulkan validation layers during a build, pass the Then build normally. When Ladybird starts and creates a VulkanContext, you will see one of these messages:
VULKAN_VALIDATION_LAYERS_DEBUG option: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
cmakecommand was not run, or the VulkanContext was not created.
