Skip to content

Code coverage does not work on armv7-unknown-linux-gnueabihf due to missing profiler_builtins #79640

Closed
@FibreFoX

Description

@FibreFoX

I am new to the Rust ecosystem, but as part of my own learning curve, I wanted to create a small personal project which includes test coverage executed on my raspberry pi server.

My setup contains a self-hosted Gitlab-instance (which runs inside docker) running on a 32-bit based Raspbian on my Raspberry Pi 4 (with 8gb RAM). After some hours of trying to get grcov working I tried to reproduce my problems, and found out, that profiler_builtins are missing for armv7-unknown-linux-gnueabihf.

I opened up an issue on the GRCOV-project (mozilla/grcov#508), because I first thought I was missing some important instruction to set up my system. It now seems to me that the package provided via rustup does not include the required crates/libs to make it work to have code coverage being analysed.

Steps to reproduce

  • install the docker engine + docker cli (locally on intel/amd-based system; and on a raspberry pi with 32bit operating system)
  • create a new project in a new folder rust-project containing a normal project (inited via cargo init)
root@9c75a90fc396:/# tree ./rust-project
./rust-project
|-- Cargo.lock
|-- Cargo.toml
`-- src
    `-- main.rs

Content of main.rs:

fn main() {
	println!("Message: {}", get_message());
}

fn get_message() -> &'static str {
	return "Hello, world!";
}

#[cfg(test)]
mod tests {
	use super::get_message;
	#[test]
	fn check_message() {
		assert_eq!(get_message(), "Hello, world!");
	}
}
  • create a Dockerfile aside of that folder:
# Dockerfile
FROM rust:latest

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y lcov
RUN rustup toolchain install nightly
RUN cargo install grcov

COPY ./rust-project /rust-project

WORKDIR /rust-project
  • create that container: docker build -t rust-grcov-raspberry-bug:latest .
  • run container: docker run --rm -ti rust-grcov-raspberry-bug:latest
  • execute the following inside the container:
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
cargo +nightly test --verbose

Result on Raspberry Pi 4 (32bit arm)

root@bfbc64ce82c2:/rust-project# cargo +nightly test --verbose
   Compiling rust-project v0.1.0 (/rust-project)
     Running `rustc --crate-name rust_project --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --test -C metadata=a223de0c0bfa7c21 -C extra-filename=-a223de0c0bfa7c21 --out-dir /rust-project/target/debug/deps -L dependency=/rust-project/target/debug/deps -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort`
error[E0463]: can't find crate for `profiler_builtins`
  |
  = note: the compiler may have been built without the profiler runtime

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `rust-project`

Caused by:
  process didn't exit successfully: `rustc --crate-name rust_project --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --test -C metadata=a223de0c0bfa7c21 -C extra-filename=-a223de0c0bfa7c21 --out-dir /rust-project/target/debug/deps -L dependency=/rust-project/target/debug/deps -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort` (exit code: 1)

root@deea46aaee17:/rust-project# rustc --version --verbose
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: armv7-unknown-linux-gnueabihf
release: 1.47.0
LLVM version: 11.0

root@a0589d6db0a9:/rust-project# rustc +nightly --version --verbose
rustc 1.49.0-nightly (b2d115f6d 2020-11-07)
binary: rustc
commit-hash: b2d115f6db5172c961dfeb50de15f35784dbc7c9
commit-date: 2020-11-07
host: armv7-unknown-linux-gnueabihf
release: 1.49.0-nightly

Result on local Windows 10 using docker-desktop (64bit amd64)

root@9c75a90fc396:/rust-project# cargo +nightly test --verbose
   Compiling rust-project v0.1.0 (/rust-project)
     Running `rustc --crate-name rust_project --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --test -C metadata=e2970e522a94ba3c -C extra-filename=-e2970e522a94ba3c --out-dir /rust-project/target/debug/deps -L dependency=/rust-project/target/debug/deps -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort`
    Finished test [unoptimized + debuginfo] target(s) in 0.44s
     Running `/rust-project/target/debug/deps/rust_project-e2970e522a94ba3c`

running 1 test
test tests::check_message ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

root@93adfcd192a9:/rust-project# rustc --version --verbose
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0

root@93adfcd192a9:/rust-project# rustc +nightly --version --verbose
rustc 1.49.0-nightly (b2d115f6d 2020-11-07)
binary: rustc
commit-hash: b2d115f6db5172c961dfeb50de15f35784dbc7c9
commit-date: 2020-11-07
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)O-ArmTarget: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions