diff --git a/driver/src/cargo.rs b/driver/src/cargo.rs index e9a1d84d1..5792a0ad1 100644 --- a/driver/src/cargo.rs +++ b/driver/src/cargo.rs @@ -178,7 +178,19 @@ impl Check<'_> { } cmd }; - run_cargo(cargo("clean").arg("--quiet").args(resolution(self.args)))?; + // Show what it says only when it fails: `--quiet` would hide even its error. + let clean = cargo("clean") + .args(resolution(self.args)) + .output() + .map_err(|err| format!("running cargo clean: {err}"))?; + if !clean.status.success() { + return Err(format!( + "cargo clean of {} failed ({}): {}", + target_dir.display(), + clean.status, + String::from_utf8_lossy(&clean.stderr).trim() + )); + } // Its own, since runs may share a target directory. let ran = target_dir.join(format!("{}-{}.ran", self.tool, std::process::id())); match std::fs::remove_file(&ran) { @@ -226,14 +238,6 @@ fn cargo() -> Command { Command::new(std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into())) } -fn run_cargo(cmd: &mut Command) -> Result<(), String> { - let status = cmd.status().map_err(|err| format!("running cargo: {err}"))?; - match status.success() { - true => Ok(()), - false => Err(format!("{cmd:?} failed")), - } -} - /// The cargo args that pick how the workspace resolves, which `cargo clean` resolves it /// by too: `--config`, and the lockfile and network flags. fn resolution(args: &[String]) -> Vec<&str> { diff --git a/flake.nix b/flake.nix index 417d2b8ac..10f622b36 100644 --- a/flake.nix +++ b/flake.nix @@ -300,6 +300,12 @@ # The free-threaded CPython the generated Python must refuse. By path, since its # python3 would shadow the GIL build's on PATH. PYTHON_FREE_THREADED = "${pkgs.python314FreeThreading}/bin/python3.14t"; + # mbx's target seeding creates the drivers' own target directories, such as + # target/rust2-ffi, without the CACHEDIR.TAG cargo writes into each it creates, and + # `cargo clean --target-dir` refuses a directory without one. It saves about 4% of a + # fresh checkout's first build, which mbx's cache already serves. Off until mbx + # fixes it: quest/m0/mbx-seed.md. + MBX_TARGET_SEED = "false"; # The pinned toolchain goes on PATH ahead of everything the host had, which # shadows the Cargo shim `mbx setup` installs. Put it back in front, as moq's dev # shell does, so cargo builds through mbx's cache wherever the host set one up, diff --git a/quest/m0/mbx-seed.md b/quest/m0/mbx-seed.md new file mode 100644 index 000000000..a134fd743 --- /dev/null +++ b/quest/m0/mbx-seed.md @@ -0,0 +1,24 @@ +# [XS] Turn mbx's target seeding back on + +## Goal + +`flake.nix` no longer sets `MBX_TARGET_SEED`, and a fresh checkout's `just ffi surface` +passes with seeding on, locally and in the merge queue. + +## Plan + +mbx's seeding copies registry build units into every target directory it learned from +another checkout, nested ones such as `target/rust2-ffi` included, and creates them +without cargo's `CACHEDIR.TAG`; `cargo clean --target-dir` then refuses them. Once mbx +tags what it creates, or stops seeding a directory the checkout never built in, delete the +setting, bump the queue's mbx pin in `.github/workflows/queue-build.yml` to that release, +and check a fresh worktree whose first build seeds from another, with a donor that has a +`target/rust2-ffi`. If mbx tags what it creates, check that the seeded `target/rust2-ffi` +holds a `CACHEDIR.TAG`; if it skips the directory, check that it creates no +`target/rust2-ffi`. Either way, `just ffi surface` passes. + +## Waiting + +- Maintainer: file the mbx issue drafted for this, and link it here +- jdx/mr-boxington: a release whose seeding writes `CACHEDIR.TAG` or skips nested target + directories