Build Scripts should check command exit code in addition to invocation success
Describe the bug
As far as I could tell from a quick search most Command invocations in build.rs files only use a single unwrap on the result of the status(). However, the first unwrap only covers a failure to invoke the command, not whether it completed successfully.
Mara Bos has confirmed this in this comment.
To Reproduce Steps to reproduce the behavior:
- Don't install a required dependency to build qemu
- Run
cargo build --no-default-features -p libafl_qemu - Observe that the first error reported by the build script is
Failed to read linkinfo.jsonas that is the "observable" error condition from the perspective of the build script.
Expected behavior
I would expect the error to be accurately attributed to the failing command.
Additional context
There are a couple of different ways this is handled in other buildscripts
https://github.com/AFLplusplus/LibAFL/blob/374f8735fa96c13ca2f74d0ead7fb40615504bed/libafl_libfuzzer/build.rs#L79-L82
https://github.com/AFLplusplus/LibAFL/blob/374f8735fa96c13ca2f74d0ead7fb40615504bed/libafl_nyx/build.rs#L10-L14
But there are also a lot of unhandled cases elsewhere like https://github.com/AFLplusplus/LibAFL/blob/374f8735fa96c13ca2f74d0ead7fb40615504bed/fuzzers/backtrace_baby_fuzzers/forkserver_executor/build.rs#L26-L30
https://github.com/AFLplusplus/LibAFL/blob/374f8735fa96c13ca2f74d0ead7fb40615504bed/libafl_frida/build.rs#L31-L33