Auto merge of #118946 - onur-ozkan:fix-clean, r=clubby789

fix `x clean` for cross-compiled artifacts

```toml
build = "x86_64-unknown-linux-gnu"
host = ["arm-unknown-linux-gnueabihf"]
target = ["arm-unknown-linux-gnueabihf"]
```

On `x86_64-unknown-linux-gnu`, after cross-compiling with the sample configuration above, artifacts under `build/x86_64-unknown-linux-gnu` never gets cleaned with `x clean`. This PR fixes that.
This commit is contained in:
bors 2023-12-18 22:42:16 +00:00
commit e719b6fc40

View File

@ -149,8 +149,14 @@ fn clean_default(build: &Build) {
rm_rf(&build.out.join("bootstrap-shims-dump")); rm_rf(&build.out.join("bootstrap-shims-dump"));
rm_rf(&build.out.join("rustfmt.stamp")); rm_rf(&build.out.join("rustfmt.stamp"));
for host in &build.hosts { let mut hosts: Vec<_> = build.hosts.iter().map(|t| build.out.join(t.triple)).collect();
let entries = match build.out.join(host.triple).read_dir() { // After cross-compilation, artifacts of the host architecture (which may differ from build.host)
// might not get removed.
// Adding its path (linked one for easier accessibility) will solve this problem.
hosts.push(build.out.join("host"));
for host in hosts {
let entries = match host.read_dir() {
Ok(iter) => iter, Ok(iter) => iter,
Err(_) => continue, Err(_) => continue,
}; };