rust-lang / rust-lang/rust

Unable to use `profile-generate` when cross-compiling for `x86_64-pc-windows-gnu` on Linux.

Open
#140,013 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-cross C-bug O-windows-gnu T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

When using either of the x86_64-unknown-linux-gnu toolchains (from rustup) with the x86_64-pc-windows-gnu target added, cross-compiling for x86_64-pc-windows-gnu with profile-generate enabled fails:

$ rustc --target x86_64-pc-windows-gnu -C profile-generate=pgo main.rs
error[E0463]: can't find crate for `profiler_builtins`
  |
  = note: the compiler may have been built without the profiler runtime

If the compiler used is built with the following in bootstrap.toml:

[build]
profiler = true
target = ["x86_64-pc-windows-gnu"]

Then the build succeeds, but (after running the instrumented binary in wine) the generated profile data is malformed, and attempting to merge it with llvm-profdata fails:

$ llvm-profdata merge -o pgo/merged.profdata pgo
warning: pgo/default_13971159156524030339_0.profraw: malformed instrumentation profile data: symbol name is empty
error: no profile can be merged

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the x86_64-unknown-linux-gnu toolchain, the x86_64-pc-windows-gnu target, and -C profile-generate=pgo; compare this with a compiler built using profiler = true and that target in bootstrap.toml. Run the instrumented binary under Wine and llvm-profdata merge; done means cross-compilation succeeds and the resulting profile data merges without malformed-profile errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.