rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973) by azhogin · Pull Request #130777 · rust-lang/rust (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it work for the Rust calling convention? Is that what we want? I assume that there's a reason we use this flag, but I don't know whether it's just a question of performance or if it's an important mitigation.

@andyhhp Do you know if this matters?

Rust and C need to agree on how to return >GPR sized values, if this happens to be used in either direction.

Whether that is via some bindings using the Rust calling conventions is something I can't answer.

The use of >GPR sized return values is rare in C because it's irritating to set up. You need a struct/typedef with a fairly precise layout, but the code generation improvements are substantial, hence why they do get used occasionally.