2019-02-15 15:53:41

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH] powerpc: use $(origin ARCH) to select KBUILD_DEFCONFIG

I often test all Kconfig commands for all architectures. To ease my
workflow, I want 'make defconfig' at least working without any cross
compiler.

Currently, arch/powerpc/Makefile checks CROSS_COMPILE to decide the
default defconfig source.

If CROSS_COMPILE is unset, it is likely to be the native build, so
'uname -m' is useful to choose the defconfig. If CROSS_COMPILE is set,
the user is cross-building (i.e. 'uname -m' is probably x86_64), so
it falls back to ppc64_defconfig. Yup, make sense.

However, I want to run 'make ARCH=* defconfig' without setting
CROSS_COMPILE for each architecture.

My suggestion is to check $(origin ARCH).

When you cross-compile the kernel, you need to set ARCH from your
environment or from the command line.

For the native build, you do not need to set ARCH. The default in
the top Makefile is used:

ARCH ?= $(SUBARCH)

Hence, $(origin ARCH) returns 'file'.

Before this commit, 'make ARCH=powerpc defconfig' failed:

$ make ARCH=powerpc defconfig
*** Default configuration is based on target 'x86_64_defconfig'
***
*** Can't find default configuration "arch/powerpc/configs/x86_64_defconfig"!
***

After this commit, it will succeed:

$ make ARCH=powerpc defconfig
*** Default configuration is based on 'ppc64_defconfig'
#
# configuration written to .config
#

Signed-off-by: Masahiro Yamada <[email protected]>
---

arch/powerpc/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index ac03334..f989979 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -34,7 +34,7 @@ ifdef CONFIG_PPC_BOOK3S_32
KBUILD_CFLAGS += -mcpu=powerpc
endif

-ifeq ($(CROSS_COMPILE),)
+ifeq ($(origin ARCH), file)
KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
else
KBUILD_DEFCONFIG := ppc64_defconfig
--
2.7.4



2019-02-15 16:10:01

by Mathieu Malaterre

[permalink] [raw]
Subject: Re: [PATCH] powerpc: use $(origin ARCH) to select KBUILD_DEFCONFIG

On Fri, Feb 15, 2019 at 10:41 AM Masahiro Yamada
<[email protected]> wrote:
>
> I often test all Kconfig commands for all architectures. To ease my
> workflow, I want 'make defconfig' at least working without any cross
> compiler.
>
> Currently, arch/powerpc/Makefile checks CROSS_COMPILE to decide the
> default defconfig source.
>
> If CROSS_COMPILE is unset, it is likely to be the native build, so
> 'uname -m' is useful to choose the defconfig. If CROSS_COMPILE is set,
> the user is cross-building (i.e. 'uname -m' is probably x86_64), so
> it falls back to ppc64_defconfig. Yup, make sense.
>
> However, I want to run 'make ARCH=* defconfig' without setting
> CROSS_COMPILE for each architecture.
>
> My suggestion is to check $(origin ARCH).
>
> When you cross-compile the kernel, you need to set ARCH from your
> environment or from the command line.
>
> For the native build, you do not need to set ARCH. The default in
> the top Makefile is used:
>
> ARCH ?= $(SUBARCH)
>
> Hence, $(origin ARCH) returns 'file'.
>
> Before this commit, 'make ARCH=powerpc defconfig' failed:

In case you have not seen it, please check:

http://patchwork.ozlabs.org/patch/1037835/

> $ make ARCH=powerpc defconfig
> *** Default configuration is based on target 'x86_64_defconfig'
> ***
> *** Can't find default configuration "arch/powerpc/configs/x86_64_defconfig"!
> ***
>
> After this commit, it will succeed:
>
> $ make ARCH=powerpc defconfig
> *** Default configuration is based on 'ppc64_defconfig'
> #
> # configuration written to .config
> #
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> arch/powerpc/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index ac03334..f989979 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -34,7 +34,7 @@ ifdef CONFIG_PPC_BOOK3S_32
> KBUILD_CFLAGS += -mcpu=powerpc
> endif
>
> -ifeq ($(CROSS_COMPILE),)
> +ifeq ($(origin ARCH), file)
> KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
> else
> KBUILD_DEFCONFIG := ppc64_defconfig
> --
> 2.7.4
>

2019-02-16 10:26:20

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] powerpc: use $(origin ARCH) to select KBUILD_DEFCONFIG

On Sat, Feb 16, 2019 at 1:11 AM Mathieu Malaterre <[email protected]> wrote:
>
> On Fri, Feb 15, 2019 at 10:41 AM Masahiro Yamada
> <[email protected]> wrote:
> >
> > I often test all Kconfig commands for all architectures. To ease my
> > workflow, I want 'make defconfig' at least working without any cross
> > compiler.
> >
> > Currently, arch/powerpc/Makefile checks CROSS_COMPILE to decide the
> > default defconfig source.
> >
> > If CROSS_COMPILE is unset, it is likely to be the native build, so
> > 'uname -m' is useful to choose the defconfig. If CROSS_COMPILE is set,
> > the user is cross-building (i.e. 'uname -m' is probably x86_64), so
> > it falls back to ppc64_defconfig. Yup, make sense.
> >
> > However, I want to run 'make ARCH=* defconfig' without setting
> > CROSS_COMPILE for each architecture.
> >
> > My suggestion is to check $(origin ARCH).
> >
> > When you cross-compile the kernel, you need to set ARCH from your
> > environment or from the command line.
> >
> > For the native build, you do not need to set ARCH. The default in
> > the top Makefile is used:
> >
> > ARCH ?= $(SUBARCH)
> >
> > Hence, $(origin ARCH) returns 'file'.
> >
> > Before this commit, 'make ARCH=powerpc defconfig' failed:
>
> In case you have not seen it, please check:
>
> http://patchwork.ozlabs.org/patch/1037835/


I did not know that because I do not subscribe to ppc ML.


Michael's patch looks good to me.


If you mimic x86, the following will work:




diff --git a/Makefile b/Makefile
index 86cf35d..eb9552d 100644
--- a/Makefile
+++ b/Makefile
@@ -356,6 +356,11 @@ ifeq ($(ARCH),sh64)
SRCARCH := sh
endif

+# Additional ARCH settings for powerpc
+ifneq ($(filter ppc%,$(ARCH)),)
+ SRCARCH := powerpc
+endif
+
KCONFIG_CONFIG ?= .config
export KCONFIG_CONFIG

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 488c9ed..ff01fef 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -34,10 +34,10 @@ ifdef CONFIG_PPC_BOOK3S_32
KBUILD_CFLAGS += -mcpu=powerpc
endif

-ifeq ($(CROSS_COMPILE),)
-KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
-else
+ifeq ($(ARCH),powerpc)
KBUILD_DEFCONFIG := ppc64_defconfig
+else
+KBUILD_DEFCONFIG := $(ARCH)_defconfig
endif

ifdef CONFIG_PPC64
diff --git a/scripts/subarch.include b/scripts/subarch.include
index 6506828..c98323f 100644
--- a/scripts/subarch.include
+++ b/scripts/subarch.include
@@ -8,6 +8,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e
s/x86_64/x86/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
- -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
+ -e s/mips.*/mips/ \
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
-e s/riscv.*/riscv/)








--
Best Regards
Masahiro Yamada

2019-03-13 20:18:40

by Mathieu Malaterre

[permalink] [raw]
Subject: Re: [PATCH] powerpc: use $(origin ARCH) to select KBUILD_DEFCONFIG

On Sat, Feb 16, 2019 at 3:26 AM Masahiro Yamada
<[email protected]> wrote:
>
> On Sat, Feb 16, 2019 at 1:11 AM Mathieu Malaterre <[email protected]> wrote:
> >
> > On Fri, Feb 15, 2019 at 10:41 AM Masahiro Yamada
> > <[email protected]> wrote:
> > >
> > > I often test all Kconfig commands for all architectures. To ease my
> > > workflow, I want 'make defconfig' at least working without any cross
> > > compiler.
> > >
> > > Currently, arch/powerpc/Makefile checks CROSS_COMPILE to decide the
> > > default defconfig source.
> > >
> > > If CROSS_COMPILE is unset, it is likely to be the native build, so
> > > 'uname -m' is useful to choose the defconfig. If CROSS_COMPILE is set,
> > > the user is cross-building (i.e. 'uname -m' is probably x86_64), so
> > > it falls back to ppc64_defconfig. Yup, make sense.
> > >
> > > However, I want to run 'make ARCH=* defconfig' without setting
> > > CROSS_COMPILE for each architecture.
> > >
> > > My suggestion is to check $(origin ARCH).
> > >
> > > When you cross-compile the kernel, you need to set ARCH from your
> > > environment or from the command line.
> > >
> > > For the native build, you do not need to set ARCH. The default in
> > > the top Makefile is used:
> > >
> > > ARCH ?= $(SUBARCH)
> > >
> > > Hence, $(origin ARCH) returns 'file'.
> > >
> > > Before this commit, 'make ARCH=powerpc defconfig' failed:
> >
> > In case you have not seen it, please check:
> >
> > http://patchwork.ozlabs.org/patch/1037835/
>
>
> I did not know that because I do not subscribe to ppc ML.
>
>
> Michael's patch looks good to me.

OK

>
> If you mimic x86, the following will work:
>

Nice! Michael do you have a preference ?

>
>
> diff --git a/Makefile b/Makefile
> index 86cf35d..eb9552d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -356,6 +356,11 @@ ifeq ($(ARCH),sh64)
> SRCARCH := sh
> endif
>
> +# Additional ARCH settings for powerpc
> +ifneq ($(filter ppc%,$(ARCH)),)
> + SRCARCH := powerpc
> +endif
> +
> KCONFIG_CONFIG ?= .config
> export KCONFIG_CONFIG
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 488c9ed..ff01fef 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -34,10 +34,10 @@ ifdef CONFIG_PPC_BOOK3S_32
> KBUILD_CFLAGS += -mcpu=powerpc
> endif
>
> -ifeq ($(CROSS_COMPILE),)
> -KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
> -else
> +ifeq ($(ARCH),powerpc)
> KBUILD_DEFCONFIG := ppc64_defconfig
> +else
> +KBUILD_DEFCONFIG := $(ARCH)_defconfig
> endif
>
> ifdef CONFIG_PPC64
> diff --git a/scripts/subarch.include b/scripts/subarch.include
> index 6506828..c98323f 100644
> --- a/scripts/subarch.include
> +++ b/scripts/subarch.include
> @@ -8,6 +8,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e
> s/x86_64/x86/ \
> -e s/sun4u/sparc64/ \
> -e s/arm.*/arm/ -e s/sa110/arm/ \
> -e s/s390x/s390/ -e s/parisc64/parisc/ \
> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
> + -e s/mips.*/mips/ \
> -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
> -e s/riscv.*/riscv/)
>
>
>
>
>
>
>
>
> --
> Best Regards
> Masahiro Yamada

2019-03-14 02:27:33

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH] powerpc: use $(origin ARCH) to select KBUILD_DEFCONFIG

Mathieu Malaterre <[email protected]> writes:
> On Sat, Feb 16, 2019 at 3:26 AM Masahiro Yamada
> <[email protected]> wrote:
>>
>> On Sat, Feb 16, 2019 at 1:11 AM Mathieu Malaterre <[email protected]> wrote:
>> >
>> > On Fri, Feb 15, 2019 at 10:41 AM Masahiro Yamada
>> > <[email protected]> wrote:
>> > >
>> > > I often test all Kconfig commands for all architectures. To ease my
>> > > workflow, I want 'make defconfig' at least working without any cross
>> > > compiler.
>> > >
>> > > Currently, arch/powerpc/Makefile checks CROSS_COMPILE to decide the
>> > > default defconfig source.
>> > >
>> > > If CROSS_COMPILE is unset, it is likely to be the native build, so
>> > > 'uname -m' is useful to choose the defconfig. If CROSS_COMPILE is set,
>> > > the user is cross-building (i.e. 'uname -m' is probably x86_64), so
>> > > it falls back to ppc64_defconfig. Yup, make sense.
>> > >
>> > > However, I want to run 'make ARCH=* defconfig' without setting
>> > > CROSS_COMPILE for each architecture.
>> > >
>> > > My suggestion is to check $(origin ARCH).
>> > >
>> > > When you cross-compile the kernel, you need to set ARCH from your
>> > > environment or from the command line.
>> > >
>> > > For the native build, you do not need to set ARCH. The default in
>> > > the top Makefile is used:
>> > >
>> > > ARCH ?= $(SUBARCH)
>> > >
>> > > Hence, $(origin ARCH) returns 'file'.
>> > >
>> > > Before this commit, 'make ARCH=powerpc defconfig' failed:
>> >
>> > In case you have not seen it, please check:
>> >
>> > http://patchwork.ozlabs.org/patch/1037835/
>>
>> I did not know that because I do not subscribe to ppc ML.
>>
>> Michael's patch looks good to me.
>
> OK
>
>>
>> If you mimic x86, the following will work:
>>
>
> Nice! Michael do you have a preference ?

Yeah I don't like playing games with ARCH. Doing so means auto builders
and other build scripts need to learn about the special rules for ARCH,
which is a pain.

So I'll merge my patch, which I think will also work for Masahiro's
case.

cheers

2019-03-15 15:28:14

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] powerpc: use $(origin ARCH) to select KBUILD_DEFCONFIG

On Thu, Mar 14, 2019 at 11:27 AM Michael Ellerman <[email protected]> wrote:
>
> Mathieu Malaterre <[email protected]> writes:
> > On Sat, Feb 16, 2019 at 3:26 AM Masahiro Yamada
> > <[email protected]> wrote:
> >>
> >> On Sat, Feb 16, 2019 at 1:11 AM Mathieu Malaterre <[email protected]> wrote:
> >> >
> >> > On Fri, Feb 15, 2019 at 10:41 AM Masahiro Yamada
> >> > <[email protected]> wrote:
> >> > >
> >> > > I often test all Kconfig commands for all architectures. To ease my
> >> > > workflow, I want 'make defconfig' at least working without any cross
> >> > > compiler.
> >> > >
> >> > > Currently, arch/powerpc/Makefile checks CROSS_COMPILE to decide the
> >> > > default defconfig source.
> >> > >
> >> > > If CROSS_COMPILE is unset, it is likely to be the native build, so
> >> > > 'uname -m' is useful to choose the defconfig. If CROSS_COMPILE is set,
> >> > > the user is cross-building (i.e. 'uname -m' is probably x86_64), so
> >> > > it falls back to ppc64_defconfig. Yup, make sense.
> >> > >
> >> > > However, I want to run 'make ARCH=* defconfig' without setting
> >> > > CROSS_COMPILE for each architecture.
> >> > >
> >> > > My suggestion is to check $(origin ARCH).
> >> > >
> >> > > When you cross-compile the kernel, you need to set ARCH from your
> >> > > environment or from the command line.
> >> > >
> >> > > For the native build, you do not need to set ARCH. The default in
> >> > > the top Makefile is used:
> >> > >
> >> > > ARCH ?= $(SUBARCH)
> >> > >
> >> > > Hence, $(origin ARCH) returns 'file'.
> >> > >
> >> > > Before this commit, 'make ARCH=powerpc defconfig' failed:
> >> >
> >> > In case you have not seen it, please check:
> >> >
> >> > http://patchwork.ozlabs.org/patch/1037835/
> >>
> >> I did not know that because I do not subscribe to ppc ML.
> >>
> >> Michael's patch looks good to me.
> >
> > OK
> >
> >>
> >> If you mimic x86, the following will work:
> >>
> >
> > Nice! Michael do you have a preference ?
>
> Yeah I don't like playing games with ARCH. Doing so means auto builders
> and other build scripts need to learn about the special rules for ARCH,
> which is a pain.
>
> So I'll merge my patch, which I think will also work for Masahiro's
> case.
>
> cheers


Yes, works for me.

Thanks!




--
Best Regards
Masahiro Yamada