Pass -pg to linker when using -Zinstrument-mcount#152457
Pass -pg to linker when using -Zinstrument-mcount#152457rust-bors[bot] merged 3 commits intorust-lang:mainfrom
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
The change itself is correct, but perhaps it deserves a test?
|
|
Is this also correct for musl and other targets that use a gnu toolchain? |
|
Good question. |
That's maybe a detail about the glibc specific implementation which can be redacted? non-gnu targets seem to have a little more varied behavior.
musl, no. Linking should fail with unresolved |
78a8cde to
a4a5208
Compare
|
Just to double check we don't regress here. FreeBSD seems to support it: https://man.freebsd.org/cgi/man.cgi?query=moncontrol&sektion=3&apropos=0&manpath=freebsd Even mingw-w64 provides the necessary objects. |
I verified musl will fail to compile in the same way with and without |
|
ping |
|
@bors r+ |
Pass -pg to linker when using -Zinstrument-mcount This selects a slightly different crt on gnu targets which enables the profiler within glibc. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
…uwer Rollup of 8 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153641 (Move `Spanned`.) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups)
…uwer Rollup of 8 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153641 (Move `Spanned`.) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups)
…uwer Rollup of 8 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153641 (Move `Spanned`.) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups)
…uwer Rollup of 8 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153641 (Move `Spanned`.) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups)
Pass -pg to linker when using -Zinstrument-mcount This selects a slightly different crt on gnu targets which enables the profiler within glibc. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
…uwer Rollup of 13 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153471 (Refactor `ActiveJobGuard`) - #153595 (`QueryLatch` cleanups) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153479 (Add rationale for intentional potential_query_instability allows) - #153600 (add test for proc-macros with custom panic payloads) - #153641 (Move `Spanned`.) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups) - #153659 (Mark an unreachable match arm as such)
…uwer Rollup of 13 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153471 (Refactor `ActiveJobGuard`) - #153595 (`QueryLatch` cleanups) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153479 (Add rationale for intentional potential_query_instability allows) - #153600 (add test for proc-macros with custom panic payloads) - #153641 (Move `Spanned`.) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups) - #153659 (Mark an unreachable match arm as such)
Pass -pg to linker when using -Zinstrument-mcount This selects a slightly different crt on gnu targets which enables the profiler within glibc. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
|
It seems
|
|
Mingw-w64 provides the symbols it failed on in libgmon, so it should have worked. Some of the symbols that linker couldnt find: https://github.com/mingw-w64/mingw-w64/blob/59cd5ce805b12cdefced08ce567d3518c6053b40/mingw-w64-crt/profile/gmon.c#L88 (other symbols are in different files). This is then assembled to libgmon: https://github.com/mingw-w64/mingw-w64/blob/59cd5ce805b12cdefced08ce567d3518c6053b40/mingw-w64-crt/Makefile.am#L2049 |
Thanks for noting that. Investigating it, mingw expects the symbol to be named |
|
Yeah. The other one is missing So, I guess Rust should add |
f47f0f0 to
40eb8d1
Compare
Indeed, and that required readding a couple other libs too. I verified it links a simple gprof instrumented binary. |
| self.cc_arg("-pg"); | ||
| // On windows-gnu targets, libgmon also needs to be linked, and this | ||
| // requires readding libraries to satisfy its dependencies. | ||
| if self.sess.target.os == Os::Windows { |
There was a problem hiding this comment.
You can check self.sess.target.is_like_windows here instead.
Right, I often forget how annoying ld.bfd is.
Do you want to update |
mingw exposes the `_mcount` symbol for profiling.
libgmon needs to be linked. This also requires readding a few other system libraries to satisfy its dependencies.
I'll update the patch with both changes you've mentioned. Thanks. |
40eb8d1 to
87c2552
Compare
|
Ping. This issue found in the rollup should be fixed. |
|
@bors r+ |
Pass -pg to linker when using -Zinstrument-mcount This selects a slightly different crt on gnu targets which enables the profiler within glibc. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
Pass -pg to linker when using -Zinstrument-mcount This selects a slightly different crt on gnu targets which enables the profiler within glibc. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
Rollup of 7 pull requests Successful merges: - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #154031 (Remove divergence check from check_expr_array) - #154418 (move many tests out of `ui/unsafe`) - #153662 (Suggest fully qualified path on method name collision) - #153675 (simd_add/sub/mul/neg: document overflow behavior) - #154110 (Change "error finalizing incremental compilation" text and emit it as a note, not a warning) - #154430 (Create GPU target notification group)
Pass -pg to linker when using -Zinstrument-mcount This selects a slightly different crt on gnu targets which enables the profiler within glibc. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
Rollup of 7 pull requests Successful merges: - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #154031 (Remove divergence check from check_expr_array) - #154418 (move many tests out of `ui/unsafe`) - #154441 (bootstrap: force a CI LLVM stamp bump) - #153662 (Suggest fully qualified path on method name collision) - #153675 (simd_add/sub/mul/neg: document overflow behavior) - #154430 (Create GPU target notification group)
Rollup of 6 pull requests Successful merges: - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #154031 (Remove divergence check from check_expr_array) - #154418 (move many tests out of `ui/unsafe`) - #154441 (bootstrap: force a CI LLVM stamp bump) - #153675 (simd_add/sub/mul/neg: document overflow behavior) - #154430 (Create GPU target notification group)
View all comments
This selects a slightly different crt on gnu targets which enables the profiler within glibc.
This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed
-Clink-args=-pgto ensure the correct startup code is linked.