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

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

Closed
erin-desu opened this issue Aug 22, 2024 · 4 comments · Fixed by #129421
Closed

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

erin-desu opened this issue Aug 22, 2024 · 4 comments · Fixed by #129421
Labels
A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@erin-desu
Copy link

erin-desu commented Aug 22, 2024

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

@erin-desu erin-desu added the C-bug Category: This is a bug. label Aug 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 22, 2024
@workingjubilee
Copy link
Member

huh, wild. did it actually have the desired codegen properties?

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Aug 22, 2024

this combines two unstable features, repr on functions (#82232) and naked functions (#90957), but the fix should be easy by adding it to this allowlist. It seems an artificial limitation, with the allowlist not including repr since that's not a well known attribute on functions. it looks like it should work

@jdonszelmann
Copy link
Contributor

(I just wrote a test for it, if it works I'll make a PR if that's okay)

@folkertdev
Copy link
Contributor

some context: #127853 introduced the allowlist, and this attribute was left out because we were unsure if it would come up. Clearly it has, so this seems fine to allow.

@bors bors closed this as completed in 99453ce Aug 28, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 28, 2024
Rollup merge of rust-lang#129421 - jdonszelmann:naked-repr-align-functions, r=workingjubilee,compiler-errors

add repr to the allowlist for naked functions

Fixes rust-lang#129412 (combining unstable features rust-lang#90957 (`#![feature(naked_functions)]`) and rust-lang#82232 (`#![feature(fn_align)]`)
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS F-naked_functions `#![feature(naked_functions)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants