Open FibreFoX opened 4 years ago
You need the Rust profiler runtime, I don't know if it's available for armv7-unknown-linux-gnueabihf, maybe you need to have a custom Rust build.
I imagine the same happens with source-based coverage, -Zinstrument-coverage
instead of -Zprofile
?
yes, it seems to be the same:
root@bd167ed00982:/rust-project# export CARGO_INCREMENTAL=0
root@bd167ed00982:/rust-project# export RUSTFLAGS="-Zinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
root@bd167ed00982:/rust-project# export RUSTDOCFLAGS="-Cpanic=abort"
root@bd167ed00982:/rust-project# cargo +nightly test --verbose
Updating git repository `https://github.com/rust-lang/compiler-builtins`
Updating git submodule `https://github.com/rust-lang/libm.git`
Compiling compiler_builtins v0.1.36 (https://github.com/rust-lang/compiler-builtins#c975b0e9)
Running `rustc --crate-name build_script_build /usr/local/cargo/git/checkouts/compiler-builtins-79341f926ffc30b3/c975b0e/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="default"' -C metadata=299181c756e471a1 -C extra-filename=-299181c756e471a1 --out-dir /rust-project/target/debug/build/compiler_builtins-299181c756e471a1 -L dependency=/rust-project/target/debug/deps --cap-lints allow -Zinstrument-coverage -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 `compiler_builtins`
Caused by:
process didn't exit successfully: `rustc --crate-name build_script_build /usr/local/cargo/git/checkouts/compiler-builtins-79341f926ffc30b3/c975b0e/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="default"' -C metadata=299181c756e471a1 -C extra-filename=-299181c756e471a1 --out-dir /rust-project/target/debug/build/compiler_builtins-299181c756e471a1 -L dependency=/rust-project/target/debug/deps --cap-lints allow -Zinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort` (exit code: 1)
@marco-c As I am new to Rust, can you point me to some instructions how to crete my own custom Rust build?
In the meantime I will check against current docker-images, to make sure this issue still exists.
Running in a freshly built docker-container:
root@edec570f38d4:/rust-project# rustup component add llvm-tools-preview
info: downloading component 'llvm-tools-preview'
info: installing component 'llvm-tools-preview'
info: using up to 500.0 MiB of RAM to unpack components
20.5 MiB / 20.5 MiB (100 %) 5.5 MiB/s in 3s ETA: 0s
root@edec570f38d4:/rust-project# export RUSTFLAGS="-Zinstrument-coverage"
root@edec570f38d4:/rust-project# cargo build
error: failed to run `rustc` to learn about target-specific information
Caused by:
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Zinstrument-coverage --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit code: 1)
--- stderr
error: the option `Z` is only accepted on the nightly compiler
root@edec570f38d4:/rust-project# cargo +nightly build
Updating git repository `https://github.com/rust-lang/compiler-builtins`
Updating git submodule `https://github.com/rust-lang/libm.git`
Compiling compiler_builtins v0.1.36 (https://github.com/rust-lang/compiler-builtins#c975b0e9)
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 `compiler_builtins`
To learn more, run the command again with --verbose.
root@edec570f38d4:/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@edec570f38d4:/rust-project# rustc +nightly --version --verbose
rustc 1.50.0-nightly (72da5a9d8 2020-11-26)
binary: rustc
commit-hash: 72da5a9d85a522b11e80d0fdd1fd95247d442604
commit-date: 2020-11-26
host: armv7-unknown-linux-gnueabihf
release: 1.50.0-nightly
root@edec570f38d4:/rust-project# export CARGO_INCREMENTAL=0
root@edec570f38d4:/rust-project# export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
root@edec570f38d4:/rust-project# export RUSTDOCFLAGS="-Cpanic=abort"
root@edec570f38d4:/rust-project# cargo +nightly test --verbose
Compiling compiler_builtins v0.1.36 (https://github.com/rust-lang/compiler-builtins#c975b0e9)
Running `rustc --crate-name build_script_build /usr/local/cargo/git/checkouts/compiler-builtins-79341f926ffc30b3/c975b0e/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="default"' -C metadata=299181c756e471a1 -C extra-filename=-299181c756e471a1 --out-dir /rust-project/target/debug/build/compiler_builtins-299181c756e471a1 -L dependency=/rust-project/target/debug/deps --cap-lints allow -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 `compiler_builtins`
Caused by:
process didn't exit successfully: `rustc --crate-name build_script_build /usr/local/cargo/git/checkouts/compiler-builtins-79341f926ffc30b3/c975b0e/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="default"' -C metadata=299181c756e471a1 -C extra-filename=-299181c756e471a1 --out-dir /rust-project/target/debug/build/compiler_builtins-299181c756e471a1 -L dependency=/rust-project/target/debug/deps --cap-lints allow -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort` (exit code: 1)
So all it comes down is that the docker-images for 32bit ARM do not contain these profiler_builtins
, maybe worth a note in the README ;)
It's likely a problem in the rust built itself where --enable-profiler
should be added (if it works on arm target).
@calixteman so nothing I can fix that fast on my end, and I did not use it wrong, right? Should I open a new issue on https://github.com/rust-lang/docker-rust then?
@marco-c As I am new to Rust, can you point me to some instructions how to crete my own custom Rust build?
You can find the instructions at https://github.com/rust-lang/rust
Yeah you can try to file an issue on docker-rust but not sure if it's useful since the docker image almost contain only a call to rustup
.
You can have a look on: https://github.com/rust-lang/rust/tree/master/src/ci/docker it may help.
There might be some progress here: https://github.com/rust-lang/rust/pull/124829
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 might found a bug that
cargo test
does not work as described in the instructions of grcov.It seems that I need more instructions to set up my system or that it is not possible to execute on my Raspberry Pi, so I need your assistance here.
Steps to reproduce
rust-project
containing a normal project (inited viacargo init
)Content of
main.rs
:fn get_message() -> &'static str { return "Hello, world!"; }
[cfg(test)]
mod tests { use super::get_message;
[test]
}
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
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
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 forprofiler_builtins
| = note: the compiler may have been built without the profiler runtimeerror: aborting due to previous error
For more information about this error, try
rustc --explain E0463
. error: could not compilerust-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@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@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
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