No more source annotations in perf

(reddit sent me here)

For the past week(and more in the past) I've been using perf occasionally to optimize my advent of code solutions, and suddenly all the source lines annotations are gone.
As far as I can tell it disappeared right after I updated my system packages + ran rustup update.

Did anything happen recently to cause this? How can I bring it back? Ive tried installing an older rust version and it didn't help.

usually just perf record X perf report are enough but ive also tried with -g and --call-graph dwarf since those are often recommended.
I've tried both stable and nightly.
I've tested debug build, release build, and my custom profile:
[profile.flame]
inherits = "release"
panic = "abort"
codegen-units = 1
lto = true
debug = true

Which has always worked before.

A link to the repo: GitHub - CattoFace/aoc2024: My Rust solutions for advent of code 2024, blog posts can be found on https://barrcodes.dev/posts/aoc2024/

Edit: I am using perf version 6.12-2 and I have also tried version 6.12-1, might be relevant.

1 Like

If it disappeared after rustup, you can hypothetically get it back by installing an older toolchain, around the version that last worked.

For instance:

rustup toolchain install 1.78.0

cargo +1.78.0 build

You may have to do a manual bisection search to find the last version that produces the information you expect. If you find one, let us know in this thread. Maybe someone can help with knowledge of whether this was a regression from stable-to-stable.

As I have already said, I tried installing an older version again, the same version that worked before, 1.82.0, and it did not help.
Now I've also tried 1.81.0 and I'm getting the same result.

objdump is responsible for the disassembly and the matching source code in perf.
The one in the binutils package doesn't work for me either, not only for Rust, but for C++ binaries as well.
A workaround that worked for me is to use LLVM's objdump (llvm-objdump binary on my system).
You can configure it with perf config annotate.objdump=llvm-objdump. You may also want to use the same for addr2line though not sure if necessary.

2 Likes

llvm-objdump indeed does work!
I just spent half the day debugging this after being annoyed for a while. Very happy that just this week someone already answered it :slight_smile: