@@ -68,6 +68,97 @@ bool graph_supplies_system(const PrepareState& state) {
6868
6969} // namespace
7070
71+ // OVERRIDING THE CONVENTION IS ALLOWED; OVERRIDING IT AND SUPPLYING
72+ // NOTHING IN ITS PLACE IS NOT, AND UNTIL THIS BLOCK IT LOOKED THE SAME.
73+ //
74+ // A hosted row's pin names the payload that supplies the target's C
75+ // library. A project may name a different compiler — that is the escape
76+ // hatch the whole convention/capability distinction exists to protect —
77+ // and the ordinary reason to do so is that its dependency graph supplies
78+ // the C library instead. `examples/06-openkal-cross` is exactly that:
79+ // `llvm@22.1.8` plus `openkal-llvm-runtime`, and `graphSuppliesSystem`
80+ // is true there.
81+ //
82+ // WITH NEITHER, THE BUILD USED TO RUN ANYWAY AND FAIL SOMEWHERE ELSE.
83+ // Measured 2026-08-26 on Linux, `[toolchain] default = "llvm@22.1.8"`
84+ // and no dependencies:
85+ //
86+ // --target x86_64-linux-musl
87+ // hermetic link check failed … crtbeginT.o (bare name)
88+ // --target x86_64-windows-gnu
89+ // hermetic link check failed …
90+ // /usr/lib/gcc/x86_64-w64-mingw32/13-win32/crtbegin.o (outside)
91+ //
92+ // Both are accurate about the symptom and silent about the decision:
93+ // clang is retargetable and brings no C library, so it reached for a
94+ // gcc installation — one that does not exist under the payload prefix
95+ // in the first case, and that belongs to the HOST in the second. There
96+ // is no llvm payload supplying either target's C library today.
97+ //
98+ // THE REFUSAL IS DECIDED HERE BECAUSE ONLY HERE ARE BOTH HALVES
99+ // KNOWN. The row is read a thousand lines earlier and the graph does
100+ // not exist then; `host_can_serve` is family-agnostic and would answer
101+ // "yes, some payload here produces it" — the same shape as the family
102+ // this release is about, a predicate answering a question narrower than
103+ // the one it is asked.
104+ static std::expected<void , std::string> decide_convention (PrepareState& state, bool graphSuppliesSystem) {
105+ if (!state.targetRowPin .empty () && !graphSuppliesSystem
106+ && tc_origin_is_user_explicit (state.tcOrigin ) && state.tcSpec .has_value ()) {
107+ auto declared = mcpp::toolchain::parse_toolchain_spec (*state.tcSpec );
108+ auto rowTc = mcpp::toolchain::parse_toolchain_spec (state.targetRowPin );
109+ // A provider that pairs with the declared family supplies the system
110+ // with it (SPEC-016 §6): the row's payload becomes that compiler's.
111+ const bool paired = declared && rowTc && declared->family != rowTc->family
112+ && std::ranges::any_of (mcpp::toolchain::target::providers (), [&](auto const * p) {
113+ return p->name == state.targetChoice .provider
114+ && mcpp::toolchain::target::serves (*p, state.targetRowName )
115+ && std::ranges::find (p->pairs , mcpp::toolchain::family_name (declared->family ))
116+ != p->pairs .end ();
117+ });
118+ // A PAIRED PROVIDER THIS HOST DOES NOT HAVE SUPPLIES NOTHING. The
119+ // selection took it as the first candidate of all, none being
120+ // available (§4.6); with the toolchain stated, the diagnosis of an
121+ // unserved target was not composed, and the payload's install
122+ // failed as an unnamed refusal (target matrix, linux-aarch64).
123+ auto const & choice = state.targetChoice ;
124+ const bool pairedHere = std::ranges::any_of (choice.candidates , [&](auto const & k) {
125+ return k.available && k.provider && k.provider ->name == choice.provider
126+ && k.row && k.row ->triple == choice.identity ;
127+ });
128+ if (paired && !pairedHere) {
129+ refusal::record (refusal::Code::HostCannotServe);
130+ return std::unexpected (std::format (
131+ " target '{}' with {} takes its system from the '{}' provider's {} payload, "
132+ " which this host does not have.\n "
133+ " `mcpp why target --target {}` lists the providers of the target and "
134+ " where each is available; depend on a package that implements the "
135+ " target's system to build it here." ,
136+ state.targetRowName , *state.tcSpec , choice.provider , state.targetRowPin ,
137+ state.targetRowName ));
138+ }
139+ if (paired) state.pairedSystem = state.targetRowPin ;
140+ else if (declared && rowTc && declared->family != rowTc->family ) {
141+ refusal::record (refusal::Code::ConventionUnreplaced);
142+ return std::unexpected (std::format (
143+ " target '{}' takes its C library from the '{}' payload, and "
144+ " '{}' has none here.\n "
145+ " The row's toolchain is a convention, so naming your "
146+ " own compiler overrides it —\n "
147+ " but the convention is what supplies this target's "
148+ " headers and C library, and\n "
149+ " nothing in the dependency graph supplies them "
150+ " instead.\n "
151+ " depend on a package that implements the target's C "
152+ " library (openkal-musl and\n "
153+ " openkal-llvm-runtime are the ones in the index), or "
154+ " remove the `[toolchain]`\n "
155+ " line so `{}` is used for this target." ,
156+ state.targetRowName , state.targetRowPin , *state.tcSpec , state.targetRowPin ));
157+ }
158+ }
159+ return {};
160+ }
161+
71162std::expected<void , std::string> phase5_toolchain_after_graph (PrepareState& state) {
72163
73164 // ─── The toolchain, resolved now that the graph exists ──────────────────
@@ -392,93 +483,7 @@ std::expected<void, std::string> phase5_toolchain_after_graph(PrepareState& stat
392483 }
393484 }
394485 }
395- // OVERRIDING THE CONVENTION IS ALLOWED; OVERRIDING IT AND SUPPLYING
396- // NOTHING IN ITS PLACE IS NOT, AND UNTIL THIS BLOCK IT LOOKED THE SAME.
397- //
398- // A hosted row's pin names the payload that supplies the target's C
399- // library. A project may name a different compiler — that is the escape
400- // hatch the whole convention/capability distinction exists to protect —
401- // and the ordinary reason to do so is that its dependency graph supplies
402- // the C library instead. `examples/06-openkal-cross` is exactly that:
403- // `llvm@22.1.8` plus `openkal-llvm-runtime`, and `graphSuppliesSystem`
404- // is true there.
405- //
406- // WITH NEITHER, THE BUILD USED TO RUN ANYWAY AND FAIL SOMEWHERE ELSE.
407- // Measured 2026-08-26 on Linux, `[toolchain] default = "llvm@22.1.8"`
408- // and no dependencies:
409- //
410- // --target x86_64-linux-musl
411- // hermetic link check failed … crtbeginT.o (bare name)
412- // --target x86_64-windows-gnu
413- // hermetic link check failed …
414- // /usr/lib/gcc/x86_64-w64-mingw32/13-win32/crtbegin.o (outside)
415- //
416- // Both are accurate about the symptom and silent about the decision:
417- // clang is retargetable and brings no C library, so it reached for a
418- // gcc installation — one that does not exist under the payload prefix
419- // in the first case, and that belongs to the HOST in the second. There
420- // is no llvm payload supplying either target's C library today.
421- //
422- // THE REFUSAL IS DECIDED HERE BECAUSE ONLY HERE ARE BOTH HALVES
423- // KNOWN. The row is read a thousand lines earlier and the graph does
424- // not exist then; `host_can_serve` is family-agnostic and would answer
425- // "yes, some payload here produces it" — the same shape as the family
426- // this release is about, a predicate answering a question narrower than
427- // the one it is asked.
428- if (!state.targetRowPin .empty () && !graphSuppliesSystem
429- && tc_origin_is_user_explicit (state.tcOrigin ) && state.tcSpec .has_value ()) {
430- auto declared = mcpp::toolchain::parse_toolchain_spec (*state.tcSpec );
431- auto rowTc = mcpp::toolchain::parse_toolchain_spec (state.targetRowPin );
432- // A provider that pairs with the declared family supplies the system
433- // with it (SPEC-016 §6): the row's payload becomes that compiler's.
434- const bool paired = declared && rowTc && declared->family != rowTc->family
435- && std::ranges::any_of (mcpp::toolchain::target::providers (), [&](auto const * p) {
436- return p->name == state.targetChoice .provider
437- && mcpp::toolchain::target::serves (*p, state.targetRowName )
438- && std::ranges::find (p->pairs , mcpp::toolchain::family_name (declared->family ))
439- != p->pairs .end ();
440- });
441- // A PAIRED PROVIDER THIS HOST DOES NOT HAVE SUPPLIES NOTHING. The
442- // selection took it as the first candidate of all, none being
443- // available (§4.6); with the toolchain stated, the diagnosis of an
444- // unserved target was not composed, and the payload's install
445- // failed as an unnamed refusal (target matrix, linux-aarch64).
446- auto const & choice = state.targetChoice ;
447- const bool pairedHere = std::ranges::any_of (choice.candidates , [&](auto const & k) {
448- return k.available && k.provider && k.provider ->name == choice.provider
449- && k.row && k.row ->triple == choice.identity ;
450- });
451- if (paired && !pairedHere) {
452- refusal::record (refusal::Code::HostCannotServe);
453- return std::unexpected (std::format (
454- " target '{}' with {} takes its system from the '{}' provider's {} payload, "
455- " which this host does not have.\n "
456- " `mcpp why target --target {}` lists the providers of the target and "
457- " where each is available; depend on a package that implements the "
458- " target's system to build it here." ,
459- state.targetRowName , *state.tcSpec , choice.provider , state.targetRowPin ,
460- state.targetRowName ));
461- }
462- if (paired) state.pairedSystem = state.targetRowPin ;
463- else if (declared && rowTc && declared->family != rowTc->family ) {
464- refusal::record (refusal::Code::ConventionUnreplaced);
465- return std::unexpected (std::format (
466- " target '{}' takes its C library from the '{}' payload, and "
467- " '{}' has none here.\n "
468- " The row's toolchain is a convention, so naming your "
469- " own compiler overrides it —\n "
470- " but the convention is what supplies this target's "
471- " headers and C library, and\n "
472- " nothing in the dependency graph supplies them "
473- " instead.\n "
474- " depend on a package that implements the target's C "
475- " library (openkal-musl and\n "
476- " openkal-llvm-runtime are the ones in the index), or "
477- " remove the `[toolchain]`\n "
478- " line so `{}` is used for this target." ,
479- state.targetRowName , state.targetRowPin , *state.tcSpec , state.targetRowPin ));
480- }
481- }
486+ if (auto r = decide_convention (state, graphSuppliesSystem); !r) return r;
482487 if (auto r = state.resolve_target_toolchain (); !r)
483488 return std::unexpected (r.error ());
484489 }
0 commit comments