-
Notifications
You must be signed in to change notification settings - Fork 13
Use stable #[naked] instead of global_asm!() fallback #169
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
base: main
Are you sure you want to change the base?
Conversation
src/naked.rs
Outdated
| #[cfg(feature = "nightly")] | ||
| /// Wrapper around `#[naked]` for defining naked functions. | ||
| /// This macro supports a limited subset of `#[naked]` features. | ||
| macro_rules! naked_fn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro can be inlined now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you're right. On it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine for my code now.
#[naked] is stable since Rust 1.79, and origin already requires 1.88. This removes the global_asm!() fallback and the naked_fn! macro entirely, inlining #[naked] directly at each call site.
a87bd39 to
ff706cd
Compare
bjorn3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good.
| __NR_rt_sigreturn = const __NR_rt_sigreturn | ||
| ); | ||
| #[unsafe(naked)] | ||
| #[unsafe(no_mangle)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually need to be no_mangle?
|
|
||
| #[unsafe(naked)] | ||
| #[unsafe(no_mangle)] | ||
| pub(super) unsafe extern "C" fn _start() -> ! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extern "custom" would make sense here, but that isn't stable yet and it is not worth it to keep the macro just for that IMHO.
Since
#[naked]is stable now (1.79) and origin already requires 1.88, we can drop theglobal_asm!()fallback entirely.This sidesteps the whole
@functionvs%functionplatform-specific syntax mess that #168 was trying to fix.Per @bjorn3's suggestion - this supersedes #168.