Skip to content

#[naked] attribute excludes use of #[repr(align(N))] #129412

Closed
@erin-desu

Description

@erin-desu

I tried this code:

#[repr(align(4))]
#[naked]
extern "C" fn handle_trap_entry() -> !
{}

I expected to see this happen:
Code compiling just fine

Instead, this happened:

error[E0736]: attribute incompatible with `#[naked]`
  --> kernel/src/arch/riscv64/trap.rs:30:1
   |
30 | #[repr(align(4))]
   | ^^^^^^^^^^^^^^^^^ the `repr` attribute is incompatible with `#[naked]`
31 | #[naked]
   | -------- function marked with `#[naked]` here

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (a32d4a0e8 2024-08-21)
binary: rustc
commit-hash: a32d4a0e822a29a6682e08b75a8df4c29c7fa9f1
commit-date: 2024-08-21
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

It is a regression, as this was originally supported (last tried on):

rustc 1.81.0-nightly (6be96e386 2024-07-09)
binary: rustc
commit-hash: 6be96e3865c4e59028fd50396f7a46c3498ce91d
commit-date: 2024-07-09
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
Backtrace

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-nakedArea: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzSC-bugCategory: This is a bug.F-naked_functions`#![feature(naked_functions)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions