Skip to content

Target-specific ABIs are allowed in compatible targets #65443

Closed
@gnzlbg

Description

@gnzlbg
Contributor

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

Activity

added
C-bugCategory: This is a bug.
requires-nightlyThis issue requires a nightly compiler in some way.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-FFIArea: Foreign function interface (FFI)
on Oct 15, 2019
gnzlbg

gnzlbg commented on Oct 15, 2019

@gnzlbg
ContributorAuthor

@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

jonas-schievink commented on Oct 15, 2019

@jonas-schievink
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

Centril commented on Oct 16, 2019

@Centril
Contributor

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

nagisa

nagisa commented on Oct 16, 2019

@nagisa
Member

Similar to #57182.

gnzlbg

gnzlbg commented on Oct 16, 2019

@gnzlbg
ContributorAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nagisa@Centril@gnzlbg@jonas-schievink

        Issue actions

          Target-specific ABIs are allowed in compatible targets · Issue #65443 · rust-lang/rust