#1436 closed todo (done)

Clangd setup and integration

Reported by: Ichthyostega Owned by:
Priority: grave Milestone:
Component: infrastructure Keywords: tooling platform scons
Sub Tickets: #1438 Parent Tickets: #525, #1356, #1432

Description

As Lumiera developer,
I want a properly integrated clangd,
so that I can use external tools that rely on a Language-server for code-intelligence.

requirements

The Language-server clangd is based on the Clang compiler framework and the LLVM project. It requires a reliable record of all actual compiler invocations with full options, so that code diagnostics and navigation features see the code base in the same way as defined by our Build System.

The established solution is to generate a compile_commands.json as part of the build process. The format is specified by LLVM as the ​JSON Compilation Database; the related ​clangd documentation (notes on compile commands) explains how a language server consumes it.

Change history (2)

comment:1 by Ichthyostega, at 2026-10-01T18:35:20Z

Sub Tickets: → 1438

Add subticket #1438 (DistCC and CCache support retired).

comment:2 by Ichthyostega, at 2026-10-01T21:22:36Z

Resolution: → done
Status: new → closed

In 109d682/Lumiera:

Buildsystem: generate a compilation database for clangd (closes: #1436)

Knowledge-Technology(Claude Opus 5) used

  • to assess the situation and present implementation avenues
  • for discussion while shaping the solution
  • for generating code and validating results

Clang based tooling is used frequently for code analysis and navigation.
This requires however that the exact flags and invocation is captured for
each possible translation unit in the code base. That knowledge exists solely
in the build system, and the established way to hand it over is the
LLVM "JSON Compilation Database".

SCons has provided a CompilationDatabase builder since 4.0, and it fits
our setup well: it installs an emitter on the object builders and captures
each command line while the dependency graph is constructed. Hence nothing
is compiled -- generating takes about two seconds -- and the result always
describes the complete build graph as declared, rather than the target
actually requested on this invocation.

This feature is provided as opt-in, either through the sticky option
COMPILEDB=yes or by direct invocation with scons compiledb

The compile_commands.json is generated into the build output `target/' dir
For configuration, a .clangd in project root instructs the language server
where to find this file.

Note the ordering constraint recorded in CompileDB.py:
the emitter must be installed only after Platform.configure() has run,
or it also captures the conftest_* compilations of the configure checks.
That is why this is a plain helper invoked from the SConstruct -- similar to
Setup, Options, Platform -- and not a tool loaded from the LumieraEnvironment.

Note: See TracTickets for help on using tickets.