Closed
Description
For example, one can use the ptx-kernel
ABI on a x86_64 target. What the following does, I have absolutely no idea:
#![feature(abi_ptx)]
pub extern "ptx-kernel" fn foo(x: i32) -> i32 { x }
Errors:
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 0.53s
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
gnzlbg commentedon Oct 15, 2019
@jonas-schievink I'm not sure what the best label would be, but this isn't just an FFI issue, since one can call
extern "ptx-kernel"
functions defined in Rust from Rust. Basically,extern "ABI"
just lets you tell the Rust compiler which calling convention should it use for a function (well, kind of, because of implicit no-mangle in some contexts, but that's another story).I think that we do not check for any of the ABIs whether they make sense for the target, so it is very likely that there is a stable ABI that can be used in a stable target for which it doesn't make much sense.
For example, the win32 ABI "stdcall" can be used on stable Rust on x86_64-unknown-linux-gnu. . That does something, but I'm not sure what that something would be. If we provide no guarantees about what that does, then the behavior is undefined, and this would be a soundness bug since no unsafe Rust code is required to exhibit undefined behavior.
jonas-schievink commentedon Oct 15, 2019
@gnzlbg Yeah, specifying an ABI is most commonly used for FFI though, and that was the closest label we have, so I picked that. Feel free to change it to something else.
Centril commentedon Oct 16, 2019
@jonas-schievink btw, if the current label set is insufficient, feel free to add new ones. :)
nagisa commentedon Oct 16, 2019
Similar to #57182.
gnzlbg commentedon Oct 16, 2019
Closing as a duplicate. I will just post there.