Skip to content

Add -Zinstrument-mcount={fentry-nop-record,fentry-record} - #160184

Open
pmur wants to merge 1 commit into
rust-lang:mainfrom
pmur:murp/add-mcount-opts
Open

Add -Zinstrument-mcount={fentry-nop-record,fentry-record}#160184
pmur wants to merge 1 commit into
rust-lang:mainfrom
pmur:murp/add-mcount-opts

Conversation

@pmur

@pmur pmur commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The linux kernel still uses fentry for x86 and s390x arches. s390x depends entirely on the compiler to record and nop these sections.

This facilitates support for inserting nop's and/or recording the location of each mcount call in a special section named __mcount_loc.

These attributes are currently only supported with fentry on the s390x target, otherwise they are quietly ignored (except on s390x).

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 29, 2026
@rustbot

rustbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

r? @mati865

rustbot has assigned @mati865.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 16 candidates

@pmur
pmur force-pushed the murp/add-mcount-opts branch from 6eff8aa to c8679c9 Compare July 29, 2026 22:28

@mati865 mati865 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +204 to +208
match opts.unstable_opts.instrument_mcount {
InstrumentMcount::Mcount(_) => {
fp.ratchet(FramePointer::Always);
}
_ => {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid turning it into match with this:

Suggested change
match opts.unstable_opts.instrument_mcount {
InstrumentMcount::Mcount(_) => {
fp.ratchet(FramePointer::Always);
}
_ => {}
if let InstrumentMcount::Mcount(_) = opts.unstable_opts.instrument_mcount {
fp.ratchet(FramePointer::Always);
}

Comment on lines -275 to -269
o => {
panic!("Unsupported or impossible mcount option {o:?}");
}
InstrumentMcount::Disabled => {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is helpful.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2026
@rustbot

rustbot commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

The linux kernel still uses fentry for x86 and s390x arches.
s390x depends entirely on the compiler to record and nop
these sections.

This facilitates support for inserting nop's and/or recording the
location of each mcount call in a special section named `__mcount_loc`.

These attributes are currently only supported with fentry on the s390x
target, otherwise they are quietly ignored (except on s390x).
@pmur
pmur force-pushed the murp/add-mcount-opts branch from c8679c9 to 3874adb Compare July 30, 2026 20:19
@pmur

pmur commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 3, 2026

@mati865 mati865 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the update has slipped under my radar.
@bors r+

View changes since this review

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3874adb has been approved by mati865

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 3, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
Add -Zinstrument-mcount={fentry-nop-record,fentry-record}

The linux kernel still uses fentry for x86 and s390x arches. s390x depends entirely on the compiler to record and nop these sections.

This facilitates support for inserting nop's and/or recording the location of each mcount call in a special section named `__mcount_loc`.

These attributes are currently only supported with fentry on the s390x target, otherwise they are quietly ignored (except on s390x).
rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160007 (allow `-Ldependency` search paths for panic runtimes)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160435 (bump tracing-tree)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
Add -Zinstrument-mcount={fentry-nop-record,fentry-record}

The linux kernel still uses fentry for x86 and s390x arches. s390x depends entirely on the compiler to record and nop these sections.

This facilitates support for inserting nop's and/or recording the location of each mcount call in a special section named `__mcount_loc`.

These attributes are currently only supported with fentry on the s390x target, otherwise they are quietly ignored (except on s390x).
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
…uwer

Rollup of 26 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #158727 (std: use `readdir` on nearly all UNIX platforms)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants