Closed trinity-1686a closed 2 years ago
Thanks for the report. The behaviour indeed reflects how Cargo runs external subcommands: Cargo doesn't call ProcessBuilder::inherit_jobserver()
for external subcommands^1, so file descriptors get close due to FD_CLOEXEC
flag (on Linux).
Not sure whether this issue is a bug or a feature. GNU Make says^2:
If your tool determines that the --jobserver-auth option is available in MAKEFLAGS but that the file descriptors specified are closed, this means that the calling make process did not think that your tool was a recursive make invocation (e.g., the command line was not prefixed with a + character). You should notify your users of this situation.
If I get it correctly, it's up to Cargo to determine whether the process should inherit the jobserver or not. It seems that cargo-fuzz
is a reasonable use case and personally I'd love to see it working.
Hi. We have discussed inheriting jobserver fd on Zulip. There might be some compatibility issues: It's rare but some commands might use fd 3 and 4 without notice of the existence of jobserver. As you said, there is a simple workaround. I'd recommend sticking with that.
I understand the compatibility concern.
You should notify your users of this situation.
Could cargo do that, so that at least other peoples stumbling on this bug/feature are made aware of the workaround? There are multiple external subcommands that actually call cargo internally (cargo-fuzz, cargo-tarpaulin...).
Also some such external subcommands do not support being called directly (I'm thinking about cargo-ndk). This is not my use case, but it could me someone else's.
Problem
I tried to use
cargo-fuzz
from a Makefile, expecting it to use make's jobserver to limit concurency. When running it ascargo-fuzz
, it worked as intended, but when running it ascargo fuzz
, it did not seem to acknowledge make job count. I foundcargo-fuzz
environment variables contained--jobserver-auth=3,4
as expected, but these file descriptors are closed.Steps
cargo-sleep
and put it into your $PATHsleep
. It containsMAKEFLAGS= -j2 --jobserver-auth=3,4
(actual number may vary)sleep
, 3 and 4 (in my case) are not open.Possible Solution(s)
No response
Notes
As stated there is a simple workaround, calling the sub-command directly instead of through cargo
Version