Skip to content
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

Target-specific ABIs are allowed in compatible targets #65443

Closed
gnzlbg opened this issue Oct 15, 2019 · 5 comments
Closed

Target-specific ABIs are allowed in compatible targets #65443

gnzlbg opened this issue Oct 15, 2019 · 5 comments
Labels
A-FFI Area: Foreign function interface (FFI) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 15, 2019

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 } 

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.53s

cc @eddyb @rkruppe

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-FFI Area: Foreign function interface (FFI) labels Oct 15, 2019
@gnzlbg
Copy link
Contributor Author

gnzlbg commented 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
Copy link
Contributor

@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
Copy link
Contributor

Centril commented Oct 16, 2019

@jonas-schievink btw, if the current label set is insufficient, feel free to add new ones. :)

@nagisa
Copy link
Member

nagisa commented Oct 16, 2019

Similar to #57182.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 16, 2019

Closing as a duplicate. I will just post there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-FFI Area: Foreign function interface (FFI) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants