-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
std: Deprecate all std::os::*::raw types #31551
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
b2a2534
to
a97bc1e
Compare
Yay! Although the limit was actually 2GB, since This highlights to me that you've made the "universal" |
a97bc1e
to
9de5ff3
Compare
@cuviper oh wow, even better than I thought! The change for fn foo(amt: off_t) { ... }
foo(metadata.size()); would break otherwise. We in theory want to return Does that makes sense? I tried to word the deprecation message to indicate "these type definitions are known to not be correct" to ensure that this was conveyed. |
Right, your explanation is basically what I suspected. Makes sense. My only concern would be if someone also tried to use negative |
I think it would have, yeah. I found only a very few locations that use |
OK. The easy fallback in this case is just |
@bors r+ |
📌 Commit 9de5ff3 has been approved by |
⌛ Testing commit 9de5ff3 with merge d8c3443... |
💔 Test failed - auto-linux-32-opt |
9de5ff3
to
3a35cbb
Compare
@bors: r=brson 3a35cbb |
⌛ Testing commit 3a35cbb with merge 4906b4c... |
💔 Test failed - auto-mac-64-opt |
3a35cbb
to
2991b04
Compare
@bors: r=brson 2991b04 |
⌛ Testing commit 2991b04 with merge 564ac80... |
💔 Test failed - auto-linux-64-x-android-t |
2991b04
to
ede1e29
Compare
@bors: r=brson ede1e29 |
⌛ Testing commit ede1e29 with merge 2905cd9... |
💔 Test failed - auto-mac-ios-opt |
This commit is an implementation of [RFC 1415][rfc] which deprecates all types in the `std::os::*::raw` modules. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1415-trim-std-os.md Many of the types in these modules don't actually have a canonical platform representation, for example the definition of `stat` on 32-bit Linux will change depending on whether C code is compiled with LFS support or not. Unfortunately the current types in `std::os::*::raw` are billed as "compatible with C", which in light of this means it isn't really possible. To make matters worse, platforms like Android sometimes define these types as *smaller* than the way they're actually represented in the `stat` structure itself. This means that when methods like `DirEntry::ino` are called on Android the result may be truncated as we're tied to returning a `ino_t` type, not the underlying type. The commit here incorporates two backwards-compatible components: * Deprecate all `raw` types that aren't in `std::os::raw` * Expand the `std::os::*::fs::MetadataExt` trait on all platforms for method accessors of all fields. The fields now returned widened types which are the same across platforms (consistency across platforms is not required, however, it's just convenient). and two also backwards-incompatible components: * Change the definition of all `std::os::*::raw` type aliases to correspond to the newly widened types that are being returned on each platform. * Change the definition of `std::os::*::raw::stat` on Linux to match the LFS definitions rather than the standard ones. The breaking changes here will specifically break code that assumes that `libc` and `std` agree on the definition of `std::os::*::raw` types, or that the `std` types are faithful representations of the types in C. An [audit] has been performed of crates.io to determine the fallout which was determined two be minimal, with the two found cases of breakage having been fixed now. [audit]: rust-lang/rfcs#1415 (comment) --- Ok, so after all that, we're finally able to support LFS on Linux! This commit then simultaneously starts using `stat64` and friends on Linux to ensure that we can open >4GB files on 32-bit Linux. Yay! Closes rust-lang#28978 Closes rust-lang#30050 Closes rust-lang#31549
ede1e29
to
aa23c98
Compare
⌛ Testing commit aa23c98 with merge 7589f86... |
⛄ The build was interrupted to prioritize another pull request. |
This commit is an implementation of [RFC 1415][rfc] which deprecates all types in the `std::os::*::raw` modules. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1415-trim-std-os.md Many of the types in these modules don't actually have a canonical platform representation, for example the definition of `stat` on 32-bit Linux will change depending on whether C code is compiled with LFS support or not. Unfortunately the current types in `std::os::*::raw` are billed as "compatible with C", which in light of this means it isn't really possible. To make matters worse, platforms like Android sometimes define these types as *smaller* than the way they're actually represented in the `stat` structure itself. This means that when methods like `DirEntry::ino` are called on Android the result may be truncated as we're tied to returning a `ino_t` type, not the underlying type. The commit here incorporates two backwards-compatible components: * Deprecate all `raw` types that aren't in `std::os::raw` * Expand the `std::os::*::fs::MetadataExt` trait on all platforms for method accessors of all fields. The fields now returned widened types which are the same across platforms (consistency across platforms is not required, however, it's just convenient). and two also backwards-incompatible components: * Change the definition of all `std::os::*::raw` type aliases to correspond to the newly widened types that are being returned on each platform. * Change the definition of `std::os::*::raw::stat` on Linux to match the LFS definitions rather than the standard ones. The breaking changes here will specifically break code that assumes that `libc` and `std` agree on the definition of `std::os::*::raw` types, or that the `std` types are faithful representations of the types in C. An [audit] has been performed of crates.io to determine the fallout which was determined two be minimal, with the two found cases of breakage having been fixed now. [audit]: rust-lang/rfcs#1415 (comment) --- Ok, so after all that, we're finally able to support LFS on Linux! This commit then simultaneously starts using `stat64` and friends on Linux to ensure that we can open >4GB files on 32-bit Linux. Yay! Closes #28978 Closes #30050 Closes #31549
This follows the pattern already used for stat functions from rust-lang#31551. Now `ftruncate`, `lseek`, and `readdir_r` use their explicit 64-bit variants for LFS support, using wider `off_t` and `dirent` types. This also updates to `open64`, which uses no different types but implies the `O_LARGEFILE` flag. Non-Linux platforms just map their normal functions to the 64-bit names. r? @alexcrichton
This follows the pattern already used for stat functions from #31551. Now `ftruncate`, `lseek`, and `readdir_r` use their explicit 64-bit variants for LFS support, using wider `off_t` and `dirent` types. This also updates to `open64`, which uses no different types but implies the `O_LARGEFILE` flag. Non-Linux platforms just map their normal functions to the 64-bit names. r? @alexcrichton
Fixes #108. MetadataExt now returns direct numeric types rather than platform-specific ones, so we need to adjust the functions that use these to have the new types. I've just aliased the types to specific ones so the rest of the code remains the same (file.rs is the only place that uses this) The RFC that changed this is here: rust-lang/rust#31551
This commit is an implementation of RFC 1415 which deprecates all types
in the
std::os::*::raw
modules.Many of the types in these modules don't actually have a canonical platform
representation, for example the definition of
stat
on 32-bit Linux will changedepending on whether C code is compiled with LFS support or not. Unfortunately
the current types in
std::os::*::raw
are billed as "compatible with C", whichin light of this means it isn't really possible.
To make matters worse, platforms like Android sometimes define these types as
smaller than the way they're actually represented in the
stat
structureitself. This means that when methods like
DirEntry::ino
are called on Androidthe result may be truncated as we're tied to returning a
ino_t
type, not theunderlying type.
The commit here incorporates two backwards-compatible components:
raw
types that aren't instd::os::raw
std::os::*::fs::MetadataExt
trait on all platforms for methodaccessors of all fields. The fields now returned widened types which are the
same across platforms (consistency across platforms is not required, however,
it's just convenient).
and two also backwards-incompatible components:
std::os::*::raw
type aliases tocorrespond to the newly widened types that are being returned on each
platform.
std::os::*::raw::stat
on Linux to match the LFSdefinitions rather than the standard ones.
The breaking changes here will specifically break code that assumes that
libc
and
std
agree on the definition ofstd::os::*::raw
types, or that thestd
types are faithful representations of the types in C. An audit has been
performed of crates.io to determine the fallout which was determined two be
minimal, with the two found cases of breakage having been fixed now.
Ok, so after all that, we're finally able to support LFS on Linux! This commit
then simultaneously starts using
stat64
and friends on Linux to ensure that wecan open >4GB files on 32-bit Linux. Yay!
Closes #28978
Closes #30050
Closes #31549