2026.9.29.1: a workspace is one graph per configuration; the planning regression of 2026.9.28.3 fixed at its cause - #738
Merged
Conversation
… the configuration, linked placement, the virtual root and member edges
modules/graph provides topological_order, levels and closure over plain
index-addressed adjacency lists (std::vector<std::vector<std::size_t>>,
edge u -> v meaning "u depends on v"). Kahn's algorithm keeps its ready
set ordered, so ties break by ascending node index; a cycle is reported
as the ordered ring that walks it rather than the set of nodes left
over.
Five hand-written variants are migrated onto it, each previously a
private DFS or Kahn's-algorithm implementation with its own tie-break
and cycle-reporting shape:
- src/modgraph/graph.cppm: topo_sort's Kahn's algorithm. The cycle
diagnostic in validate.cppm now names the ring ("a -> b -> c -> a")
instead of an unordered list of suspects.
- src/build/prepare/features.cpp: the within-package unit order by
imports (falls back to declaration order on a cycle, preserving the
existing "leave it to the compiler" behaviour), and the cross-package
host-module provider order (restricted to each consumer's own
reachable closure before calling into the module, so a cycle outside
that closure cannot fail an unrelated consumer's build).
- src/build/prepare/graph.cpp: step4b_cycle_check's package-cycle DFS.
- src/build/dep_graph.cppm: transitive_dependencies, on mcpp::graph::closure.
- src/build/prepare/plan.cpp: the build-cache key fold walks
topological_order instead of recursing, turning the memoized
recursion into a loop; the per-node fold and taint stay local to the
caller.
modules/graph/tests covers ties, diamonds, disconnected components,
self-loops, a longer cycle (path checked exactly), levels and closure,
including the include/exclude-roots and cycle-tolerant cases.
…rectories, the workspace fast path, the scheduler, the lock, clean --stale, tests, documentation and the 2026.9.29.1 version
…e package reads its own workspace dependencies, pooled flags kept for units no member owns, the group link line checked for hermeticity, runtime files placed in the product directory
…me limit documented
… shared helpers (file length), the design record carries its front matter, and PackageRoot holds no optional string (clang with the MSVC STL cannot copy one)
…ink order, and so Mach-O initializer order) and the host-module depth-first orders; groups sharing one build directory build one after the other; status lines written whole
…ter-free, ninja-build/ninja#2662); pack reads runtime files against the product directory; a program shipped through artifacts is linked with its package's intermediates and placed in each member's product directory; a file never takes a product directory's path
Sunrisepeak
added a commit
to openxlings/xim-pkgindex
that referenced
this pull request
Sep 29, 2026
mcpp 2026.9.29.1: a workspace is one graph per configuration (mcpp-community/mcpp#738).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A workspace is built as one graph per configuration (design:
.agents/docs/2026-09-29-workspace-build-graph-design.md, revision 4, with theimplementation record in §17). Released as 2026.9.29.1.
shared member as the root of a nested build, which met E1's condition again,
so a chain of n members cost 2^n plans (a nine-member workspace with nothing
to build: 79 s against 6.3 s). E1 is removed with everything that served it
(nested plans, member stage edges, the member lock,
packageKeys, e2e 830).(
--workspace,-p X, the member directory, the rooted package) and plansthem under a virtual root with member edges. Members that share their
root-position values are one plan with one
build.ninja; a member used byseveral members is compiled once. Members that differ are separate plans,
built concurrently under a static share of the jobs.
target/<triple>/<configuration>/bin/<package name>/(qualified on a namecollision; the rooted package keeps
bin/), with the runtime files and thegraph-built shared libraries its programs load. Each member links its own
closure: a link group holds the closure's flags and runtime contract, and the
link edge carries the group's line.
and include directories reach its commands, not the directory name; editing
them rebuilds that package in place.
build.ninjarecords a request tag(members and features) that every fast path compares.
(2026.9.28.3) against 0.51 s planned and 3 ms replayed.
required_features),dev-dependencies under
mcpp test, hooks,when = "dev"xlings entries,--features, and a build program run after every dependency's program withits own graph document.
selections;
clean --staleremoves the members' old build directories.mcpp.graph(modules/graph): stable topological order with the cyclepath, levels, closure; five hand-written algorithms migrated.
Refs #734. The module-name limit across members is documented and tracked by #732.
Test plan
mcpp build(self-host) andmcpp test: 135 unit tests; the new ones areWorkspacePlan.*,BuildStagelinked placement,BuildProfileconfiguration key,
GraphShape.TheHeaderNamesTheRequest, andmcpp test -p graph(22 tests).-pafter--workspacecompiles nothing, a flag edit rebuilds one member, twoconfigurations, product directories, qualified names,
clean --stale),834 (planning once, fast path in under a second), 835 (linked placement).
moved with the layout updated (35, 120, 211, 218, 321, 770, 806).
2026.9.28.3 on the same machine (its default toolchain is llvm; the tests
assume gcc), except the tests updated above.
buildandtest;mcppls
build,build -p devtoolsandtest.tests/run_members.sh.