mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Zhouyi Zhou <zhouzhouyi@gmail.com>
Cc: w@1wt.eu, rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
	 lance@osuosl.org
Subject: Re: [PATCH] tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers
Date: Thu, 18 Sep 2025 22:01:35 +0200	[thread overview]
Message-ID: <6aa8f3da-05b8-482f-ae14-a1a67a393ebf@t-8ch.de> (raw)
In-Reply-To: <20250918010833.2760723-1-zhouzhouyi@gmail.com>

Hi Zhouyi,

thanks for your report and patch!

On 2025-09-18 01:08:33+0000, Zhouyi Zhou wrote:
> 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).    

FYI you don't need to keep the referenced commit message on a single
line and should reflow it like regular text:

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).    

(Source: I did the same thing as you until Linus told me to stop)

> Some distributions (e.g. Ubuntu 20.04 on ppc64le with older
> exported headers under /usr/include) do not expose
> `__kernel_old_time_t`, causing nolibc builds that rely on host
> headers to fail (I discovered this when doing RCU torture test in
> PPC VM of Open Source Lab of Oregon State University).

Instead of mentioning Ubuntu 20.04, just explain that __kernel_old_time_t
is fairly new, notably from 2020 in commit 94c467ddb273 ("y2038: add
__kernel_old_timespec and __kernel_old_time_t")

> Keep the new behavior, but add a small compatibility shim:
> if `__kernel_old_time_t` is not available, fall back to
>  `signed long`
> 
> This preserves the intent of d5094bcb5bfd while letting nolibc
> build on systems with older exported headers.
> 
> Fixes: d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t")
> Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>    
> ---
>  tools/include/nolibc/std.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
> index ba950f0e7338..ea225a0b16e9 100644
> --- a/tools/include/nolibc/std.h
> +++ b/tools/include/nolibc/std.h
> @@ -29,6 +29,10 @@ typedef unsigned long       nlink_t;
>  typedef   signed long         off_t;
>  typedef   signed long     blksize_t;
>  typedef   signed long      blkcnt_t;
> +#ifndef __kernel_old_time_t
> +typedef   signed long        time_t;
> +#else
>  typedef __kernel_old_time_t  time_t;
> +#endif

I don't think this works as __kernel_old_time_t is never defined.
Instead we could switch to __kernel_time_t, which is the same as
__kernel_old_time_t and has existed for longer.

>
>  #endif /* _NOLIBC_STD_H */


Thomas

      reply	other threads:[~2025-09-18 20:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  1:08 Zhouyi Zhou
2025-09-18 20:01 ` Thomas Weißschuh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6aa8f3da-05b8-482f-ae14-a1a67a393ebf@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=lance@osuosl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=w@1wt.eu \
    --cc=zhouzhouyi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®