Skip to contentSkip to conversation

tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers

PATCH In review Zhouyi Zhou 2 participants 2 messages Sep 19, 2025 – Sep 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers

Commit d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t") made nolibc use the kernel's time type so that time_t matches timespec::tv_sec on all ABIs (notably x32).

But since __kernel_old_time_t
is fairly new, notably from 2020 in commit 94c467ddb273 ("y2038: add __kernel_old_timespec and __kernel_old_time_t"), nolibc builds that rely on host headers may fail.

Switch to __kernel_time_t, which is the same as
__kernel_old_time_t and has existed for longer.

Tested in PPC VM of Open Source Lab of Oregon State University (./tools/testing/selftests/rcutorture/bin/mkinitrd.sh)

Fixes d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t")
---
 tools/include/nolibc/std.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/nolibc/std.h +1 -1
index ba950f0e7338..3940778822f4 100644
@@ -29,6 +29,6 @@ typedef unsigned long       nlink_t;
 typedef   signed long         off_t;
 typedef   signed long     blksize_t;
 typedef   signed long      blkcnt_t;
-typedef __kernel_old_time_t  time_t;
+typedef __kernel_time_t  time_t;
 
 #endif /* _NOLIBC_STD_H */
Signature · 1 line
2.25.1
#1 lore raw
Quoted 9 lines · Zhouyi Zhou

Commit d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t") made nolibc use the kernel's time type so that time_t matches timespec::tv_sec on all ABIs (notably x32).

But since __kernel_old_time_t
is fairly new, notably from 2020 in commit 94c467ddb273 ("y2038: add __kernel_old_timespec and __kernel_old_time_t"), nolibc builds that rely on host headers may fail.

Quoted 8 lines

Switch to __kernel_time_t, which is the same as
__kernel_old_time_t and has existed for longer.

Tested in PPC VM of Open Source Lab of Oregon State University (./tools/testing/selftests/rcutorture/bin/mkinitrd.sh)

Fixes d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t")

Thanks! Although it is fairly late in the developmment cycle I have applied it to nolibc-next for 6.18.

(...)