Amanieu / naked-function

Proc macro implementation of #[naked]
Apache License 2.0
29 stars 5 forks source link

request: support `instruction_set` attribute #1

Closed Lokathor closed 1 year ago

Lokathor commented 2 years ago

It might be "too early" to ask for this since that attribute isn't stable yet, but would it be possible to support the instruction_set attribute?

Related, I've had some issues with interworking code where using the rustc::naked attribute (that is, the nightly one in the compiler) fixed the fact that rust code was making non-interworking calls to t32 (written in rust) from a32 (written in a global asm file), causing crashes. Since this proc-macro lowers to a normal global_asm usage, I'm concerned that I could end up hitting those interworking issues again even if you do add instruction_set support

Amanieu commented 1 year ago

I had a try at implementing this, but I am hitting a significant issue: there's no reliable way to determine whether the current target uses T32 or A32 by default. This is important because global_asm! code must restore the default assembler mode at the end of a function. There is a thumb_mode target feature, but that is only available on nightly.

Lokathor commented 1 year ago

Awesome.

Is there a tracking issue for where thumb_mode could move to stabilization?

Amanieu commented 1 year ago

Not really, the ARM target features in general need cleaning up before they can be stabilized, like it was done for AArch64.

In this case I didn't check for the thumb_mode target feature and instead just checked whether the target name started with thumb in build.rs.