-
Notifications
You must be signed in to change notification settings - Fork 13k
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
struct addrinfo needs padding on Solaris/SPARC #43649
Comments
It is fine to use any unstable features you need in the implementation of rustc and its standard libraries. Feel free to send in a PR and r? me. That being said the change against the structure itself will have to be PRd against https://github.com/rust-lang/libc first and only then the libstd itself changed. |
Something like this can be used too for the same effect:
|
Thanks, that's great! I'm not wild about having the padding member be public, but I don't see a way around that, so I submitted rust-lang/libc#714 for the libc part, and will follow up with a PR on this side shortly. |
I don't think it needs to be public - there are private fields in other structs in libc. |
There are, but (at least for the ones in the Solaris-specific module), none of those structs are ever initialized directly, AFAICT. At least, the compiler complained at me for it not being public. I can double-check, though. |
Indeed; if I remove
|
You can do |
struct addrinfo needs padding on Solaris/SPARC 64-bit Solaris/SPARC has a 4-byte pad before `ai_addrlen` for historical reasons (`ai_addrlen` used to be defined as a `size_t`, which is 4 bytes in ILP32 and 8 in LP64, but was converted to a 4-byte `socklen_t` in Solaris 10, which necessitated padding for (more or less) binary compatibility). See rust-lang/rust#43649.
addrinfo hint in lookup_host() clean initialization on all platforms Fixes #43649
On Solaris,
struct addrinfo
is defined like this:That padding member needs to be represented in Rust's copy. This is pretty straightforward, if a bit ugly. The following patch against the 1.19.0 sources fixes all the networking related test failures on SPARC:
Because this is against 1.19.0, so the
#[cfg]
directive isn't yet allowed inside the initializer, though presumably that could be used onmaster
, or beta withstruct_field_attributes
.But I'm struggling to find an idiomatic way to do this in such a way that it needn't be mentioned in
net.rs
at all, and just defaulted to0
insolaris/mod.rs
, as well as a way to make it non-pub
. I haven't yet tried it, but I assume I could use theDefault
trait. But that would still require me to add..Default::default()
to the initializer, and I would need to make the change to all thestruct addrinfo
definitions in libc.Is there a better way to fix this?
The text was updated successfully, but these errors were encountered: