Skip to content
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

Don't build a broken/untested profiler runtime on mingw targets #122613

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Zalathar
Copy link
Contributor

Context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Why.20build.20a.20broken.2Funtested.20profiler.20runtime.20on.20mingw.3F

#75872 added --enable-profiler to the x86_64-mingw job (to cause some additional tests to run), but had to also add //@ ignore-windows-gnu to all of the tests that rely on the profiler runtime actually working, because it's broken on that target.

We can achieve a similar outcome by going through all the //@ needs-profiler-support tests that don't actually need to produce/run a binary, and making them use -Zno-profiler-runtime instead, so that they can run even in configurations that don't have the profiler runtime available. Then we can remove --enable-profiler from x86_64-mingw, and still get the same amount of testing.

This PR also removes --enable-profiler from the mingw dist builds, since it is broken/untested on that target. Those builds have had that flag for a very long time.

@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2024

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Mar 17, 2024
@Zalathar
Copy link
Contributor Author

@mati865 mentioned that this change might require some extra manual checking, to verify that the profiler runtime in the dist builds is sufficiently broken that we can happily remove it.

There's no rush, so it's fine for this PR to sit around for a while until it's convenient for that to happen.

@rust-log-analyzer

This comment has been minimized.

For PGO/coverage tests that don't need to build or run an actual artifact, we
can use `-Zno-profiler-runtime` to run the test even when the profiler runtime
is not available.
…time

The profiler runtime is no longer built in mingw test jobs, so these tests
should naturally be skipped by `//@ needs-profiler-support`.
@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2024

Some changes occurred in run-make tests.

cc @jieyouxu

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@nnethercote
Copy link
Contributor

Looks ok to me though I am not familiar with any of these stuff. @mati865, if you could review as well that would be appreciated :)

@mati865
Copy link
Contributor

mati865 commented Mar 24, 2024

Linked final binary with binutils:

$ cargo rustc -- -C instrument-coverage
    Updating crates.io index
  Downloaded whoami v1.2.1
  Downloaded 1 crate (11.0 KB) in 0.47s
   Compiling whoami v1.2.1
   Compiling hello v0.1.0 (D:\tmp\hello)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.39s

$ target/debug/hello.exe
bash: target/debug/hello.exe: cannot execute binary file: Exec format error`

LLD yields "less bad" result but since the library shipped by Rust is still miscompiled by GCC/Binutils the resulting profraw file is malformed (the binary itself works fine):

$ RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo llvm-cov
info: cargo-llvm-cov currently setting cfg(coverage) and cfg(coverage_nightly); you can opt-out it by passing --no-cfg-coverage and --no-cfg-coverage-nightly
   Compiling whoami v1.2.1
   Compiling hello v0.1.0 (D:\tmp\hello)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.58s
     Running unittests src\main.rs (target\llvm-cov-target\debug\deps\hello-637c13bc18a191d0.exe)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

warning: D:\tmp\hello\target\llvm-cov-target\hello-18720-12256372789117787786_0.profraw: malformed instrumentation profile data: function name is empty
error: no profile can be merged
error: failed to merge profile data: process didn't exit successfully: `'C:\Users\mateusz\.rustup\toolchains\nightly-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\bin\llvm-profdata.exe' merge -sparse -f 'D:\tmp\hello\target\llvm-cov-target\hello-profraw-list' -o 'D:\tmp\hello\target\llvm-cov-target\hello.profdata'` (exit code: 1)
Some offtopic

Also noticed gnullvm targets might have regressed at some point (or this quickly created setup is not quite right which is more probable) but it doesn't matter for this PR:

$ cargo new --lib test_lib

$ cd test_lib/

$ PATH=~/.cargo/bin:/h/msys64/clang64/bin:$PATH cargo +stage1_gnullvm llvm-cov
info: cargo-llvm-cov currently setting cfg(coverage) and cfg(coverage_nightly); you can opt-out it by passing --no-cfg-coverage and --no-cfg-coverage-nightly
   Compiling test_lib v0.1.0 (D:\tmp\test_lib)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.32s
     Running unittests src\lib.rs (target\llvm-cov-target\debug\deps\test_lib-3d83b996113588e9.exe)

running 1 test
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                               0                 0         -           0                 0         -           0                 0         -           0                 0         -

@bors
Copy link
Contributor

bors commented Mar 25, 2024

☔ The latest upstream changes (presumably #123029) made this pull request unmergeable. Please resolve the merge conflicts.

@nnethercote
Copy link
Contributor

I will be away for 3 weeks, but if/when this reaches a point where @mati865 is happy with it then you have my r+.

@mati865
Copy link
Contributor

mati865 commented Mar 25, 2024

Sorry if it's not obvious enough but I have confirmed the profiler library shipped with Rust is hopelessly broken for this target and there is no point in shipping it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants