Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running on Windows is broken because of symlink usage #462

Closed
EFanZh opened this issue Jun 27, 2020 · 7 comments · Fixed by #720
Closed

Running on Windows is broken because of symlink usage #462

EFanZh opened this issue Jun 27, 2020 · 7 comments · Fixed by #720
Labels

Comments

@EFanZh
Copy link
Contributor

EFanZh commented Jun 27, 2020

To reproduce, run the following code with cmd:

set CARGO_INCREMENTAL=0
set RUSTFLAGS=-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
set RUSTDOCFLAGS=-Cpanic=abort

cargo +nightly new test-coverage --lib
cd test-coverage
cargo +nightly test

cargo +nightly install grcov
grcov ./target/debug/ -s . -t html --llvm --branch --ignore-not-existing -o ./target/debug/coverage/

start target/debug/coverage/src/lib.rs.html

There is no coverage on the report. Also, I have noticed that if I use nightly-gnu instead of nightly, the result is correct. Maybe the -Zprofile is not supported for msvc target?

System informantion:

  • Compiler: rustc 1.46.0-nightly (50fc24d8a 2020-06-25)
  • OS: Windows 10 version 2004 (OS Build 19041.329)
bors bot added a commit to intellij-rust/intellij-rust that referenced this issue Jul 6, 2020
5441: RUN: Fix environment variables for Coverage runner r=Undin a=mchernyavsky

Fixes `Run with Coverage` on the latest versions of the plugin.

Also adds tests for the Coverage runner.

NB: For now, `cargo test` with coverage doesn't work on Windows if MSVC toolchain is used (mozilla/grcov#462)

Co-authored-by: mchernyavsky <[email protected]>
@howardmoore
Copy link

I've seen the same issue. I initially wondered if it was due to the use of --llvm, as I was linking with the MSVC linker, but removing that flag resulted in grcov reporting errors. Eventually I found that removing the -Cpanic=abort rustflag solved the problem. I also found I had to turn off control flow guard or my instrumented application crashed with a stack buffer overflow.

@marco-c
Copy link
Collaborator

marco-c commented Jan 21, 2021

I'll try to get to this as soon as I get my hands on a Windows machine.

@lolo32
Copy link

lolo32 commented Feb 12, 2021

I've got another error on my Windows 10.

Without Administrator rights, it ends with:

18:53:08 [ERROR] A panic occurred at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\grcov-0.7.1\src\producer.rs:297: Failed to create a symlink "D:\\Projets\\rust\\test_cover\\.\\your_name-8644-12395990519104456799_0.profraw" -> "C:\\Users\\User\\AppData\\Local\\Temp\\.tmpxic1nO\\your_name-8644-12395990519104456799_0_1.profraw"

If running with admin rights because grcov want to do symlinks:

set LLVM_PROFILE_FILE=your_name-%p-%m.profraw
set RUSTFLAGS=-Zinstrument-coverage
cargo +nightly build
cargo +nightly test
grcov . --source-dir . --llvm --binary-path .\target\debug\ --branch --ignore-not-existing --ignore "/*" --output-type html --output-path .\target\debug\coverage
19:04:29 [ERROR] Error while executing llvm tools: Failed to execute "C:\\Users\\User\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\bin\\llvm-profdata.exe" "merge" "-sparse" "C:\\Users\\User\\AppData\\Local\\Temp\\.tmpVTufXj\\your_name-8644-12395990519104456799_0_1.profraw" "C:\\Users\\User\\AppData\\Local\\Temp\\.tmpVTufXj\\default_1.profraw" "-o" "C:\\Users\\User\\AppData\\Local\\Temp\\.tmpVTufXj\\1\\grcov.profdata"
Le fichier spécifié est introuvable. (os error 2)

Sorry, the error message is in french like my interface. It says that grcov cannot find a file.

Versions informations:

  • rustup 1.23.1 (3df2264a9 2020-11-30)
  • cargo 1.51.0-nightly (ab64d1393 2021-02-10)
  • rustc 1.52.0-nightly (07194ffcd 2021-02-10)
  • grcov 0.7.1

@lolo32
Copy link

lolo32 commented Feb 12, 2021

Sorry, i'm replying to my previous report, I forget to install llvm-tools-preview.

rustup component add llvm-tools-preview

Solved my previous problem, but I got another erro with the same command as the previous one:

19:58:28 [ERROR] Execution count overflow detected.

@marco-c
Copy link
Collaborator

marco-c commented Apr 19, 2021

@lolo32 does the report look OK? That error can be ignored in most cases.

@marco-c marco-c changed the title No coverage on Windows Do not use symlinks on Windows, or document that Admin rights are needed Apr 19, 2021
@marco-c marco-c changed the title Do not use symlinks on Windows, or document that Admin rights are needed Running on Windows is broken because of symlink usage Apr 19, 2021
@DanielJoyce

This comment has been minimized.

@marco-c marco-c linked a pull request Nov 25, 2021 that will close this issue
@marco-c
Copy link
Collaborator

marco-c commented Nov 25, 2021

#720 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants