rust-lang/cargo

cargo test then cargo tarpaulin causes BorrowMut error and linking failure

Closed this issue · 4 comments

So when running cargo test with default rust flags and then running cargo tarpaulin (version 0.18.0-alpha1) cargo can output the following error (it's called within tarpaulin)

error: Broken pipe (os error 32)
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at 'already borrowed: BorrowMutError', src/tools/cargo/src/cargo/util/config/mod.rs:307:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Mar 01 19:28:55.644 ERROR cargo_tarpaulin: Failed to compile tests! Error: signals: linking with `cc` failed: exit code: 1
Error: "Failed to compile tests! Error: signals: linking with `cc` failed: exit code: 1"

To recreate the error given an example project (https://github.com/Smithay/calloop) we do the following:

cargo install cargo-tarpaulin --version 0.18.0-alpha1
git clone --depth 1 https://github.com/Smithay/calloop 
cd calloop
cargo test
cargo tarpaulin

One salient note cargo tarpaulin changes the rust flags to RUSTFLAGS=" -C link-dead-code -C debuginfo=2 --cfg=tarpaulin " so I wonder if this is a case of incremental compilation going wrong?

Further comment from the person who raised this with me in tarpaulin initially:

if we do the reverse (cargo clean, then cargo tarpaulin, then cargo test), then cargo test fails with a more detailed error. For example on calloop I get undefined reference to core::ptr::drop_in_place'`.

Oh also my cargo version is cargo 1.50.0 (f04e7fab7 2021-02-04)

I think this should be fixed in #9229

Awesome can't wait to try it out 👍