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

Use -Clink-dead-code #26

Merged
merged 1 commit into from Jun 9, 2021
Merged

Use -Clink-dead-code #26

merged 1 commit into from Jun 9, 2021

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Jun 9, 2021

NOTE: this PR has been reverted. see #26 (comment) for more.

Fixes #21

The unstable book says that unused functions are also instrumented, but it seems that -Clink-dead-code is also needed.

https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/instrument-coverage.html#-z-instrument-coverageoptions

-Z instrument-coverage=all: Instrument all functions, including unused functions and unused generics. (This is the same as -Z instrument-coverage, with no value.)

@taiki-e
Copy link
Owner Author

taiki-e commented Jun 9, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 9, 2021

Build succeeded:

@bors bors bot merged commit 94737b7 into main Jun 9, 2021
@bors bors bot deleted the link-dead-code branch June 9, 2021 18:34
@taiki-e
Copy link
Owner Author

taiki-e commented Jun 9, 2021

The unstable book says that unused functions are also instrumented, but it seems that -Clink-dead-code is also needed.

https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/instrument-coverage.html#-z-instrument-coverageoptions

-Z instrument-coverage=all: Instrument all functions, including unused functions and unused generics. (This is the same as -Z instrument-coverage, with no value.)

FYI @richkadel If this is not the intended behavior.

@richkadel
Copy link

I don't think -Clink-dead-code should have any impact.

In fact, that option is known to break the coverage workflow in some cases (particularly on MSVC/Windows builds).

Why, what makes you think it is operating differently without that option?

@richkadel
Copy link

Ah, I just reviewed your updated test. Correct me if I'm wrong. It looks like you are adding -Clink-dead-code in order to get coverage for an entire mod. Apparently, without it, coverage ignores the file or ignores the mod (I'm not sure which).

That should be filed as an issue against rust-lang/rust and maybe I can figure out how to get coverage to include unused mods / files without requiring the troublesome -Clink-dead-code.

I would advise against adding -Clink-dead-code for coverage, or make it opt-in with a warning to "use at your own risk".

Thoughts?

@taiki-e
Copy link
Owner Author

taiki-e commented Jun 9, 2021

Thanks for your advice! I opened rust-lang/rust#86177 to report this problem.

And for -Clink-dead-code, I'll revert this PR and mention the known workarounds and how they are likely to cause another problem.

bors bot added a commit that referenced this pull request Jun 9, 2021
28: Revert "Use -Clink-dead-code"  r=taiki-e a=taiki-e

This reverts commit 40fdbd8.

> Due to a bug of `-Zinstrument-coverage`, some files may be ignored. There is a known workaround for this issue, but note that the workaround is likely to cause another problem. See rust-lang/rust#86177 and #26 for more.

Co-authored-by: Taiki Endo <te316e89@gmail.com>
bors bot added a commit that referenced this pull request Jan 15, 2022
125: Update coverage output in test to nightly-2022-01-15 r=taiki-e a=taiki-e

rust-lang/rust#86177 (#21, #26) has been fixed 🎉 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

100% coverage is incorrectly reported
2 participants