Repository navigation
fix(xvm): switch the whole release on xlings use, or none of it - #397
Merged
Merged
Conversation
cmd_use decided and acted at the same time. It swapped the entry target's headers and libraries first, then walked the binding edges by hand to find everything else. Two problems followed from that order. The walk was keyed by target rather than by (target, version) and never checked that what it reached existed, so a stale edge led to a version with no payload, which it wrote into the active workspace anyway. The shim then failed at exec time, far from the command that caused it. And because the swap ran before the walk, and only for the entry target, a failure part-way through left the sysroot holding one release while the workspace claimed another. Switching gcc while leaving the previous release's libstdc++ headers in place is how gcc (XPKG: xlings install fromsource:gcc) 15.1.0 Copyright (C) 2025 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. reports the right thing and the compile fails anyway. Split the decision from the work. plan_use_switch resolves the release through resolve_binding_selection, preflights every member's payload, and returns the filesystem changes -- or an error, having touched nothing. cmd_use carries the plan out. Everything the plan covers is now per member rather than per entry point: headers and libraries move for the whole release, members already in place emit no change, and entering from gcc, g++ or libstdc++ yields the same plan. The split is also what makes any of this testable. cmd_use needs a Config singleton and a real filesystem, so none of its logic could be reached from a unit test; the seven cases here run against the pure function.
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.
Problem
cmd_use把决策和执行混在一起:先换入口 target 的头文件和库,再手工遍历 binding 边去找其它成员。这个顺序带来两个问题。1. 遍历不安全。 以 target(而非
(target, version))为 visited key,且从不检查抵达的东西是否存在。一条残缺边把它带到一个没有 payload 的版本,它照样写进 active workspace —— shim 在 exec 时才失败,离肇事命令已经很远。2. 顺序错误。 交换在遍历之前、且只对入口 target 执行。中途失败就留下 sysroot 是一个 release、workspace 声称另一个。
Change
把决策和执行拆开。
plan_use_switch(纯函数)通过resolve_binding_selection解析整个 release、预检每个成员的 payload,返回需要做的文件系统改动 —— 或者返回错误,且什么都没碰。cmd_use只负责执行这个 plan。plan 覆盖的一切现在都是逐成员而非逐入口:
gcc、g++或libstdc++进入,得到同一个 plan这个拆分也是可测性的来源
cmd_use需要 Config 单例和真实文件系统,它内部的逻辑此前没有一行能被单测触及。现在 7 条用例跑在纯函数上:PlansEveryMemberNotJustTheEntryPointSwapsHeadersAndLibsForEveryMovingMemberMembersAlreadyInPlaceProduceNoChangeEveryEntryPointYieldsTheSamePlanAMissingMemberIsAnErrorNotAPartialSwitchAnUnresolvableGroupIsRefusedBeforeAnyChangeAnUngroupedTargetSwitchesOnItsOwn场景验收进度
这解决了评审 §5.1 的目标输出:
或者什么都不发生 + 具名原因 + hint。
对应 A1(切换程序)、A2/A3(切换头文件/库)、A4(失败零改动)、A5(多入口一致)。端到端证明仍在 P4.2。
Verification
CI 状态为已知上游拉取签名(见 #386),依计划 §3.1.1 合入集成分支。