Open
Conversation
Collaborator
|
rustbot has assigned @petrochenkov. Use |
Collaborator
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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