Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions driver/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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> {
Expand Down
6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions quest/m0/mbx-seed.md
Original file line number Diff line number Diff line change
@@ -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