Closed sandhose closed 11 months ago
I'm not sure why it's not created because eventually it's cargo driving the build, cargo-zigbuild
only sets up some environment variables to use zig as c/c++ compiler and linker.
Nothing obvious I can do here.
But the issue exists, can be reliably reproduced, has real consequences (in my case, macOS CI builds not being cached), and looks somehow specific to cargo-zigbuild, since regular equivalent cargo calls work as expected. I can try investigating a bit more on my free time, but I really think the issue should stay open in the meantime
Sure, we can open it if you want to investigate.
Do note that I'll close it again if nothing comes up after a month or two.
I found the culprit:
Before invoking cargo build
, the target/[profile]/deps/
directory is being created, so when cargo is invoked, it skips the target directory creation (done here)
I don't exactly know how one would fix this, but I can confirm commenting the last two lines is enough to fix the issue
Thanks, see also https://github.com/rust-lang/cargo/issues/12441.
Cargo creates
CACHEDIR.TAG
files in some directories of thetarget/
folder, so that they are marked as excluded for backups. This is also used by theSwatinem/rust-cache
action to know if the directory should be kept for cache or notTurns out, for some reason with
*-apple-darwin
targets (at least),cargo-zigbuild
doesn't create such a file.Repo:
Create an empty bin crate:
It works as expected with
cargo build
on theaarch64-apple-darwin
target:It doesn't with
cargo zigbuild
on theaarch64-apple-darwin
target:But it works with some targets:
This is affecting me because it means macOS builds are not properly cached in my CI, with a combination of
cargo-zigbuild
andSwatinem/rust-cache
.Note that the host target seems irrelevant, I tried both from a Linux host and a macOS host, and it affects AFAIK the
aarch64-apple-darwin
and thex86_64-apple-darwin
targets