Description
This issue tracks changes we want to make in libc 1.0.
(Note that this tracking issue previously referred to libc 0.3, this should now be assumed to refer to 1.0 instead)
64-bit time_t
and off_t
On some 32-bit targets, it is unclear whether time_t
should be 32-bit or 64-bit since in C this depends on what pre-processor macros are defined when the C standard library headers are included (e.g. _FILE_OFFSET_BITS
, _TIME_BITS
on glibc) or what version of the libc headers are used (e.g. musl 1.2 changed time_t
to always be 64-bit). This was achieved without breaking ABI compatibility by giving the new 64-bit API separate symbol names (clock_gettime64
) and having the header files transparently redirect the old function names to the new symbols. The old symbols remain available for programs built against old versions of the libc headers.
This makes it difficult for the libc
crate since we can only have one definition of off_t
and time_t
, and yet we need our definitions of those types to match the ones used in any C code we link against.
- musl 1.2: Upgrade musl supported version to 1.2.3 #3068
- Switch to 64-bit time on musl
- Deprecate all the 32-bit variants of time and file offset functions
- On musl 1.2, the unsuffixed variants of time and file offset functions are the 64-bit versions, so perhaps allow those to remain undeprecated.
- Rust binding to LFS64 ABI-compat symbols rather than public names on musl libc #2934 and Alias all LFS64 symbols to their non-LFS64 counterparts on musl #2935
- Decide how to handle
time64_t
andoff64_t
.- Should we provide only the 64-bit suffixed versions? Should we provide the unsuffixed versions and have them be 64-bit? Should we provide the 32-bit versions at all?
Breaking changes
Most of these are mistakes that were made early on which cannot be fixed without making a breaking change. libc 1.0 is a good opportunity to make these changes.
- Remove
iconv
on all platforms - Remove "placeholder constants" #3131
- msghdr.msg_iovlen is inconsistently declared in gnu and musl #2971
- Incorrect
pthread_t
definition on Darwin (should be a raw pointer, not anuintptr_t
) #2903 - Check windows: stat::st_mode and S_IFMT are of different type #3161
- Remove
vfork
: Deprecate vfork #1574 - freebsd: move net/if_mib.h contents to submodule #3367
- Review all breakage canidates in the issue list: https://github.com/rust-lang/libc/issues?q=label%3Abreakage-candidate
Policy
These don't involve any code changes, but instead require a decision for how to handle breaking changes moving forward.
- Define an MSRV policy (MSRV policy for libc crate libs-team#72)
- Define the supported platform versions (e.g. glibc, musl, etc.)
Anonymous structs and unions
Some C types are defined using anonymous structs and unions, such as sigaction
or siginfo
. To properly expose these, we need support for anonymous structs and unions in Rust. This feature is part of RFC 2102, but the implementation is still a work in progress.
- We should implement Unnamed fields of struct and union type rfcs#2102 first?
Trait implementations
RFC 2235 added implementations of Eq
, Hash
and Debug
for all libc types. However it turns out that this is not appropriate for many libc types, especially in the presence of padding, unions and extensible structs.
We would like to un-accept this RFC for libc 1.0 and completely remove Eq
and Hash
trait implementations for all types. It is still an open question whether we want to keep Debug
trait implementations, but we are tending towards removing them as well.
- Remove impls of
Eq
,Hash
, etc. RFC: Implement Debug, Eq, PartialEq, and Hash for libc structs rfcs#2235 - Either remove
Debug
or make it best-effort.
Testing
We use ctest2 to check that the struct and function definitions in libc match those in C header files. However ctest2 is based on an old fork of the Rust parser, which doesn't handle new syntax well. It might be worth rewriting it or replacing it with a more modern tool (possibly based on bindgen/cbindgen).
- Rewrite ctest2 (which is used on libc-test) to support newer edition and syntax
Implementation plan
- Fork a libc-0.2 branch from master on which development for libc 0.2 will continue (done).
- All PRs should target
main
. - Anyone that would like a nonbreaking feature in a sooner release should comment
@rustbot label +stable-nominated
. After merge tomain
, this PR will be considered for cherry pick tolibc-0.2
. - Once all desired features for libc 1.0 are ready, we can made a release! 🎉