-
Notifications
You must be signed in to change notification settings - Fork 232
use #[naked]
for __rust_probestack
#897
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: master
Are you sure you want to change the base?
Conversation
fb31ab0
to
61be61f
Compare
f4d8cfa
to
d70607d
Compare
define_rust_probestack!( | ||
#[unsafe(naked)] | ||
#[no_mangle] | ||
pub unsafe extern "C" fn __rust_probestack() { |
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.
Could you mention in the doc comment that the custom ABI is the reason this is unsafe?
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.
Do you mean in the module doc comment? We can add some specific details (about what registers are used etc) if we add a doc comment to the function itself.
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 was referring to the comments above each of the functions, I guess they're not actually doc comments though they could be. Something like (hence the `unsafe`, since the ABI does not actually match `extern "C"`)
in the paragraph describing ABI is sufficient, unless you want to add more. Just to have a note that it isn't supposed to be extern "C"
.
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.
That reminded me of a few other cases we have where naked functions are extern "C"
but that doesn't really make sense. Seems like a somewhat common issue, I wrote up rust-lang/rust#140566 as a possible way to make this more clear (not for this pr of course).
…d_internal_symbol, r=bjorn3 allow `#[rustc_std_internal_symbol]` in combination with `#[naked]` The need for this came up in rust-lang/compiler-builtins#897, but in general this seems useful and valid to allow. Based on a quick scan, I don't think changes to the generated assembly are needed. cc `@bjorn3`
Thanks for putting this together, this is a nice bit of simplification. After the
Feel free to do any cleanup you see fit. Split NFC commits are great, GH's "ignore whitespace" option on the review UI works for everything else 🙂 |
4d09a30
to
a548e1f
Compare
Hmm, formatting does not really help much, because formatting in asm is undefined. So let's leave it as it is. I did merge the definition for |
There will need to be a change on the rustc side anyway when updating compiler-builtins. |
…d_internal_symbol, r=bjorn3 allow `#[rustc_std_internal_symbol]` in combination with `#[naked]` The need for this came up in rust-lang/compiler-builtins#897, but in general this seems useful and valid to allow. Based on a quick scan, I don't think changes to the generated assembly are needed. cc ``@bjorn3``
Well currently the bootstrap compiler rejects So yeah waiting for the new beta is probably easiest (not sure how rustweek impacts the schedule there, but we'll see) |
…d_internal_symbol, r=bjorn3 allow `#[rustc_std_internal_symbol]` in combination with `#[naked]` The need for this came up in rust-lang/compiler-builtins#897, but in general this seems useful and valid to allow. Based on a quick scan, I don't think changes to the generated assembly are needed. cc `@bjorn3`
Rollup merge of rust-lang#140552 - folkertdev:naked-function-rustc_std_internal_symbol, r=bjorn3 allow `#[rustc_std_internal_symbol]` in combination with `#[naked]` The need for this came up in rust-lang/compiler-builtins#897, but in general this seems useful and valid to allow. Based on a quick scan, I don't think changes to the generated assembly are needed. cc ``@bjorn3``
…l_symbol, r=bjorn3 allow `#[rustc_std_internal_symbol]` in combination with `#[naked]` The need for this came up in rust-lang/compiler-builtins#897, but in general this seems useful and valid to allow. Based on a quick scan, I don't think changes to the generated assembly are needed. cc ``@bjorn3``
460a2da
to
b1934ae
Compare
…l_symbol, r=bjorn3 allow `#[rustc_std_internal_symbol]` in combination with `#[naked]` The need for this came up in rust-lang/compiler-builtins#897, but in general this seems useful and valid to allow. Based on a quick scan, I don't think changes to the generated assembly are needed. cc ``@bjorn3``
b1934ae
to
f9a5ab4
Compare
f9a5ab4
to
66de876
Compare
The global->naked LGTM, with the optional nit that you can indent the text by two places so it's nested within the If so, I think we could leave those unmangled for now with a FIXME to change it once this repo becomes a subtree, to make things a bit easier (unfortunately never got a chance to do that this week). |
The indenting is nicer, yes (though rustfmt is still a bit wonkey sometimes). The PR allowing |
I think the attribute would be accepted, but from Bjorn's comment it sounds like rustc will need to be updated in order to start looking for the mangled symbols rather than unmangled. In which case, wouldn't unconditional mangling mean that when the standard library+builtins is built with the beta compiler it will emit calls to unmangled symbols, but we'll only be providing the mangled version? We could also provide a trampoline from unmangled to mangled symbols and provide both with a FIXME to remove after the next bootstrap bump, so we don't need to worry about |
Hmm, maybe? We might also be able to "fix" the mangling on the rustc side with Did you ever get using a git dependency for compiler-builtins in rustc to work? (I remember I tried but at least locally I never got it to work) |
That would need to be done on the compiler-builtins side, but then the next bootstrap bump would break until a new compiler-builtins version with the cfg(bootstrap) removed lands. |
Right, that's the issue we've been having. Bjorn mentioned earlier that using |
Providing both versions is probably the easiest way forward then, unless you're able to test a better way.
I do it occasionally but consistently forget exactly how. To the best of my knowledge, the below is about what is needed:
|
Forgot about this, #897 (comment) for my future reference. Let me just see if I can get this into a subtree within the next couple of days, which will at least avoid some of the possible back and forth. |
This should work now.
#[naked]
takes care of adding the directives thatdefine_rust_probestack
added.I deliberately did not format/indent the assembly code to make review easier. I could do that in a separate commit it that is desirable.
Let's see if CI is OK with this.