All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Zhangjin Wu <falcon@tinylab.org>
Cc: arnd@arndb.de, thomas@t-8ch.de, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH v3 3/3] selftests/nolibc: riscv: customize makefile for rv32
Date: Wed, 7 Jun 2023 06:17:13 +0200	[thread overview]
Message-ID: <ZIAEybZdXywKv43C@1wt.eu> (raw)
In-Reply-To: <20230607012032.585223-1-falcon@tinylab.org>

Hi,

On Wed, Jun 07, 2023 at 09:20:32AM +0800, Zhangjin Wu wrote:
> Arnd, Thomas, Willy
> 
> > > >     +# Additional ARCH settings for riscv
> > > >     +ifeq ($(ARCH),riscv32)
> > > >     +        SRCARCH := riscv
> > > >     +endif
> > > >     +ifeq ($(ARCH),riscv64)
> > > >     +        SRCARCH := riscv
> > > >     +endif
> > > >     +
> > > >      export cross_compiling :=
> > > >      ifneq ($(SRCARCH),$(SUBARCH))
> > > >      cross_compiling := 1
> > >
> > > I've never been a big fan of the top-level $(ARCH) setting
> > > in the kernel, is there a reason this has to be the same
> > > as the variable in tools/include/nolibc? If not, I'd just
> > > leave the Linux Makefile unchanged.
> > >
> > > For userspace we have a lot more target names than
> > > arch/*/ directories in the kernel, and I don't think
> > > I'd want to enumerate all the possibilities in the
> > > build system globally.

Actually it's not exactly used by nolibc, except to pass to the kernel
for the install part to extract kernel headers (make headers_install).
It's one of the parts that has required to stick to most of the kernel's
variables very closely (the other one being for nolibc-test which needs
to build a kernel).

> Good news, I did find a better solution without touching the top-level
> Makefile, that is overriding the ARCH to 'riscv' just before the targets
> and after we got the necessary settings with the original ARCH=riscv32
> or ARCH=riscv64, but it requires to convert the '=' assignments to ':=',
> which is not that hard to do and it is more acceptable, just verified it
> and it worked well.
> 
>     ...
> 
>      LDFLAGS := -s
> 
>     +# top-level kernel Makefile only accept ARCH=riscv, override ARCH to make kernel happy
>     +ifneq ($(findstring riscv,$(ARCH)),)
>     +override ARCH := riscv
>     +endif
>     +

That can be one approach indeed. Another one if we continue to face
difficulties for this one would be to use a distinct KARCH variable
to assign to ARCH in all kernel-specific operations.

>      help:
>             @echo "Supported targets under selftests/nolibc:"
>             @echo "  all          call the \"run\" target below"
> 
> This change is not that big, and the left changes can keep consistent with the
> other platforms. but I still need to add a standalone patch to convert the '='
> to ':=' to avoid the before setting using our new overridded ARCH.

I don't even see why the other ones below are needed, given that as
long as they remain assigned as macros, they will be replaced in-place
where they are used, so they will reference the last known assignment
to ARCH.

>     ++ b/tools/testing/selftests/nolibc/Makefile
>     @@ -26,7 +26,7 @@ IMAGE_riscv64    = arch/riscv/boot/Image
>      IMAGE_riscv      = arch/riscv/boot/Image
>      IMAGE_s390       = arch/s390/boot/bzImage
>      IMAGE_loongarch  = arch/loongarch/boot/vmlinuz.efi
>     -IMAGE            = $(IMAGE_$(ARCH))
>     +IMAGE           := $(IMAGE_$(ARCH))
>      IMAGE_NAME       = $(notdir $(IMAGE))
> 
>      # default kernel configurations that appear to be usable
>     @@ -41,7 +41,7 @@ DEFCONFIG_riscv64    = defconfig
>      DEFCONFIG_riscv      = defconfig
>      DEFCONFIG_s390       = defconfig
>      DEFCONFIG_loongarch  = defconfig
>     -DEFCONFIG            = $(DEFCONFIG_$(ARCH))
>     +DEFCONFIG           := $(DEFCONFIG_$(ARCH))
> 
>      # optional tests to run (default = all)
>      TEST =
>     @@ -58,7 +58,7 @@ QEMU_ARCH_riscv64    = riscv64
>      QEMU_ARCH_riscv      = riscv64
>      QEMU_ARCH_s390       = s390x
>      QEMU_ARCH_loongarch  = loongarch64
>     -QEMU_ARCH            = $(QEMU_ARCH_$(ARCH))
>     +QEMU_ARCH           := $(QEMU_ARCH_$(ARCH))
> 
>      # QEMU_ARGS : some arch-specific args to pass to qemu
>      QEMU_ARGS_i386       = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>     @@ -72,7 +72,7 @@ QEMU_ARGS_riscv64    = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_T
>      QEMU_ARGS_riscv      = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>      QEMU_ARGS_s390       = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>      QEMU_ARGS_loongarch  = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>     -QEMU_ARGS            = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA)
>     +QEMU_ARGS           := $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA)
> 
>      # OUTPUT is only set when run from the main makefile, otherwise
>      # it defaults to this nolibc directory.
>     @@ -87,11 +87,18 @@ endif
>      CFLAGS_riscv32 = -march=rv32im -mabi=ilp32
>      CFLAGS_s390 = -m64
>      CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))
>     -CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \
>     +CFLAGS_default := -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \
>                     $(call cc-option,-fno-stack-protector) \
>                     $(CFLAGS_$(ARCH)) $(CFLAGS_STACKPROTECTOR)
>     +
>     +CFLAGS  ?= $(CFLAGS_default)

Why did you need to split this one like this instead of proceeding
like for the other ones ? Because of the "?=" maybe ? Please
double-check that you really need to turn this from a macro to a
variable, if as I suspect it it's not needed, it would be even
simpler.

Thanks,
Willy

WARNING: multiple messages have this Message-ID (diff)
From: Willy Tarreau <w@1wt.eu>
To: Zhangjin Wu <falcon@tinylab.org>
Cc: arnd@arndb.de, thomas@t-8ch.de, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH v3 3/3] selftests/nolibc: riscv: customize makefile for rv32
Date: Wed, 7 Jun 2023 06:17:13 +0200	[thread overview]
Message-ID: <ZIAEybZdXywKv43C@1wt.eu> (raw)
In-Reply-To: <20230607012032.585223-1-falcon@tinylab.org>

Hi,

On Wed, Jun 07, 2023 at 09:20:32AM +0800, Zhangjin Wu wrote:
> Arnd, Thomas, Willy
> 
> > > >     +# Additional ARCH settings for riscv
> > > >     +ifeq ($(ARCH),riscv32)
> > > >     +        SRCARCH := riscv
> > > >     +endif
> > > >     +ifeq ($(ARCH),riscv64)
> > > >     +        SRCARCH := riscv
> > > >     +endif
> > > >     +
> > > >      export cross_compiling :=
> > > >      ifneq ($(SRCARCH),$(SUBARCH))
> > > >      cross_compiling := 1
> > >
> > > I've never been a big fan of the top-level $(ARCH) setting
> > > in the kernel, is there a reason this has to be the same
> > > as the variable in tools/include/nolibc? If not, I'd just
> > > leave the Linux Makefile unchanged.
> > >
> > > For userspace we have a lot more target names than
> > > arch/*/ directories in the kernel, and I don't think
> > > I'd want to enumerate all the possibilities in the
> > > build system globally.

Actually it's not exactly used by nolibc, except to pass to the kernel
for the install part to extract kernel headers (make headers_install).
It's one of the parts that has required to stick to most of the kernel's
variables very closely (the other one being for nolibc-test which needs
to build a kernel).

> Good news, I did find a better solution without touching the top-level
> Makefile, that is overriding the ARCH to 'riscv' just before the targets
> and after we got the necessary settings with the original ARCH=riscv32
> or ARCH=riscv64, but it requires to convert the '=' assignments to ':=',
> which is not that hard to do and it is more acceptable, just verified it
> and it worked well.
> 
>     ...
> 
>      LDFLAGS := -s
> 
>     +# top-level kernel Makefile only accept ARCH=riscv, override ARCH to make kernel happy
>     +ifneq ($(findstring riscv,$(ARCH)),)
>     +override ARCH := riscv
>     +endif
>     +

That can be one approach indeed. Another one if we continue to face
difficulties for this one would be to use a distinct KARCH variable
to assign to ARCH in all kernel-specific operations.

>      help:
>             @echo "Supported targets under selftests/nolibc:"
>             @echo "  all          call the \"run\" target below"
> 
> This change is not that big, and the left changes can keep consistent with the
> other platforms. but I still need to add a standalone patch to convert the '='
> to ':=' to avoid the before setting using our new overridded ARCH.

I don't even see why the other ones below are needed, given that as
long as they remain assigned as macros, they will be replaced in-place
where they are used, so they will reference the last known assignment
to ARCH.

>     ++ b/tools/testing/selftests/nolibc/Makefile
>     @@ -26,7 +26,7 @@ IMAGE_riscv64    = arch/riscv/boot/Image
>      IMAGE_riscv      = arch/riscv/boot/Image
>      IMAGE_s390       = arch/s390/boot/bzImage
>      IMAGE_loongarch  = arch/loongarch/boot/vmlinuz.efi
>     -IMAGE            = $(IMAGE_$(ARCH))
>     +IMAGE           := $(IMAGE_$(ARCH))
>      IMAGE_NAME       = $(notdir $(IMAGE))
> 
>      # default kernel configurations that appear to be usable
>     @@ -41,7 +41,7 @@ DEFCONFIG_riscv64    = defconfig
>      DEFCONFIG_riscv      = defconfig
>      DEFCONFIG_s390       = defconfig
>      DEFCONFIG_loongarch  = defconfig
>     -DEFCONFIG            = $(DEFCONFIG_$(ARCH))
>     +DEFCONFIG           := $(DEFCONFIG_$(ARCH))
> 
>      # optional tests to run (default = all)
>      TEST =
>     @@ -58,7 +58,7 @@ QEMU_ARCH_riscv64    = riscv64
>      QEMU_ARCH_riscv      = riscv64
>      QEMU_ARCH_s390       = s390x
>      QEMU_ARCH_loongarch  = loongarch64
>     -QEMU_ARCH            = $(QEMU_ARCH_$(ARCH))
>     +QEMU_ARCH           := $(QEMU_ARCH_$(ARCH))
> 
>      # QEMU_ARGS : some arch-specific args to pass to qemu
>      QEMU_ARGS_i386       = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>     @@ -72,7 +72,7 @@ QEMU_ARGS_riscv64    = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_T
>      QEMU_ARGS_riscv      = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>      QEMU_ARGS_s390       = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>      QEMU_ARGS_loongarch  = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>     -QEMU_ARGS            = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA)
>     +QEMU_ARGS           := $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA)
> 
>      # OUTPUT is only set when run from the main makefile, otherwise
>      # it defaults to this nolibc directory.
>     @@ -87,11 +87,18 @@ endif
>      CFLAGS_riscv32 = -march=rv32im -mabi=ilp32
>      CFLAGS_s390 = -m64
>      CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))
>     -CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \
>     +CFLAGS_default := -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \
>                     $(call cc-option,-fno-stack-protector) \
>                     $(CFLAGS_$(ARCH)) $(CFLAGS_STACKPROTECTOR)
>     +
>     +CFLAGS  ?= $(CFLAGS_default)

Why did you need to split this one like this instead of proceeding
like for the other ones ? Because of the "?=" maybe ? Please
double-check that you really need to turn this from a macro to a
variable, if as I suspect it it's not needed, it would be even
simpler.

Thanks,
Willy

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-06-07  4:21 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-03  9:00 [PATCH v3 0/3] nolibc: add part2 of support for rv32 Zhangjin Wu
2023-06-03  9:00 ` Zhangjin Wu
2023-06-03  9:01 ` [PATCH v3 1/3] tools/nolibc: fix up #error compile failures with -ENOSYS Zhangjin Wu
2023-06-03  9:01   ` Zhangjin Wu
2023-06-06  7:35   ` Arnd Bergmann
2023-06-06  7:35     ` Arnd Bergmann
2023-06-07  5:19     ` Zhangjin Wu
2023-06-07  5:19       ` Zhangjin Wu
2023-06-07  8:45       ` Arnd Bergmann
2023-06-07  8:45         ` Arnd Bergmann
2023-06-07  9:46         ` Zhangjin Wu
2023-06-07  9:46           ` Zhangjin Wu
2023-06-07 10:02           ` Arnd Bergmann
2023-06-07 10:02             ` Arnd Bergmann
2023-06-07 13:26             ` Zhangjin Wu
2023-06-07 13:26               ` Zhangjin Wu
2023-06-03  9:04 ` [PATCH v3 2/3] tools/nolibc: fix up undeclared syscall macros with #ifdef and -ENOSYS Zhangjin Wu
2023-06-03  9:04   ` Zhangjin Wu
2023-06-03  9:05 ` [PATCH v3 3/3] selftests/nolibc: riscv: customize makefile for rv32 Zhangjin Wu
2023-06-03  9:05   ` Zhangjin Wu
2023-06-06  7:43   ` Arnd Bergmann
2023-06-06  7:43     ` Arnd Bergmann
2023-06-06 11:12     ` Zhangjin Wu
2023-06-06 11:12       ` Zhangjin Wu
2023-06-06 11:21       ` Arnd Bergmann
2023-06-06 11:21         ` Arnd Bergmann
2023-06-06 12:07         ` Zhangjin Wu
2023-06-06 12:07           ` Zhangjin Wu
2023-06-07  1:20           ` Zhangjin Wu
2023-06-07  1:20             ` Zhangjin Wu
2023-06-07  4:17             ` Willy Tarreau [this message]
2023-06-07  4:17               ` Willy Tarreau
2023-06-07  6:33               ` Zhangjin Wu
2023-06-07  6:33                 ` Zhangjin Wu
2023-06-07  7:33                 ` Willy Tarreau
2023-06-07  7:33                   ` Willy Tarreau
2023-06-07  8:11                   ` Zhangjin Wu
2023-06-07  8:11                     ` Zhangjin Wu
2023-06-07 10:44                     ` Willy Tarreau
2023-06-07 10:44                       ` Willy Tarreau
2023-06-06  4:25 ` [PATCH v3 0/3] nolibc: add part2 of support " Zhangjin Wu
2023-06-06  4:25   ` Zhangjin Wu
2023-06-06  4:42   ` Willy Tarreau
2023-06-06  4:42     ` Willy Tarreau
2023-06-06  6:34     ` Zhangjin Wu
2023-06-06  6:34       ` Zhangjin Wu
2023-06-06  6:45       ` Willy Tarreau
2023-06-06  6:45         ` Willy Tarreau

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=ZIAEybZdXywKv43C@1wt.eu \
    --to=w@1wt.eu \
    --cc=arnd@arndb.de \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=thomas@t-8ch.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.