Skip to content

Allow (but don't require) #[unsafe(naked)] so that compiler-builtins can upgrade to it#5

Closed
klintonc wants to merge 2 commits intomainfrom
pull/139797
Closed

Allow (but don't require) #[unsafe(naked)] so that compiler-builtins can upgrade to it#5
klintonc wants to merge 2 commits intomainfrom
pull/139797

Conversation

@klintonc
Copy link
Copy Markdown

@klintonc klintonc commented Apr 20, 2026

Reference Rust: https://rocket.rs/

tracking issue: rust-lang/rust#138997

Per rust-lang/rust#134213 (comment), we want to make the #[naked] attribute an unsafe attribute. Making that change runs into a cyclic dependency with compiler-builtins which uses #[naked], where rustc needs an updated compiler-builtins and vice versa.

So based on rust-lang/rust#139753 and #t-compiler/help > updating `compiler-builtins` and `rustc`, this PR allows, but does not require #[unsafe(naked)], and makes that change for some of the tests to check that both #[naked] and #[unsafe(naked)] are accepted.

Then we can upgrade and synchronize compiler-builtins, and then make #[naked] (without unsafe) invalid.

r? @traviscross (or someone from t-compiler if you're faster and this look allright)

@MonnetalX
Copy link
Copy Markdown

🔍 PR Link Analysis

🔗 Ranked Links

#1 rust-lang/rust#139753

🔍 The #[naked] attribute is now an unsafe attribute in any edition, creating a cyclic dependency where updating the compiler requires updating compiler-builtins and vice versa.

#2 rust-lang/rust#138997

🔍 The #[naked] attribute is being made unsafe to ensure naked functions with the Rust ABI remain unstable, as the Rust ABI details are not yet stable.

#3 rust-lang/rust#134213 (comment)

🔍 The #[unsafe(naked)] attribute prevents the compiler from emitting a function prologue or epilogue, analogous to C's __attribute__((naked)).

#4 #t-compiler/help > updating `compiler-builtins` and `rustc`

🔍 The #[unsafe(naked)] attribute is being introduced to allow compiler-builtins to upgrade without breaking the cyclic dependency with rustc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants