tarpaulin icon indicating copy to clipboard operation
tarpaulin copied to clipboard

Linking with `cc` failed

Open Kaendor opened this issue 2 years ago • 4 comments

Hello everyone,

Description

We recently updated our rust stack to 1.59, everything compile just fine. But when we try to collect coverage using Tarpaulin, compilation errors are occurring.

We get the infamous "Error: build-script-build: linking with cc failed: exit status: 1".

Sometimes it fails to compile "log" from rust-lang, sometimes futures-rs or even futures-utils. The bug doesn't seems to target a precise crate but always happen. We use tarpaulin on CI and our local machines (all of them using linux x64).

To Reproduce The smallest thing I did to reproduce was having a Cargo.toml containing the following :


[package]
name = "minimal-repro"
version = "0.1.0"
edition = "2021"

[dependencies]
darling = "0.13.0"
quote = "1.0"
syn = "1.0"

[dev-dependencies]
tracing = { version = "0.1", features = ["attributes"] }

[lib]
proc-macro = true

I have only one file in /src which is lib.rs and is empty. I call tarpaulin with the following command : cargo tarpaulin --avoid-cfg-tarpaulin --skip-clean --frozen --ignore-tests -o Xml -o Lcov --workspace --all-features --verbose --line --debug

When we turn on debug and verbose on tarpaulin we get this kind of logs :

error: could not compile `log` due to 2 previous errors
Caused by:
  process didn't exit successfully: `CARGO=/home/dimitri/.rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/home/dimitri/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.14 CARGO_PKG_AUTHORS='The Rust Project Developers' CARGO_PKG_DESCRIPTION='A lightweight logging facade for Rust
  ' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=log CARGO_PKG_REPOSITORY='https://github.com/rust-lang/log' CARGO_PKG_VERSION=0.4.14 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=4 CARGO_PKG_VERSION_PATCH=14 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/home/dimitri/repository/c/target/debug/deps:/home/dimitri/.rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/lib:/home/dimitri/.rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/lib:/home/dimitri/.rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/lib' sccache rustc --crate-name build_script_build /home/dimitri/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.14/build.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="std"' -C metadata=63e856e52ee02c9e -C extra-filename=-63e856e52ee02c9e --out-dir /home/dimitri/repository/project1/target/debug/build/log-63e856e52ee02c9e -L dependency=/home/dimitri/repository/project1/target/debug/deps --cap-lints warn -Cdebuginfo=2 -Clink-dead-code -Clink-arg=-fuse-ld=lld` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
error: Broken pipe (os error 32)
error: build failed
Mar 18 15:05:55.289 ERROR cargo_tarpaulin: Failed to compile tests! Error: build-script-build: linking with `cc` failed: exit status: 1
Mar 18 15:05:55.289  INFO cargo_tarpaulin::event_log: Serializing tarpaulin debug log to tarpaulin-run-2022-03-18T15:05:55.289680580+01:00.json
Error: "Failed to compile tests! Error: build-script-build: linking with `cc` failed: exit status: 1"

Expected behavior Compilation and collection of coverage

Kaendor avatar Mar 18 '22 14:03 Kaendor

So I've just tried this on my own system with tarpaulin 0.20.0 and it ran fine on 1.59.0 running on this kernel/distro 5.4.0-104-generic #118~18.04.1-Ubuntu. Could you share some more info about what kernel/distro you're on, and anything else that might be pertinent like using musl instead of glibc

xd009642 avatar Mar 20 '22 18:03 xd009642

Hi, i'm using Manjaro 21.2.2, one colleague of mine is on Debian Bookworm and our CI is using a docker image rust:1.59.0-slim-bullseye. We are all using glibc for rust because we tried to use musl once and it was a pain to setup...

However, it seems removing :


[lib]
proc-macro = true

is fixing our issue.

Maybe it was a mistake on our end, because this crate wasn't exporting proc-macros but still tagged like it was.

Kaendor avatar Mar 21 '22 08:03 Kaendor

Hmm I know proc-macro crates only publicly export proc macros, so maybe it is just proc-macro things impacting it. I'll keep this open for a while as a reminder to investigate further though :thinking:

xd009642 avatar Mar 21 '22 08:03 xd009642

I met the same error without using proc-macro on Debian 5.4.56, arch a86_64

wre232114 avatar Apr 21 '22 02:04 wre232114