Preserve the previous build output when writing its Cargo receipt fails

未关闭
#1,079 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@hiyouwhatsapp 已经在做这个了。

开始于 2026年11月7日。

  • #1087 来自 @hiyouwhatsapp —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
56/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
build-system, cli

调研方向

Start at the binary activation and receipt writing sequence in tools/src/build.rs around line 119, then trace the existing package backup restoration work in #1001 and the build identity checks. Reproduce the receipt destination conflict described in the issue and inspect the build-cargo tests for activation and rollback coverage. Done means a failed receipt write preserves both previous outputs or reports a retained recovery location, with successful builds activating a matching pair.

由索引模型根据 Issue 内容生成。

描述

bug build help wanted

Problem

The build-cargo helper replaces the requested output binary before writing its build.json receipt. If receipt serialization or activation fails, the helper returns an error after the previous output has already been lost. The two outputs can then describe different build generations.

Starting point: binary activation followed by receipt writing.

Reproduction

Audited canonical master e1f8effd195b6339c3979b1e091e63c25f1da983 on Linux amd64 with checkout-built Wave 0.0.1-alpha-dev, matching std, Rust 1.89.0, Cargo jobs=2 and LLVM 21.1.8. The master SHA was rechecked before registration.

Build the two tools from the audited checkout using the pinned toolchain and matching LLVM. The following Linux reproduction invokes real incremental Cargo, uses only disposable output paths, and makes the receipt destination a directory to force a deterministic activation error:

from pathlib import Path
import os
import subprocess
import tempfile

root = Path.cwd()
with tempfile.TemporaryDirectory(prefix="wave-build-receipt-") as temporary:
    output = Path(temporary) / "wavec"
    output.write_bytes(b"PREVIOUS-COMPILER")
    receipt = output.with_suffix(".build.json")
    receipt.mkdir()
    environment = os.environ.copy()
    environment["LLVM_SYS_211_PREFIX"] = "/usr/lib64/llvm21"
    result = subprocess.run([
        str(root / "target/debug/wave-tools"), "build-cargo",
        "--target", "x86_64-unknown-linux-gnu",
        "--binary", str(root / "target/debug/wavec"),
        "--output", str(output), "--",
        "cargo", "+1.89.0", "build", "--locked", "--jobs", "2",
        "-p", "wavec", "--bin", "wavec",
    ], env=environment, capture_output=True, text=True, timeout=300)
    print("exit:", result.returncode)
    print(result.stderr.strip())
    print("old bytes preserved:", output.read_bytes() == b"PREVIOUS-COMPILER")
    print("output header:", output.read_bytes()[:4])

Observed:

exit: 1
wave-tools: Is a directory (os error 21)
old bytes preserved: False
output header: b'\x7fELF'

The Cargo compiler build itself succeeded. Despite the helper's failed result, the previous sentinel was replaced by the new compiler. A directory at the receipt path is one reproducible failure injection, not the only possible receipt I/O failure.

Scope

Treat binary and receipt activation as one recoverable build-output operation. Prepare and validate both destinations before replacement; any later failure must preserve or restore the prior output set, retaining a recoverable backup if restoration itself fails. Keep Cargo compilation and Meson orchestration unchanged.

Related: #1001 covered package-set backup restoration, while #1070 delivered Rust tooling. Neither covers this build-cargo binary/receipt activation order.

Completion criteria

  • A receipt-write failure leaves the previous binary and receipt usable, or reports a retained recovery location if rollback cannot finish.
  • A successful invocation activates a matching binary/receipt pair.
  • Regressions cover a conflicting receipt destination and failures around activation and restoration.
  • Native platform replacement semantics and existing package/build identity checks remain intact.
主要语言
Rust
星标
56
派生
21
平均合并
23 小时 20 分钟
30 天内合并 PR
45

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wavefnd/Wave 的其他 Issue

查看 wavefnd/Wave 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。