Is a similar decorator or macros or something in rust like golang's //go:nosplit

Hi, I'm rewriting google's gvisor in rust and find one thing without proper parallel in rust, the go:nosplit annotation.

All I can find in the internet is like we can disable all stack check by adding rustc -C no-stack-check.

I'm still quite new to rust so it's quite possible that I missed some documentation. Do we have better alternative to provide more fine-grained control over behavior?

I have checked the option provided in rustc -W help, only two thing related to overflow I can find are arithmetic-overflow and overflowing-literals, which obviously is not what I need.

The //go:nosplit directive specifies that the next function declared in the file must not include a stack overflow check. This is most commonly used by low-level runtime sources invoked at times when it is unsafe for the calling goroutine to be preempted.

ref: The GNU Go Compiler: Compiler Directives

I don't think your question applies to Rust. Rust doesn't use split stacks, and doesn't do any stack overflow checks of its own, relying on the OS access checks. The -C no-redzone=yes seems closest to the "disable stack checks", but it has quite different implementation and use cases.


ok, let me further check with the rust and golang's behavior, the most worrying problem I can see is that " -C no-stack-check=val -- this option is deprecated and does nothing" lol

If you're doing something super low-level that even a stack probe is unwanted, then perhaps you need naked functions?

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.