Skip to content

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

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
Esper89 opened this issue Apr 18, 2025 · 1 comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. O-windows-gnu Toolchain: GNU, Operating system: Windows

Comments

@Esper89
Copy link

Esper89 commented Apr 18, 2025

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
@Esper89 Esper89 added the C-bug Category: This is a bug. label Apr 18, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 18, 2025
@jieyouxu jieyouxu added A-cross Area: Cross compilation O-windows-gnu Toolchain: GNU, Operating system: Windows labels Apr 19, 2025
@mati865
Copy link
Contributor

mati865 commented Apr 19, 2025

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

This is why it's not enabled. It works only when built with Clang, I don't remember if linking with ld.bfd works or if LLD is also required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. O-windows-gnu Toolchain: GNU, Operating system: Windows
Projects
None yet
Development

No branches or pull requests

4 participants