Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change -Z asm_comments to -Z verbose_asm, stop stripping handwritten assembly comments #762

Closed
1 of 3 tasks
tgross35 opened this issue Jun 21, 2024 · 4 comments
Closed
1 of 3 tasks
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@tgross35
Copy link

Proposal

-Z asm-comments currently controls two things: stripping all comments from assembly (PreserveAsmComments), and LLVM emitting its own verbose comments (AsmVerbose). By default this option is set to false, so even handwritten comments get stripped:

use core::arch::asm;

pub fn foo() {
    unsafe {
        asm!("nop # hello");
        asm!("nop // world");
    }
}

The output doesn't have the "hello" and "world" comments anywhere:

example::foo::h61551f5681388f69:
        push    rax
        #APP

        nop

        #NO_APP
        #APP

        nop

        #NO_APP
        pop     rax
        ret

Link: https://rust.godbolt.org/z/jxdEWY6oG

There doesn't seem to be a good reason to strip handwritten assembly comments ever (within the string), since a user can just write Rust comments if they don't want something to show up in the binary. So, proposal:

  1. Rename the configuration flag to -Z verbose-asm, which will be consistent with Clang/GCC
  2. Change that config option to only control LLVM-generated comments (AsmVerbose)
  3. Change PreserveAsmComments to be always true
  4. Start an actual tracking issue so -Z verbose-asm might wind up stabilized one day

The flag was originally added at rust-lang/rust#53290

See background discussion at https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Comments.20in.20.60asm!.60

Mentors or Reviewers

I can do the change

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@tgross35 tgross35 added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Jun 21, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2024

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:

@rustbot concern reason-for-concern 
<description of the concern> 

Concerns can be lifted with:

@rustbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Jun 21, 2024
@Amanieu
Copy link
Member

Amanieu commented Jun 21, 2024

Clang seems to preserve asm comments by default: https://github.com/llvm/llvm-project/blob/4232dd586b65c9301304cab2fb166d8df97c591a/clang/include/clang/Driver/Options.td#L3737-L3741

So there's no downside to just always doing this in rustc.

@nikic
Copy link
Contributor

nikic commented Jun 21, 2024

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Jun 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 2, 2024
Change `asm-comments` to `verbose-asm`, always emit user comments

Implements what is described in rust-lang/compiler-team#762

Tracking issue: rust-lang#126802
@apiraino
Copy link
Contributor

apiraino commented Jul 3, 2024

@rustbot label -final-comment-period +major-change-accepted

@apiraino apiraino closed this as completed Jul 3, 2024
@rustbot rustbot added major-change-accepted A major change proposal that was accepted and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Jul 3, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 3, 2024
Change `asm-comments` to `verbose-asm`, always emit user comments

Implements what is described in rust-lang/compiler-team#762

Tracking issue: rust-lang#126802
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 3, 2024
Rollup merge of rust-lang#126803 - tgross35:verbose-asm, r=Amanieu

Change `asm-comments` to `verbose-asm`, always emit user comments

Implements what is described in rust-lang/compiler-team#762

Tracking issue: rust-lang#126802
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

5 participants