Skip to content

fix coverage generation #3491

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TroyKomodo
Copy link

Stop rustc from emitted --codegen=instrument-coverage when the target does not have coverage enabled via --instrumentation_filter

Stop rustc from emitted `--codegen=instrument-coverage` when the target
does not have coverage enabled via `--instrumentation_filter`
@TroyKomodo
Copy link
Author

TroyKomodo commented Jul 3, 2025

I am not actually sure why the unit tests dont pass,

From looking at it

rustc \
	'test/unit/pipelined_compilation/bin.rs '--crate-name=bin' '--crate-type=bin' '--error-format=human' \
	'--out-dir=bazel-out/k8-fastbuild-ST-1c8a4433bbf5/bin/test/unit/pipelined_compilation' \
	'--codegen=opt-level=0' '--codegen=debuginfo=0' '--codegen=strip=none' '--remap-path-prefix=${pwd}=' \
	'--emit=link=bazel-out/k8-fastbuild-ST-1c8a4433bbf5/bin/test/unit/pipelined_compilation/bin' '--emit=dep-info'  \
	'--color=always' '--target=x86_64-unknown-linux-gnu'  \
	'-L rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib' '--edition=2021' '-Cembed-bitcode=no' \
	'--codegen=linker=/usr/bin/gcc' '--codegen=link-arg=--coverage' '--codegen=link-arg=-fuse-ld=gold' \
	'--codegen=link-arg=-B/usr/bin' '--codegen=link-arg=-Wl,-no-as-needed' '--codegen=link-arg=-Wl,-z,relro,-z,now'  \
	'--codegen=link-arg=-pass-exit-codes' '--codegen=link-arg=-Wl,--push-state,-as-needed' '--codegen=link-arg=-lstdc++' \
	'--codegen=link-arg=-Wl,--pop-state' '--codegen=link-arg=-Wl,--push-state,-as-needed' '--codegen=link-arg=-lm' \
	'--codegen=link-arg=-Wl,--pop-state' \
	'--extern=second=./bin/test/unit/pipelined_compilation/libsecond-416833743.rlib' \
	'-Ldependency=bazel-out/k8-fastbuild-ST-1c8a4433bbf5/bin/test/unit/pipelined_compilation' \
	'-Ldependency=bazel-out/k8-opt-exec-ST-742c84c296cd/bin/test/unit/pipelined_compilation' \
	'--codegen=instrument-coverage' \
	'--sysroot=./rust_toolchain' \
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error[E0463]: can't find crate for `second`
 --> test/unit/pipelined_compilation/bin.rs:1:5
  |
1 | use second::fun;
  |     ^^^^^^ can't find crate

error: aborting due to 1 previous error

Which doesn't make sense to me because we are clearly passing --extern=second=...

I also dont think my changes effect the dependency resolution graph so again I'm not sure why rustc is behaving this way, perhaps its showing an error for not finding the crate but the actual issue is it not finding the llvm library the crate needs for coverage?

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.

1 participant