Stream: t-lang/wg-unsafe-code-guidelines

Topic: Where is info on the Rust calling convention?


simulacrum (Dec 24 2019 at 00:07, on Zulip):

I don't think we document this at all, but generally speaking, src/librustc_codegen_{ssa,llvm} and librustc_mir is probably where to look.

gnzlbg (Dec 28 2019 at 13:27, on Zulip):

You also want to look at librustc/.../layout.ty

gnzlbg (Dec 28 2019 at 13:27, on Zulip):

Since that's where the Layout and Abi's are tied together

gnzlbg (Dec 28 2019 at 13:28, on Zulip):

e.g. Abi::ScalarPair means that the Rust calling convention for scalar pairs is different than for other repr(rust) aggregates

Lokathor (Dec 28 2019 at 16:23, on Zulip):

Particularly I want to know how the stack works.

ARM eabi has an 8byte aligned stack, and the default LLVM data layout also has an 8 aligned stack, but I would like a 4 aligned stack on a particular embedded program where I know that I've compiled 100% of the code. And I want to know if I can just change the setting in LLVM and have Rust go with it.

bjorn3 (Dec 28 2019 at 16:26, on Zulip):

@Lokathor If LLVM keeps values 8 aligned when they are need it, then telling LLVM to align stacks to 4 should be fine. Rust doesn't manipulate the stack itself. Instead it uses alloca.

Lokathor (Dec 28 2019 at 16:26, on Zulip):

excellent!

Last update: Jan 21 2020 at 08:45UTC