Conversation
|
rustbot has assigned @petrochenkov. Use |
|
|
A few questions:
I think these all reduce to a desire to have the rustc docs either be self-contained or at least link to documentation for how a user might use this without needing to dig through LLVM. |
Yes, I think this is named after the BSD profiler function. Opening the door for a more generic option, I think we want to consider where similar derivatives fit in, like gcc/clang's As for naming, I think it is tied to the effective[1] ABI of the target for interoperability. The calling conventions are typically non-standard and handled by the codegen backend, but there are enough moving parts that it cannot be changed on a whim. As for documenting the above, arm is the only target which documents this interface. I could try to document the tier1 and some tier2 targets, and provide hints on how to determine this. [1] The ABI presumably introduced by gcc/gprof, defined officially (e.g arm's |
Stabilization report
Summary
Stabilize the boolean
-Zinstrument-mcountcommand line option into-Cinstrument-mcount.This option is similar to the gcc or clang
-pgoption to support instrumented profiling. This optioninserts a special function call into each function's prologue in the crate being compiler. The name of
the function is target specific. A user would then link a library which implements this function to
collect profiling data.
A common use is to compile a binary for instrumented profiling using gprof.
ldsupports a special option (also called-pg) to link the necessary runtime support forinstrumented profiling.
This option was introduced several years ago, and quietly broke for a period of time due to
refactoring within LLVM, but has since been fixed with an end-to-end test to verify (at least on
x86-64) functions are instrumented.
And all other contributors who have tested, reported, or fixed bugs since 2018.
cc @rust-lang/compiler
What is stabilized
The command line option
-Cinstrument-mcount. More generally, the ability to instrument function entry points in way compatible with other widely adopted toolchains (gcc, clang) for instrumenting function calls.What isn't stabilized
None.
Design
Reference
This feature annotates LLVM IR functions with
instrument-function-entry-inlined=target_mcount_namewheretarget_mcount_nameis target specific.RFC history
This option was likely considered too trivial for an RFC.
Answers to unresolved questions
None yet.
Post-RFC changes
None.
Key points
Nightly extensions
There is not part of this feature which will remain unstable.
Doors closed
This option has minimal impact on other options.
Feedback
Call for testing
No. This is a very narrowly scoped option. In the years since this was added there is now sufficient testing to verify the compiler feature
works end-to-end on major targets.
Nightly use
No. It was suggested this might be useful for Rust For Linux, but it is not yet used.
Implementation
Major parts
Coverage
Various PR's over the years have added support for target specific mcount function names which verify the correct function attributes are applied, and several tier 1 targets verify the mcount function is called after LLVM code generation.
Outstanding bugs
There are no outstanding bugs.
Outstanding FIXMEs
None.
Tool changes
This requires no tooling changes. Though, the utility of this option could be increased by addition cargo support to build instrumented binaries. That would required a stabilized means to build and instrumented
stdand apply appropriate linker flags. That discussion is out of this scope.Breaking changes
None.
History and Acknoledgments
The following contributors have implemented, tested, and stabilized this feature:
And any others I have failed to uncover in the long history of this option.
Open items