Skip to content

PGO cannot be used via cargo because of how RUSTFLAGS are handled. #7416

Closed
@michaelwoerister

Description

@michaelwoerister

Problem

PGO works in two phases:

  1. Compile an instrumented binary of your program that enables collecting profile data. This is done via RUSTFLAGS=-Cprofile-generate.
  2. Compile an optimized binary that makes use of the profile data collected in step (1). This is done via RUSTFLAGS=-Cprofile-use.

In order for this to work, the symbol names within the two program versions must match up because LLVM generates profiling data in terms of symbol names.

However, since #6503, RUSTFLAGS are fed into the -Cmetadata argument to rustc. This causes symbol names to differ because one version has -Cprofile-generate and the other has -Cprofile-use in their RUSTFLAGS.

I think I would prefer not feeding RUSTFLAGS into -C metadata at all. It does not seem right to me that symbol names are affected by random command line arguments to the compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions