Skip to content

refactor: move definition of time_t in uclibc#5144

Draft
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:uclibc-time_t-patch
Draft

refactor: move definition of time_t in uclibc#5144
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:uclibc-time_t-patch

Conversation

@dybucc

@dybucc dybucc commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses bit-width representation issues under uClibc for the time_t type.

Following the definition in upstream uclibc-ng (the maintained fork of uClibc,) this type should be
defined in terms of either an i64 or a c_long. This depends on a macro, __UCLIBC_USE_TIME64__,
that makes the latter one available in all systems, irrespective of machine word size or
implementation memory model. This type is declared under libc/sysdeps/linux/common/bits/types.h,
in terms of other types in libc/sysdeps/linux/common/bits/typesizes.h, with no alternative
definitions for other platforms. The macro is not directly set by the library user, but rather
issued at compile time as part of the make configuration scripts that the library provides.

Yet in the libc crate, time_t under the linux/uclibc module has different definitions for all
four of MIPS32, MIPS64, arm and x86_64. This patch changes that such that the definition is shared
by all targets using uClibc, at the top-level uclibc/mod.rs module instead. This does not, at
present, affect L4RE.

Tests are still pending on most platforms.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@dybucc dybucc force-pushed the uclibc-time_t-patch branch from 6bfd246 to 77686a8 Compare June 5, 2026 08:20
@dybucc

dybucc commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

CI is failing for reasons unrelated to the changes introduced in this PR. A rerun should do it.

@dybucc dybucc force-pushed the uclibc-time_t-patch branch 3 times, most recently from 13d76f4 to 017fca3 Compare June 8, 2026 15:43
The uclibc-ng upstream project did not seem to provide different
definitions for all of the target architectures for which the `libc`
crate does provide different definitions.

This patch aims to solve that by moving the prior type-specific
definition of `time_t` to the top-level `unix/linux_like/linux/uclibc`
module. `time_t` is now defined in terms of a platform- and
implementation-specific `c_long`, which fits the default in upstream.

There is a macro that the uclibc-ng project checks for to ensure that
the type is 64-bits wide and not left to the system implementation, but
that does not exist in the original uClibc. This patch does not add
support for it.
@dybucc dybucc force-pushed the uclibc-time_t-patch branch from 017fca3 to bf22331 Compare June 9, 2026 07:09
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

Successfully merging this pull request may close these issues.

1 participant