Skip to content

PGO on Windows-GNU #49409

@leonardo-m

Description

@leonardo-m

I am trying to see if -Z pgo-gen is available on Windows-Gnu:

#48346

I am using:

rustc 1.26.0-nightly (188e693b3 2018-03-26)
binary: rustc
commit-hash: 188e693b392116c46f746e86f8521f9621fcfd43
commit-date: 2018-03-26
host: x86_64-pc-windows-gnu
release: 1.26.0-nightly
LLVM version: 6.0

I am using a very small Rust test program:

fn main() {
    println!("Hello");
}

If I compile with:

rustc -Z pgo-gen test.rs

It gives me:

error: debugging option `pgo-gen` requires a string (Z pgo-gen=<value>)

If I compile with (using a random string?):

rustc -Z pgo-gen=abc test.rs

It gives me:

error[E0463]: can't find crate for `profiler_builtins`

Activity

matthiaskrgr

matthiaskrgr commented on Mar 27, 2018

@matthiaskrgr
Member

Hi, I was also struggling with that! :)
The =val is supposed to be the profile file which details are written into after executing the pgo-gen instrumented binary and details are read from when building the binary for the second time with pgo-use.

So
RUSTFLAGS="-Z pgo-gen=profile_data.pgo" cargo build --release
*do things with the program*
RUSTFLAGS="-Z pgo-use=profile_data.pgo" cargo build --release
might work :)

leonardo-m

leonardo-m commented on Mar 27, 2018

@leonardo-m
Author

I've tried to do as you say, but perhaps I am doing something wrong. I've created a binary project with cargo (just the hello world), then I've set the variable:

set RUSTFLAGS="-Z pgo-gen=profile_data.pgo"

Then I've compiled:

cargo build --release

It gives me:

error: failed to run `rustc` to learn about target-specific information
Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names "-Z pgo-gen=profile_data.pgo" --target x86_64-pc-windows-gnu --crate-type bin --crate-typ
e rlib` (exit code: 101)
--- stderr
error: multiple input filenames provided
matthiaskrgr

matthiaskrgr commented on Mar 27, 2018

@matthiaskrgr
Member

Hm, I'm not sure what is going on there now (I also can't reproduce since not a windows user), sorry :/

added
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
O-windowsOperating system: Windows
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Mar 27, 2018
leonardo-m

leonardo-m commented on Apr 12, 2019

@leonardo-m
Author

Using:

rustc 1.35.0-nightly (3de010678 2019-04-11)
binary: rustc
commit-hash: 3de0106789468b211bcc3a25c09c0cf07119186
commit-date: 2019-04-11
host: x86_64-pc-windows-gnu
release: 1.35.0-nightly
LLVM version: 8.0

Calling rustc directly gives:

...>rustc -O -Z pgo-gen=profile_data.pgo test.rs
error[E0463]: can't find crate for `profiler_builtins`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
mati865

mati865 commented on Apr 12, 2019

@mati865
Member
added
O-windows-gnuToolchain: GNU, Operating system: Windows
and removed
O-windowsOperating system: Windows
on Apr 15, 2019
michaelwoerister

michaelwoerister commented on May 14, 2019

@michaelwoerister
Member

I wonder if we could just enable the profiler on *-pc-windows-gnu.

mati865

mati865 commented on May 14, 2019

@mati865
Member

I think I can find time this week to test it.
I'm almost sure PGO was broken on some older GCC version but I cannot recall the details.

mati865

mati865 commented on May 19, 2019

@mati865
Member

Status update:
I've got it working few days ago but pushing this upstream is blocked on upgrading compiler-builtins to 0.1.15. It was meant to be done by #60841 but was backed off.

added 5 commits that reference this issue on May 25, 2019
c907f03
e6eaff6
1625abf
3674ed8
94b29f3
added a commit that references this issue on May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.O-windows-gnuToolchain: GNU, Operating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @sanxiyn@matthiaskrgr@mati865@michaelwoerister@pietroalbini

      Issue actions

        PGO on Windows-GNU · Issue #49409 · rust-lang/rust