Skip to content

Support generating unique profraw files by default when using -C instrument-coverage #100381

Closed
@ridwanabdillahi

Description

@ridwanabdillahi

Currently, when enabling the instrumentation of Rust crates using the -C instrument-coverage rustc flag, rustc does not set any default naming scheme for the generated *.profraw files. Today, a user has two options:

  1. Allow LLVM to set the default naming scheme which is default.profraw. Thie issue here is if there is more than one binary being executed that is linked to the instrumented library, LLVM would overwrite the coverage results from the previous executed binary.
  2. Manually set the LLVM_PROFILE_FILE environment variable and apply LLVMs special pattern strings to ensure unique files are generated.

LLVM also has API support for passing in the designated filename for instrumented profile files via rustc. This is leveraged today when enabling profile guided optimization or PGO. The Rust compiler directly sets a default naming scheme for the generated profraw file, default_%m.profraw.

Profile files generated by rustc's -C instrument-coverage should have the same or similar defaults to ensure coverage results are not overwritten by each test binary executed. A similar but more unique version of the default for PGO instrumented profile files should be used since multiple binaries are executed using the same instrumented library such as default_%m_%p.profraw.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions