cargo-zigbuild
cargo-zigbuild copied to clipboard
macOS: `cargo-zigbuild` reports `ProcessFdQuotaExceeded` with zig 0.14.0+
When building relatively large projects such as probe-rs on macOS, there is a build failure with the error ProcessFdQuotaExceeded. This is due to the relatively low number of descriptors available by default on macOS, and the fact that zig now links all files in parallel. When combined with the fact that musl has one file per function the default number of 256 descriptors is quickly exceeded.
This is a problem when linking for both Windows and Linux.
Steps to Reproduce and Observed Behavior
- Install Rust --
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - Get probe-rs --
git clone https://github.com/probe-rs/probe-rs.git - Install cargo-zigbuild:
cargo install cargo-zigbuild - Install the Windows toolchain:
rustup target add x86_64-pc-windows-gnu - Attempt to build probe-rs:
rm -rf target; cargo zigbuild --target x86_64-pc-windows-gnu -p probe-rs-tools
With zig 0.14.0 or newer (including the latest nightly), this fails with an error:
= note: error: failed to open object /Users/seancross/Code/probe-rs/target/x86_64-pc-windows-gnu/debug/deps/probe_rs-6084bb00951e46ab.e5cjc0ec27acx9jogd9t0pslj.rcgu.o: ProcessFdQuotaExceeded
Note that the build fails with the same error for both Linux and Windows, but the Linux build requires some patches which is why I'm building the Windows version in this example.
Expected Behavior
The binary should build. If using zig 0.13.0, then the binaries build.
Workarounds
As a workaround, users should run ulimit -n 8192 when they open their shell. This number can only be changed once per process.
Alternately, perhaps we could have the builder attempt to change this, if possible?
This has been reported upstream and it's unclear whether it will be fixed, or if the answer isn't just to have the user increase their number of file descriptors.