Skip to content

Commit 5ead2d0

Browse files
speak-agentclaude
andcommitted
prepare: file headers, phase declarations in order, an accurate layout note
- Every phase file opens with what it holds (P0 to P13) and the helper files with their concern, as the rest of the tree does. - `:state` declares the phase functions in the order the driver runs them. - prepare.cppm's layout note lists all sixteen files as they are, states that the interface defines nothing beyond its exported inline functions, and cites #721 for the GCC 16.1 constraint. - check_file_lengths.sh no longer points at a document outside this repository or counts the units. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1a22790 commit 5ead2d0

14 files changed

Lines changed: 80 additions & 38 deletions

‎.github/tools/check_file_lengths.sh‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
#
77
# prepare.cppm was 16,105 lines: one exported function, prepare_build, ~85%
88
# of the file, ~180 top-level locals sharing a stack frame. It was split into
9-
# a primary interface (src/build/prepare.cppm), an implementation partition
10-
# (src/build/prepare/state.cppm) and twelve implementation units, each phase
11-
# a function taking PrepareState& instead of closing over the old locals
12-
# directly — see the layout comment at the top of prepare.cppm and
13-
# .agents/docs/2026-09-27-mcpp-2026.9.27.1-ecosystem-plan.md §4.
9+
# a primary interface (src/build/prepare.cppm) holding declarations, an
10+
# implementation partition (src/build/prepare/state.cppm) and implementation
11+
# units, each phase a function taking PrepareState& instead of closing over
12+
# the old locals directly -- see the layout comment at the top of
13+
# prepare.cppm, and mcpp-community/mcpp#721 for the GCC 16.1 constraint that
14+
# shapes it.
1415
#
1516
# A size cap with no gate is a target nobody re-checks. The decomposition's
1617
# whole point was to keep any one file's compile from blocking on the rest —

‎src/build/prepare.cppm‎

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,40 @@
22
// core (workspace -> toolchain -> dependency resolution -> features ->
33
// modgraph -> fingerprint -> plan -> lockfile).
44
//
5-
// LAYOUT. This file is the primary interface: exported types, and
6-
// prepare_build's own exported declaration (default arguments included —
7-
// they belong on the declaration, not the definition). Nothing else. The
8-
// implementation lives under src/build/prepare/:
9-
// state.cppm implementation partition `:state` — PrepareState (the
10-
// working state every phase reads and writes, by
11-
// reference, in place of prepare_build's former ~180
12-
// locals) and the phase functions' declarations.
13-
// driver.cpp prepare_build's definition: construct PrepareState,
14-
// call each phase in order, return the last one's result.
15-
// manifest.cpp P0 — manifest and workspace resolution.
16-
// toolchain.cpp P1, P2, P5 — toolchain spec, the toolchain resolver
17-
// closure (P2 defines it, P5 calls it), the toolchain
18-
// decision once the graph exists.
19-
// xlings.cpp P3 — xlings payload before the graph.
20-
// graph_load.cpp P4a — the git/path/version dependency loader
21-
// (loadVersionDep), called from graph.cpp.
22-
// graph.cpp P4b — the worklist engine and cycle detection that
23-
// call it.
24-
// features.cpp P6-P8 — feature activation, capability/ABI
25-
// accumulation, target side, host-tool provisioning.
26-
// target_side.cpp P9 — the target side, resolved once against the graph.
27-
// scan.cpp P11 — the modgraph scan, validation, fingerprint.
28-
// plan.cpp P13 — BuildContext: plan, assembly, Windows resources,
29-
// the global cache, mcpp.lock, resolution.json.
30-
//
31-
// A GCC 16.1 CONSTRAINT SHAPES ALL OF THIS. Verified locally (archived on
32-
// branch wip/prepare-split; see the mcpp repository's `upstream`-labelled GCC
33-
// issue for the minimal reproduction): inserting a new INTERFACE unit into
5+
// LAYOUT. This file is the primary interface: the exported types, the exported
6+
// inline functions, and the declarations of every other exported function,
7+
// default arguments included (they belong on the declaration, not the
8+
// definition). Nothing else is defined here. The implementation lives under
9+
// src/build/prepare/:
10+
// state.cppm implementation partition `:state`: PrepareState (the
11+
// working state every phase reads and writes, by
12+
// reference, in place of prepare_build's former ~180
13+
// locals), the phase functions' declarations, and the
14+
// declarations of the helpers the phases share.
15+
// driver.cpp prepare_build: construct PrepareState, run the phases
16+
// in order, return what the last one builds.
17+
// manifest.cpp P0 -- the manifest and its workspace.
18+
// toolchain.cpp P1, P2 -- the toolchain specification and target axis;
19+
// the toolchain resolver's definition.
20+
// xlings.cpp P3 -- xlings payloads before the graph.
21+
// graph_load.cpp P4a -- loading one git, path or version dependency.
22+
// graph.cpp P4b -- the worklist, the graph, the cycle check.
23+
// toolchain_decision.cpp P5 -- the toolchain, decided once the graph exists.
24+
// features.cpp P6-P8 -- features, capabilities, host tools, and the
25+
// dependencies' build programs.
26+
// target_side.cpp P9, P10 -- the target side and each dependency's link form.
27+
// scan.cpp P11, P12 -- the module scan, validation, fingerprint.
28+
// plan.cpp P13 -- the BuildContext, mcpp.lock, resolution.json.
29+
// config.cpp, options.cpp, toolchain_env.cpp, fetch.cpp
30+
// the helpers the phases share: manifest merges and
31+
// feature requests; invocation options; target rows,
32+
// sysroots and build-program environments; git remotes
33+
// and xlings provisioning.
34+
// Every file stays at or below 2,500 lines (.github/tools/check_file_lengths.sh).
35+
//
36+
// A GCC 16.1 CONSTRAINT SHAPES ALL OF THIS. Measured locally and recorded in
37+
// mcpp-community/mcpp#721 (the archived attempt is branch wip/prepare-split):
38+
// inserting a new INTERFACE unit into
3439
// mcpp.build.prepare's import chain — a separately named module, or an
3540
// interface partition (`export module mcpp.build.prepare:x;`) — makes GCC
3641
// 16.1 segfault in add_imported_namespace while reading `import mcpp.cli;`

‎src/build/prepare/driver.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// driver.cpp -- prepare_build itself: construct the PrepareState, run the
2+
// phases in order, and return what the last one builds. An early error of any
3+
// phase ends the call with that phase's message.
4+
15
module mcpp.build.prepare;
26
import :state;
37

‎src/build/prepare/features.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// features.cpp -- P6 to P8: feature activation, capability and ABI
2+
// requirements, host-tool provisioning, and the dependencies' build programs.
3+
14
module mcpp.build.prepare;
25
import :state;
36

‎src/build/prepare/graph.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// graph.cpp -- P4b: the dependency worklist, the resolved graph and the
2+
// package-cycle check.
3+
14
module mcpp.build.prepare;
25
import :state;
36

‎src/build/prepare/graph_load.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// graph_load.cpp -- P4a: loading one dependency (git, path or index
2+
// version) into the graph; the worklist in graph.cpp calls it.
3+
14
module mcpp.build.prepare;
25
import :state;
36

‎src/build/prepare/manifest.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// manifest.cpp -- P0: the effective manifest and the workspace it belongs to,
2+
// from the one loader every command uses.
3+
14
module mcpp.build.prepare;
25
import :state;
36

‎src/build/prepare/plan.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// plan.cpp -- P13: the BuildContext: the plan, prebuilt dependencies,
2+
// assembly units, Windows resources, the global cache, mcpp.lock and
3+
// resolution.json.
4+
15
module mcpp.build.prepare;
26
import :state;
37

‎src/build/prepare/scan.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// scan.cpp -- P11 and P12: the module scan and its validation, the
2+
// standard-module gate, and the fingerprint.
3+
14
module mcpp.build.prepare;
25
import :state;
36

‎src/build/prepare/state.cppm‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,17 +526,17 @@ struct PrepareState {
526526
// prepare_build(). Ordinary (non-static) module-linkage declarations --
527527
// static would give each definition internal linkage, invisible outside
528528
// its own file.
529-
std::expected<void, std::string> phase9_target_side(PrepareState& state);
530-
std::expected<void, std::string> phase11_scan(PrepareState& state);
531-
std::expected<BuildContext, std::string> phase13_finish(PrepareState& state);
532529
std::expected<void, std::string> phase0_manifest_and_workspace(PrepareState& state);
533530
std::expected<void, std::string> phase1_toolchain_spec_and_axes(PrepareState& state);
534531
std::expected<void, std::string> phase2_define_toolchain_resolver(PrepareState& state);
535-
std::expected<void, std::string> phase5_toolchain_after_graph(PrepareState& state);
536532
std::expected<void, std::string> phase3_xlings_before_graph(PrepareState& state);
537533
std::expected<void, std::string> phase4a_graph_load(PrepareState& state);
538534
std::expected<void, std::string> phase4b_graph_worklist(PrepareState& state);
535+
std::expected<void, std::string> phase5_toolchain_after_graph(PrepareState& state);
539536
std::expected<void, std::string> phase6_features_and_host_tools(PrepareState& state);
537+
std::expected<void, std::string> phase9_target_side(PrepareState& state);
538+
std::expected<void, std::string> phase11_scan(PrepareState& state);
539+
std::expected<BuildContext, std::string> phase13_finish(PrepareState& state);
540540

541541
// ── Helpers the phases share, defined in the files named below ─────────────
542542

0 commit comments

Comments
 (0)