mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: chris.chenfeiyang@gmail.com
Cc: paulmck@kernel.org, Feiyang Chen <chenfeiyang@loongson.cn>,
	arnd@arndb.de, chenhuacai@kernel.org, jiaxun.yang@flygoat.com,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	Vincent Dagonneau <v@vda.io>
Subject: Re: [PATCH v3 2/5] tools/nolibc: Add statx() and make stat() rely on statx() if necessary
Date: Sun, 12 Feb 2023 22:12:32 +0100	[thread overview]
Message-ID: <Y+lWQC3XU3xWqEi2@1wt.eu> (raw)
In-Reply-To: <f60027664200d6d1f0ed6c7b87915a223afb982f.1675907639.git.chenfeiyang@loongson.cn>

Hi Feiyang,

On Thu, Feb 09, 2023 at 11:24:13AM +0800, chris.chenfeiyang@gmail.com wrote:
> From: Feiyang Chen <chenfeiyang@loongson.cn>
> 
> LoongArch and RISC-V 32-bit only have statx(). ARC, Hexagon, Nios2 and
> OpenRISC have statx() and stat64() but not stat() or newstat(). Add
> statx() and make stat() rely on statx() if necessary to make them happy.
> We may just use statx() for all architectures in the future.
> 
> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> ---
>  tools/include/nolibc/sys.h | 56 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> index c4818a9c8823..70c30d457952 100644
> --- a/tools/include/nolibc/sys.h
> +++ b/tools/include/nolibc/sys.h
> @@ -20,6 +20,7 @@
>  #include <linux/time.h>
>  #include <linux/auxvec.h>
>  #include <linux/fcntl.h> // for O_* and AT_*
> +#include <linux/stat.h>  // for statx()

This one causes build warnings on all archs but x86_64:

  /f/tc/nolibc/gcc-11.3.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc -Os -fno-ident -fno-asynchronous-unwind-tables  -s -o nolibc-test \
    -nostdlib -static -Isysroot/arm64/include nolibc-test.c -lgcc
  In file included from sysroot/arm64/include/sys.h:23,
                   from sysroot/arm64/include/nolibc.h:99,
                   from sysroot/arm64/include/errno.h:26,
                   from sysroot/arm64/include/stdio.h:14,
                   from nolibc-test.c:15:
  sysroot/arm64/include/linux/stat.h:9: warning: "S_IFMT" redefined
      9 | #define S_IFMT  00170000
        | 
  In file included from sysroot/arm64/include/nolibc.h:98,
                   from sysroot/arm64/include/errno.h:26,
                   from sysroot/arm64/include/stdio.h:14,
                   from nolibc-test.c:15:
  sysroot/arm64/include/types.h:27: note: this is the location of the previous definition

This is caused by the definitions for S_IF* and S_IS* in types.h. However
if I remove them I'm seeing x86_64 fail on S_IFCHR not defined. The root
cause is that the x86_64 toolchain falls back to /usr/include for the
include_next <limits.h> that others do not do (probably that when built
it thought it was a native compiler instead of a cross-compiler). I'm
apparently able to work around this by ifdefing out the definitions but
it makes me feel like I'm hiding the dust under the carpet. Instead I'm
thinking of reusing Vincent's work who added stdint and the definitions
for the various INT*MAX values that are normally found in limits.h and
providing our own limits.h so that this issue is globally addressed.

I'm going to experiment a little bit about this and will propose something
once I'm satisfied with a solution that we can queue for 6.4. Most likely
it will involve merging a variant of Vincent's series first, a few changes
to have limits.h then your series.

Best regards,
Willy

  reply	other threads:[~2023-02-12 21:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09  3:24 [PATCH v3 0/5] Add LoongArch support to nolibc chris.chenfeiyang
2023-02-09  3:24 ` [PATCH v3 1/5] tools/nolibc: Include linux/fcntl.h and remove duplicate code chris.chenfeiyang
2023-02-09  3:24 ` [PATCH v3 2/5] tools/nolibc: Add statx() and make stat() rely on statx() if necessary chris.chenfeiyang
2023-02-12 21:12   ` Willy Tarreau [this message]
2023-02-13  1:06     ` Feiyang Chen
2023-02-19 19:06       ` Willy Tarreau
2023-02-20  1:04         ` Feiyang Chen
2023-02-09  3:24 ` [PATCH v3 3/5] tools/nolibc: Add support for LoongArch chris.chenfeiyang
2023-02-09  3:24 ` [PATCH v3 4/5] selftests/nolibc: " chris.chenfeiyang
2023-02-09  3:24 ` [PATCH v3 5/5] selftests/nolibc: Adjust indentation for Makefile chris.chenfeiyang
2023-02-09  3:35 ` [PATCH v3 0/5] Add LoongArch support to nolibc Willy Tarreau
2023-02-09  3:38   ` Huacai Chen

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=Y+lWQC3XU3xWqEi2@1wt.eu \
    --to=w@1wt.eu \
    --cc=arnd@arndb.de \
    --cc=chenfeiyang@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=chris.chenfeiyang@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=paulmck@kernel.org \
    --cc=v@vda.io \
    /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®