Skip to content

Commit d7da9cc

Browse files
committed
fix: the toolchain stamp formats its numbers explicitly, and the design record carries front matter
`std::to_string` over a filesystem clock's rep and over `uintmax_t` is ambiguous on libc++, so the three sites that write or compare the stamp of a toolchain named by path format the two values through `std::format` with an explicit type. The design record gains the `subject`/`status` front matter every record dated 2026-09-08 or later carries.
1 parent ef6b450 commit d7da9cc

5 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎.agents/docs/2026-10-01-tool-and-toolchain-sources-design.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
subject: design
3+
status: landed
4+
---
5+
16
# 工具与工具链的来源:声明、编程决定、可观察
27

38
日期:2026-10-01。状态:已落地(mcpp 2026.10.1.3,mcpp#755)。

‎.agents/docs/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Records that declare one. Everything else is listed by date below.
3030

3131
### design
3232

33+
- [工具与工具链的来源:声明、编程决定、可观察](2026-10-01-tool-and-toolchain-sources-design.md) — landed
3334
- [A pack's build reported as a build, and a unit's compile independent of the member selection: triage and design (#753, #751)](2026-10-01-pack-drive-and-selection-independent-compile-design.md) — landed
3435
- [Member selection, build programs prepared once, a pack over several members, and the output streams of `mcpp run`: the plan for the release after 2026.9.30.2 (#748, #749, #750)](2026-09-30-member-selection-and-build-program-cost-plan.md) — landed
3536
- [The build's wall time, its progress count, a hang after the build, and #732 and #744: measurements and a remediation plan](2026-09-30-build-wall-time-progress-count-and-hang-plan.md) — landed
@@ -113,7 +114,7 @@ Records that declare one. Everything else is listed by date below.
113114

114115
### 2026-10
115116

116-
- [工具与工具链的来源:声明、编程决定、可观察](2026-10-01-tool-and-toolchain-sources-design.md)
117+
- [工具与工具链的来源:声明、编程决定、可观察](2026-10-01-tool-and-toolchain-sources-design.md) — landed
117118
- [A pack's build reported as a build, and a unit's compile independent of the member selection: triage and design (#753, #751)](2026-10-01-pack-drive-and-selection-independent-compile-design.md) — landed
118119
### 2026-09
119120

‎src/build/execute.cppm‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,12 @@ bool local_toolchain_unchanged(const std::filesystem::path& outputDir) {
15721572
if (ec) return false;
15731573
const auto time = std::filesystem::last_write_time(p, ec);
15741574
if (ec) return false;
1575-
if (std::to_string(size) != line.substr(0, t1)
1576-
|| std::to_string(time.time_since_epoch().count()) != line.substr(t1 + 1, t2 - t1 - 1))
1575+
// `std::format`, not `std::to_string`: the clock's rep and
1576+
// `uintmax_t` both convert to two integer overloads of the latter, and
1577+
// libc++ calls that ambiguous.
1578+
if (std::format("{}", static_cast<std::uint64_t>(size)) != line.substr(0, t1)
1579+
|| std::format("{}", static_cast<std::int64_t>(time.time_since_epoch().count()))
1580+
!= line.substr(t1 + 1, t2 - t1 - 1))
15771581
return false;
15781582
}
15791583
return true;

‎src/build/prepare/local_toolchain.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ std::string local_identity(const mcpp::toolchain::Toolchain& tc) {
100100
auto stamp = [&](const fs::path& p) {
101101
std::error_code ec;
102102
mix(p.generic_string());
103-
mix(std::to_string(fs::file_size(p, ec)));
103+
mix(std::format("{}", static_cast<std::uint64_t>(fs::file_size(p, ec))));
104104
auto t = fs::last_write_time(p, ec);
105-
mix(std::to_string(t.time_since_epoch().count()));
105+
mix(std::format("{}", static_cast<std::int64_t>(t.time_since_epoch().count())));
106106
};
107107
stamp(tc.binaryPath);
108108
for (auto const& [role, p] : tc.toolOverrides) { mix(role); stamp(p); }

‎src/build/prepare/records.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,10 @@ void step13_resolution_json(PrepareState& state, BuildContext& ctx) {
598598
std::error_code fe;
599599
const auto size = std::filesystem::file_size(p, fe);
600600
const auto time = std::filesystem::last_write_time(p, fe);
601-
st << size << '\t' << time.time_since_epoch().count() << '\t'
601+
// The same two spellings the fast path compares against.
602+
st << std::format("{}", static_cast<std::uint64_t>(size)) << '\t'
603+
<< std::format("{}", static_cast<std::int64_t>(
604+
time.time_since_epoch().count())) << '\t'
602605
<< p.string() << '\n';
603606
};
604607
put(ctx.tc.binaryPath);

0 commit comments

Comments
 (0)