-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Support for pointers with asm_const #128464
Comments
I think this is at least blocked on #125558 right now (which is done but runs into an error message ordering difference between CI and local that we don't know how to fix). |
First of all, it doesn't make sense to pass a pointer as a Secondly, what you are actually proposing is a generalization of sym, where rather than only supporting |
I understand that |
Indeed. Note that in my real use-case |
Everywhere else in the language, we do support pointers as "constants", and our backends do the right thing. You can use pointers as initial values for |
That may indicate that
Which doesn't really make sense for relocatable constants. The whole point of It's really more of a |
So then what is the right name for something in inline asm that can evaluate to a relocation with offset? "sym" does not seem right either, since the offset makes it not a symbol.
What does this look like in C?
Would it be a problem to use "const" even when the result is a relocation? This shod not be too surprising since it is how "const" works everywhere else in Rust. For int-typed consts we would still guarantee that the result is bare assembly without linker involvement.
|
@rustbot label A-rust-for-linux |
Nominating this for lang to discuss the question of whether we should support use of @Amanieu, any input you'd like to provide would be helpful. |
After thinking about it a bit, I think it's probably fine to add this functionality to |
Inline assembly supports an unstable feature called asm_const with tracking issue #93332 that lets you pass constants to inline assembly. However, it only supports integer types. This issue is a feature request to support raw pointers with asm_const.
This would enable code such as the following:
Currently, the above code would require you to convert
my_asm_wrapper
into amacro_rules!
so that you can write out the path to the global using thesym
operand. Supporting this would be useful for the Rust for Linux project, as implementing support for static keys requires a long list of workarounds at the moment.cc @Amanieu @oli-obk
The text was updated successfully, but these errors were encountered: