Skip to content

Unstably add -Cpanic=immediate-abort #909

@saethlin

Description

@saethlin

Draft implementation: rust-lang/rust#146317

Proposal

We currently have a standard library feature called panic_immediate_abort. The goal of this feature is to minimize code size, and it does so by replacing the entire panic runtime with intrinsics::abort(). For example, on x86 this aborts with just the ud2 instruction, not a call to libc::abort(). In addition, panic hooks are not called which means that panic messages and backtraces are not printed. Finally, the feature adjusts some inlining attributes on panic wrappers in the standard library so that they completely optimize away.

-Zbuild-std-features=panic_immediate_abort is really a new panic strategy, kludged in as a standard library feature. I'm proposing that we elevate it to an actual panic option, so that it integrates better with the toolchain. This will let users set the option in the normal way that panics are customized, and let us customize diagnostics about it.

It also opens up opportunities to teach codegen about the panic mode, instead of managing an ever-growing amount of cfg_attr( in the standard library source.

And if eventually libraries want to customize their behavior to facilitate the code size optimizations that the option opens up, they could use cfg(panic = "immediate_abort") like the standard library.

Mentors or Reviewers

None

Process

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

  • File an issue describing the proposal.
  • A compiler team member who is knowledgeable in the area can second by writing @rustbot second or kickoff a team FCP with @rfcbot fcp $RESOLUTION.
  • Once an MCP is seconded, the Final Comment Period begins.
    • Final Comment Period lasts for 10 days after all outstanding concerns are solved.
    • Outstanding concerns will block the Final Comment Period from finishing. Once all concerns are resolved, the 10 day countdown is restarted.
    • If no concerns are raised after 10 days since the resolution of the last outstanding concern, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was accepted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions