Expand description
Validate that a detected toolchain can run the commands the C++ backend emits.
The planner emits commands in one of two dialects - GCC/Clang-style or MSVC-style - chosen by the detected C++ compiler. The GCC/Clang shapes are:
- C++ compile:
cxx -std=<effective standard> -O… [-g] [-DNDEBUG] -MD -MF <depfile> -D<name> -I<dir> [-isystem <dir>] [extra-args] -c <src> -o <obj>. - Static-library archive:
ar crs <lib> <objs>. - Link:
cxx <objs> <libs> [extra-args] -o <exe>.
Any compiler / archiver that cannot run those exact shapes - or that lacks the flag for a requested language standard - is rejected up front rather than left to fail with a confusing Ninja error.
Structs§
- Requested
Standards - The set of language standards a build’s compiles request, per language. A language’s set is empty iff no compile of that language exists, which is the signal the C-compiler checks key on.
Functions§
- collect_
requested_ standards - Pre-plan approximation of
requested_standards_of: walk every selected package’s targets and classify each declared source. Over-approximates per target (it cannot know which targets the plan will reach), so it must not gate validation - use it only for decisions needed before planning, like the MSVC/external:Ifallback. Dev-only targets (test/example) contribute only for packages indev_for, mirroring dev-dependency activation. - msvc_
external_ includes_ supported - Whether every compiler that will run a compile in this build
accepts the MSVC-dialect distinct system-include spelling
(
/external:W0+/external:I <dir>). Mirrorsvalidate_toolchain_for_backend’s contract for the optionalccslot: the C compiler only weighs in when a C source exists, because the planner never invokes it otherwise. - requested_
standards_ of - The exact standards a planned build requests: every compile
action in the graph contributes its typed standard. This is the
set
validate_toolchain_for_backendshould be called with - the planner has already narrowed targets to the requested selection, so a sibling target that is not built cannot gate the toolchain. - validate_
planned_ standards - Surface the first standards violation the planner recorded that
survived into the final graph (after the
cabin checkrewrite, when applicable): an MSVC no-stable-flag compile or an escape-hatch flag conflict on a planned compile. Must run before anything is lowered or written; commands that skip the toolchain-validation pass (cabin tidy’s fail-soft path) must still call this so a violating compile cannot be silently dropped from the compile database. - validate_
toolchain_ for_ backend - Validate that every populated tool in
reportcan execute the command shapes emitted by the current backend. Returns the first problem encountered so users see one actionable error, not a wall of unrelated failures. - validate_
toolchain_ standards - Validate the plan-dependent half of the toolchain contract:
every language standard in
requested, plus - when the plan compiles C - the C compiler’s backend shape and dialect coherence.requestedis derived from the final planned graph viarequested_standards_of(after thecabin checkrewrite when applicable), so only compiles the command will run participate: an unbuilt sibling target, an unrelated C executable in a dependency package, or a dependency compile thatcabin checkdrops can never gate the build. Runs afterplan()and before any Ninja file is written; the plan-independent C++/archiver shape checks invalidate_toolchain_for_backendstay pre-plan so a broken toolchain still fails fast.