As my first contribution to Linux I added support for showing readable Rust symbols in Linux's perf performance counter profiling tool. If you are doing performance-related work in Rust on Linux you want this patch.
And at the machine instruction level, inline with the source code:
Here are the steps for cloning and building perf with my patch. Note that the build requires about 500 MB of disk space.
git init perf-core
cd perf-core/
git remote add tip git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
git config core.sparsecheckout true
cat > .git/info/sparse-checkout << SPARSE
include/*
tools/arch/*
tools/build/*
tools/include/*
tools/lib/*
tools/perf/*
tools/scripts/*
SPARSE
git pull --depth=1 tip perf/core
cd tools/perf/
CC=gcc make
The make command will tell you which development headers you need to install. Just keep trying until you get it right. I had to install binutils-dev, libaudit-dev, libdw-dev, libelf-dev, libgtk2.0-dev, libiberty-dev, liblzma-dev, libnuma-dev, libperl-dev, libslang2-dev, libunwind8-dev. There may have been others that I already had installed.
We just recently tweaked the stdlib's demangler to add a couple more cases that it looks like the kernel patch missed: https://github.com/rust-lang/rust/pull/34753. Might be worth pushing upstream?
This is awesome, but I'm not thrilled about the de facto stabilization of our symbol mangling, which was mostly hacked in to prevent LLVM from complaining.
I'm not sure I like this... In principle, it's great that perf gets Rust support. But our current symbol mangling scheme is historically grown without much of a long-term plan behind it, afaik.
The patch as written will not do The Wrong Thing. In the worst case it will do nothing - showing you what you would have seen without the patch. I guess consider it a preview of how nice it will be when things are stabilized.
@dtolnay: Sorry for sounding a bit negative there. It really is great that we have support for the current encoding! Especially since it will still be around for a while.