Skip to content

ABI of ZST arguments? #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joshlf opened this issue Jun 12, 2025 · 3 comments
Closed

ABI of ZST arguments? #574

joshlf opened this issue Jun 12, 2025 · 3 comments

Comments

@joshlf
Copy link

joshlf commented Jun 12, 2025

Also posted to URLO.

Is it guaranteed that a ZST argument has no effect on a function's ABI? For example, are the following two functions guaranteed to have the same ABI?

extern "C" {
    fn foo(a: u8, b: u16);
    fn bar(a: u8, x: (), b: u16);
}

If this is in practice true but not yet guaranteed, would there be support for adding such a guarantee?

@RalfJung
Copy link
Member

RalfJung commented Jun 12, 2025

This is definitely not guaranteed at the moment.

And in fact, it's just not true for all ABIs at the moment. On windows-msvc, we pass ZST by-ptr for extern "C". We've done this since ~forever and the exact reasons are lost to time; I think that is just a bad work-around for rust-lang/rust#81996, and we should fix that issue instead. But we probably can't remove the ABI hack until we fixed the type layout.

Even once we fix that, there's a question of whether we truly can promise this for all future ABIs. Who knows what people come up with in the ABI space.

@RalfJung
Copy link
Member

Oh, and furthermore we probably don't want to make any more ABI compatibility guarantees anyway, we want people to use something like rust-lang/rust#140803 instead.

@joshlf
Copy link
Author

joshlf commented Jun 12, 2025

Okay thanks!

@joshlf joshlf closed this as completed Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants