Skip to content

Conversation

@vak-leon
Copy link

ARM GNU assembler uses %function instead of @function for the .type directive. The @function syntax causes build failures on arm-unknown-linux-gnueabihf:

error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '%<type>' or "<type>"
 --> <inline asm>:2:15
  |
2 | .type _start, @function
  |               ^

This adds an ARM-specific variant of the naked_fn! macro that uses the correct syntax.

Tested with cargo build --target arm-unknown-linux-gnueabihf.

ARM GNU assembler uses %function instead of @function for the .type
directive. This was causing build failures on arm-unknown-linux-gnueabihf.

/// `#[naked]` is nightly-only. We use it when we can, and fall back to
/// `global_asm` otherwise. This macro supports a limited subset of the
/// features of `#[naked]`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[naked] is now available on stable.

@vak-leon
Copy link
Author

Thanks for the pointer! Unfortunately the nightly feature forces the unwinding crate which conflicts with panic="abort" builds. The global_asm fallback path is still needed for minimal no_std binaries that don't want unwinding overhead.

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 12, 2026

I don't mean that you should enable the nightly feature. Rather I think you can change origin to use #[naked] rather than global_asm!() even the nightly feature is disabled.

@vak-leon
Copy link
Author

Ah, you're right - I was confusing the nightly feature with #[naked] itself. Makes sense that stable #[naked] would handle the platform-specific asm syntax internally, avoiding this whole %function vs @function mess.

Happy to look into refactoring naked_fn! to use #[naked] directly if that's the way to go. Want me to update this PR or open a fresh one?

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 12, 2026

A new PR probably makes sense.

@vak-leon
Copy link
Author

Closing in favor of #169 which takes the cleaner approach of using stable #[naked] directly.

@vak-leon vak-leon closed this Jan 12, 2026
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.

2 participants