Implementation details?

Are the rust implementation details in any way documented outside of the source code? I’ve been trying to find information on calling conventions (ABI and whatnot) and I can’t find anything.

Also, is this the right part of the forum to be posting this?

Insofar as I’m aware, there is no defined ABI, and the ABI that exists is not guaranteed to be stable. It’s also not a target for 1.0.

That is, to be clear, excluding things like #[repr(C)].

Okay, thought I’d ask. Nobody seems to know implememtation details. Maybe I’m looking in the wrong places.

Rust’s ABI is undefined and unstable. The only place it is documented is in the compiler implementation, and in the heads of the people who work on it.

There is a lot of documentation in the compiler source code. For high level stuff, look for doc.rs in various directories, as well as big comments at the top of files.

Note that this may change anytime and might already have changed:

The function call ABI puts all structures bigger than a pointer behind a reference, same goes for RVO which triggers for everything bigger than a pointer. Struct layout currently is the same as C’s, for enums it’s a tagged union with an integer at the beginning that is big enough to cover all the variants (most of the time it’s a u8).

Are fat pointers (2 words: begin + size) or equivalent user defined structures passed this way too?

Unless there was a change here, yes.

I’m quite sure we use the System V ABI, which triggers RVO only for structs at least 2 pointers big.

No, we don’t, we have our own “larger than a pointer” rule, and sadly there’s a lot of trans code that assumes that threshold so you can’t just change it to see if you get a perf increase or something.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.