Skip to content

Use rustc_target for function call ABI compatibility check #402

Closed
@RalfJung

Description

@RalfJung

@eddyb suggests to use something in https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/abi/call/index.html instead of https://github.com/rust-lang/rust/blob/c610be92e2925ab8e789efc835c88247e46c6cbf/src/librustc_mir/interpret/terminator/mod.rs#L191.

IRC log:

<eddyb> RalfJ: yeah you can basically emulate ABIs!
<eddyb> RalfJ: the PassMode variant must always match. direct (including pairs) must have the same layout primitive, cast must use the same register "shape", and indirect has no requirements
<eddyb> RalfJ: for direct I doubt you can have anything other than scalars, scalar pairs and vectors, and for at least the first two you can just reuse the miri value and change the type
<eddyb> RalfJ: for cast & indirect, you basically need to do a memcpy/union type-cast
<eddyb> if you want you can check that the size matches *but that's not actually required* (in terms of things working, that is)
<eddyb> RalfJ: especially if we'll get virtual calls with by-value self, it's gonna be indirect on both sides but one of the sides might only know the zero-sized unsized `dyn Trait` type, whereas the other has the full type
<eddyb> RalfJ: now this is still somewhat imprecise

Unfortunately I have no idea yet what all of that means. ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions