Re: [PATCH] riscv: add arch/riscv/Kbuild

2019-09-03 Thread Masahiro Yamada
On Mon, Sep 2, 2019 at 4:42 PM Christoph Hellwig  wrote:
>
> On Sat, Aug 31, 2019 at 10:04:53PM +0900, Masahiro Yamada wrote:
> > Kbuild support two file names, "Makefile" and "Kbuild"
> > for describing obj-y, obj-m, etc.
>
>  I I think I full understand>
>
> > Similarly, arch/$(SRCARCH)/Makefile is very special
> > in that it is included from the top-level Makefile,
> > and specify arch-specific compiler flags etc.
> >
> > We can use arch/$(SRCARCH)/Kbuild
> > to specify obj-y, obj-m.
> > The top-level Makefile does not need to know
> > the directory structure under arch/$(SRCARCH)/.
> >
> > This is logical separation.
>
> But only if we document this specific split and eventually stop allowing
> to build objects from arch/$(SRCARCH)/Makefile.

I like this idea, but it would change the link order (i.e. probe order)

For example, I want move all drivers-y in arch/x86/Makefile
to arch/x86/Kbuild.

I do not know how much we care about the probe order.


>  And in my perfect world
> we'd eventually phase out the magic arch/$(SRCARCH)/Makefile entireŀy.
> In addition to the normal Kbuild file we'd then have say (names entirely
> made up and probably not the best idea)
>
>   arch/$(SRCARCH)/flags.mk to set the various compiler flags and co
>   arch/$(SRCARCH)/targets.mk for extra arch-specific targets

I am not sure whether this split is a good idea.
What is the problem with having the single arch-Makefile?


-- 
Best Regards
Masahiro Yamada


Re: [PATCH] riscv: add arch/riscv/Kbuild

2019-09-02 Thread Christoph Hellwig
On Sat, Aug 31, 2019 at 10:04:53PM +0900, Masahiro Yamada wrote:
> Kbuild support two file names, "Makefile" and "Kbuild"
> for describing obj-y, obj-m, etc.



> Similarly, arch/$(SRCARCH)/Makefile is very special
> in that it is included from the top-level Makefile,
> and specify arch-specific compiler flags etc.
> 
> We can use arch/$(SRCARCH)/Kbuild
> to specify obj-y, obj-m.
> The top-level Makefile does not need to know
> the directory structure under arch/$(SRCARCH)/.
> 
> This is logical separation.

But only if we document this specific split and eventually stop allowing 
to build objects from arch/$(SRCARCH)/Makefile.  And in my perfect world
we'd eventually phase out the magic arch/$(SRCARCH)/Makefile entireŀy.
In addition to the normal Kbuild file we'd then have say (names entirely
made up and probably not the best idea)

  arch/$(SRCARCH)/flags.mk to set the various compiler flags and co
  arch/$(SRCARCH)/targets.mk for extra arch-specific targets


Re: [PATCH] riscv: add arch/riscv/Kbuild

2019-08-31 Thread Masahiro Yamada
On Sat, Aug 31, 2019 at 12:53 AM Christoph Hellwig  wrote:
>
> On Tue, Aug 27, 2019 at 02:14:59PM +0900, Masahiro Yamada wrote:
> > There is a small documentation about "Makefile" vs "Kbuild"
> > in Documentation/kbuild/modules.rst section 3.2
>
> I know that part.
>
> >
> > It is talking about external modules, but the benefit applies
> > to arch/$(SRCARCH)/Kbuild as well.
>
> I fail to fully understand this part, though.

Kbuild support two file names, "Makefile" and "Kbuild"
for describing obj-y, obj-m, etc.

If both exist in the same directory, "Kbuild" takes precedence.

This is useful where we want to use "Makefile"
for other purposes.

For external modules, we use "Makefile" as a start point,
so we often want to  describe obj-m in "Kbuild" instead of "Makefile".


Similarly, arch/$(SRCARCH)/Makefile is very special
in that it is included from the top-level Makefile,
and specify arch-specific compiler flags etc.

We can use arch/$(SRCARCH)/Kbuild
to specify obj-y, obj-m.
The top-level Makefile does not need to know
the directory structure under arch/$(SRCARCH)/.

This is logical separation.


>
> > arch/$(SRCARCH)/Makefile is included by the top Makefile
> > to specify arch-specific compiler flags, etc.
> >
> > On the other hand, arch/$(SRCARCH)/Kbuild, if exists, is included
> > when Kbuild actually descends into arch/$(SRCARCH)/.
> >
> > This allows you to hierarchize the sub-directories to visit
> > instead of specifying everything in flat in arch/$(SRCARCH)/Makefile.
>
> Yes, but what is the plan in the long run?  arch/$(ARCH)/Makefile
> is still a weird hodge-podge of overriding global variables and misc
> Makefile targets, it now just has a tiny little work.

There are lots of arch-specific build settings.
We definitely need a place to describe them,
hence arch/$(SRCARCH)/Makefile.


>  Is there any
> actual benefit from using Kbuild for the build process?

For example, arch/x86/Kbuild is quite useful
since there are many directories in arch/x86.

riscv does not have many directories for now since it is a new architecture,
but it will be useful when it will have more directories.


>  Can we
> eventually move the setting of variables in the Makefile into another
> special purpose file?  Is the support for actually compiling kernel
> source files from the arch/$(ARCH) Makefile eventually going away?

No, I do not think so.

>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv



-- 
Best Regards
Masahiro Yamada


Re: [PATCH] riscv: add arch/riscv/Kbuild

2019-08-30 Thread Paul Walmsley
On Wed, 21 Aug 2019, Masahiro Yamada wrote:

> Use the standard obj-y form to specify the sub-directories under
> arch/riscv/. No functional change intended.
> 
> Signed-off-by: Masahiro Yamada 

Thanks, queued for v5.4-rc1.


- Paul


Re: [PATCH] riscv: add arch/riscv/Kbuild

2019-08-30 Thread Christoph Hellwig
On Tue, Aug 27, 2019 at 02:14:59PM +0900, Masahiro Yamada wrote:
> There is a small documentation about "Makefile" vs "Kbuild"
> in Documentation/kbuild/modules.rst section 3.2

I know that part.

> 
> It is talking about external modules, but the benefit applies
> to arch/$(SRCARCH)/Kbuild as well.

I fail to fully understand this part, though.

> arch/$(SRCARCH)/Makefile is included by the top Makefile
> to specify arch-specific compiler flags, etc.
> 
> On the other hand, arch/$(SRCARCH)/Kbuild, if exists, is included
> when Kbuild actually descends into arch/$(SRCARCH)/.
> 
> This allows you to hierarchize the sub-directories to visit
> instead of specifying everything in flat in arch/$(SRCARCH)/Makefile.

Yes, but what is the plan in the long run?  arch/$(ARCH)/Makefile
is still a weird hodge-podge of overriding global variables and misc
Makefile targets, it now just has a tiny little work.  Is there any
actual benefit from using Kbuild for the build process?  Can we
eventually move the setting of variables in the Makefile into another
special purpose file?  Is the support for actually compiling kernel
source files from the arch/$(ARCH) Makefile eventually going away?


Re: [PATCH] riscv: add arch/riscv/Kbuild

2019-08-26 Thread Masahiro Yamada
On Mon, Aug 26, 2019 at 8:35 PM Christoph Hellwig  wrote:
>
> On Wed, Aug 21, 2019 at 06:26:58PM +0900, Masahiro Yamada wrote:
> > Use the standard obj-y form to specify the sub-directories under
> > arch/riscv/. No functional change intended.
> >
> > Signed-off-by: Masahiro Yamada 
>
> Do you have a document what the grand scheme here is?

There is a small documentation about "Makefile" vs "Kbuild"
in Documentation/kbuild/modules.rst section 3.2

It is talking about external modules, but the benefit applies
to arch/$(SRCARCH)/Kbuild as well.

arch/$(SRCARCH)/Makefile is included by the top Makefile
to specify arch-specific compiler flags, etc.

On the other hand, arch/$(SRCARCH)/Kbuild, if exists, is included
when Kbuild actually descends into arch/$(SRCARCH)/.

This allows you to hierarchize the sub-directories to visit
instead of specifying everything in flat in arch/$(SRCARCH)/Makefile.

Major architectures are already doing this.

See
arch/x86/Kbuild
arch/sparc/Kbuild
arch/powerpc/Kbuild
etc.

(and arm64 also adopted this recently)


The trick is "Kbuild" has precedence over "Makefile".

If you are interested in the actual code,
see line 41 of scripts/Makefile.build




>  Less of the magic
> in arch/$(ARCH)/Makefile sounds like a good idea, but unless we have
> a very specific split between the kbuild makefile and various override
> I fear just splitting things up into two files doesn't really help much.

Why not?


-- 
Best Regards
Masahiro Yamada


Re: [PATCH] riscv: add arch/riscv/Kbuild

2019-08-26 Thread Christoph Hellwig
On Wed, Aug 21, 2019 at 06:26:58PM +0900, Masahiro Yamada wrote:
> Use the standard obj-y form to specify the sub-directories under
> arch/riscv/. No functional change intended.
> 
> Signed-off-by: Masahiro Yamada 

Do you have a document what the grand scheme here is?  Less of the magic
in arch/$(ARCH)/Makefile sounds like a good idea, but unless we have
a very specific split between the kbuild makefile and various override
I fear just splitting things up into two files doesn't really help much.