-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Disable the BorrowedFd
layout optimization on Haiku
#112371
Disable the BorrowedFd
layout optimization on Haiku
#112371
Conversation
On Haiku (and apparently only Haiku), the platform `AT_FDCWD` has the value `-1`. However, `BorrowedFd` currently has layout optimizations that assume the value is not `-1`, and it's useful to be able to store `AT_FDCWD` in a `BorrowedFd`. For example, rustix has [a function which returns a `BorrowedFd` containing `AT_FDCWD`]. To support this on Haiku, disable the layout optimizations for `BorrowedFd` on Haiku and allow it to store the value `-1`. This is technically a breaking change for Haiku users, as they could theoretically be depending on `Option<BorrowedFd>` having the same layout as `RawFd`, however this is not a common idiom, and Haiku support is [Tier 3] in Rust. [a function which returns a `BorrowedFd` containing `AT_FDCWD`]: https://docs.rs/rustix/latest/rustix/fs/fn.cwd.html [Tier 3]: https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-3
(rustbot has picked a reviewer for you, use r? to override) |
I don't think it's as simple as this. Whatever tier a target is, people are going to ask random crates for support for it, and those crates have to consider whether to support that target or not. And if there is any platform where I think we need to make this decision on a broader basis: what do we expect developers in the ecosystem to do?
What does Haiku use for "invalid file descriptor"? Are there any Haiku syscalls or library calls where you can pass an optional file descriptor, and there's a (hopefully consistent) placeholder value used to represent not providing a file descriptor? From what I can tell, Haiku syscalls seem to use large negative numbers as their error values: |
In most cases, this layout optimization is just an optimization, so it's not a major problem if some platforms get it and Haiku doesn't. The one place that does legitimately depend on the layout optimization is FFI declarations. Here,
Haiku's documentation just says it followed POSIX, so I assume It happens that the places in POSIX where a -1 fd can meaningfully be passed or returned are disjoint from the places were |
r? libs-api |
Haiku accepted a patch changing the |
As of the newly released Haiku R1/beta5, and the Rust libc crate version 0.2.155, the |
On Haiku (and apparently only Haiku), the platform
AT_FDCWD
has the value-1
. However,BorrowedFd
currently has layout optimizations that assume the value is not-1
, and it's useful to be able to storeAT_FDCWD
in aBorrowedFd
. For example, rustix hasa function which returns a
BorrowedFd
containingAT_FDCWD
.To support this on Haiku, disable the layout optimizations for
BorrowedFd
on Haiku and allow it to store the value-1
.This is technically a breaking change for Haiku users, as they could theoretically be depending on
Option<BorrowedFd>
having the same layout asRawFd
, however this is not a common idiom, and Haiku support is Tier 3 in Rust.