linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending
@ 2019-12-19 11:51 Masahiro Yamada
  2019-12-19 16:49 ` Johan Hovold
  2019-12-19 19:53 ` Matthew Wilcox
  0 siblings, 2 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-12-19 11:51 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Randy Dunlap, Sam Ravnborg, Johan Hovold, Masahiro Yamada,
	Jonathan Corbet, Michal Marek, linux-doc, linux-kernel

Kbuild descends into a directory by either 'y' or 'm', but there is an
important difference.

Kbuild combines the built-in objects into built-in.a in each directory.
The built-in.a in the directory visited by obj-y is merged into the
built-in.a in the parent directory. This merge happens recursively when
Kbuild is ascending back towards the top directory, so built-in objects
are linked into vmlinux eventually. This works properly only when the
Makefile that specifies obj-y is reachable by the chain of obj-y.

On the other hand, Kbuild does not take built-in.a from the directory
visited by obj-m. This it, all the objects in that directory are supposed
to be modular. If Kbuild descends into a directory by obj-m, but the
Makefile in the sub-directory specifies obj-y, those objects are just
left orphan.

The current statement "Kbuild only uses this information to decide that
it needs to visit the directory" is misleading. Clarify the difference.

Reported-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Documentation/kbuild/makefiles.rst | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index b9b50553bfc5..d7e6534a8505 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -297,9 +297,19 @@ more details, with real examples.
 	If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
 	the corresponding obj- variable will be set, and kbuild will descend
 	down in the ext2 directory.
-	Kbuild only uses this information to decide that it needs to visit
-	the directory, it is the Makefile in the subdirectory that
-	specifies what is modular and what is built-in.
+
+	Kbuild uses this information not only to decide that it needs to visit
+	the directory, but also to decide whether or not to link objects from
+	the directory into vmlinux.
+
+	When Kbuild descends into the directory with 'y', all built-in objects
+	from that directory are combined into the built-in.a, which will be
+	eventually linked into vmlinux.
+
+	When Kbuild descends into the directory with 'm', in contrast, nothing
+	from that directory will be linked into vmlinux. If the Makefile in
+	that directory specifies obj-y, those objects will be left orphan.
+	It is very likely a bug of the Makefile or of dependencies in Kconfig.
 
 	It is good practice to use a `CONFIG_` variable when assigning directory
 	names. This allows kbuild to totally skip the directory if the
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending
  2019-12-19 11:51 [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending Masahiro Yamada
@ 2019-12-19 16:49 ` Johan Hovold
  2019-12-21 15:32   ` Masahiro Yamada
  2019-12-19 19:53 ` Matthew Wilcox
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2019-12-19 16:49 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Randy Dunlap, Sam Ravnborg, Johan Hovold,
	Jonathan Corbet, Michal Marek, linux-doc, linux-kernel

On Thu, Dec 19, 2019 at 08:51:00PM +0900, Masahiro Yamada wrote:
> Kbuild descends into a directory by either 'y' or 'm', but there is an
> important difference.
> 
> Kbuild combines the built-in objects into built-in.a in each directory.
> The built-in.a in the directory visited by obj-y is merged into the
> built-in.a in the parent directory. This merge happens recursively when
> Kbuild is ascending back towards the top directory, so built-in objects
> are linked into vmlinux eventually. This works properly only when the
> Makefile that specifies obj-y is reachable by the chain of obj-y.
> 
> On the other hand, Kbuild does not take built-in.a from the directory
> visited by obj-m. This it, all the objects in that directory are supposed
> to be modular. If Kbuild descends into a directory by obj-m, but the
> Makefile in the sub-directory specifies obj-y, those objects are just
> left orphan.
> 
> The current statement "Kbuild only uses this information to decide that
> it needs to visit the directory" is misleading. Clarify the difference.
> 
> Reported-by: Johan Hovold <johan@kernel.org>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Looks good! Thanks for fixing this.

Reviewed-by: Johan Hovold <johan@kernel.org>

> ---
> 
>  Documentation/kbuild/makefiles.rst | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
> index b9b50553bfc5..d7e6534a8505 100644
> --- a/Documentation/kbuild/makefiles.rst
> +++ b/Documentation/kbuild/makefiles.rst
> @@ -297,9 +297,19 @@ more details, with real examples.
>  	If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
>  	the corresponding obj- variable will be set, and kbuild will descend
>  	down in the ext2 directory.
> -	Kbuild only uses this information to decide that it needs to visit
> -	the directory, it is the Makefile in the subdirectory that
> -	specifies what is modular and what is built-in.
> +
> +	Kbuild uses this information not only to decide that it needs to visit
> +	the directory, but also to decide whether or not to link objects from
> +	the directory into vmlinux.
> +
> +	When Kbuild descends into the directory with 'y', all built-in objects
> +	from that directory are combined into the built-in.a, which will be
> +	eventually linked into vmlinux.
> +
> +	When Kbuild descends into the directory with 'm', in contrast, nothing
> +	from that directory will be linked into vmlinux. If the Makefile in
> +	that directory specifies obj-y, those objects will be left orphan.
> +	It is very likely a bug of the Makefile or of dependencies in Kconfig.
>  
>  	It is good practice to use a `CONFIG_` variable when assigning directory
>  	names. This allows kbuild to totally skip the directory if the

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending
  2019-12-19 11:51 [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending Masahiro Yamada
  2019-12-19 16:49 ` Johan Hovold
@ 2019-12-19 19:53 ` Matthew Wilcox
  2019-12-20 16:00   ` Masahiro Yamada
  1 sibling, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2019-12-19 19:53 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Randy Dunlap, Sam Ravnborg, Johan Hovold,
	Jonathan Corbet, Michal Marek, linux-doc, linux-kernel

On Thu, Dec 19, 2019 at 08:51:00PM +0900, Masahiro Yamada wrote:
> Kbuild descends into a directory by either 'y' or 'm', but there is an
> important difference.
> 
> Kbuild combines the built-in objects into built-in.a in each directory.
> The built-in.a in the directory visited by obj-y is merged into the
> built-in.a in the parent directory. This merge happens recursively when
> Kbuild is ascending back towards the top directory, so built-in objects
> are linked into vmlinux eventually. This works properly only when the
> Makefile that specifies obj-y is reachable by the chain of obj-y.
> 
> On the other hand, Kbuild does not take built-in.a from the directory
> visited by obj-m. This it, all the objects in that directory are supposed
> to be modular. If Kbuild descends into a directory by obj-m, but the
> Makefile in the sub-directory specifies obj-y, those objects are just
> left orphan.
> 
> The current statement "Kbuild only uses this information to decide that
> it needs to visit the directory" is misleading. Clarify the difference.

> +	Kbuild uses this information not only to decide that it needs to visit
> +	the directory, but also to decide whether or not to link objects from
> +	the directory into vmlinux.
> +
> +	When Kbuild descends into the directory with 'y', all built-in objects
> +	from that directory are combined into the built-in.a, which will be
> +	eventually linked into vmlinux.
> +
> +	When Kbuild descends into the directory with 'm', in contrast, nothing
> +	from that directory will be linked into vmlinux. If the Makefile in
> +	that directory specifies obj-y, those objects will be left orphan.
> +	It is very likely a bug of the Makefile or of dependencies in Kconfig.

Perhaps the implementation should be changed to match the documentation?
This seems like a very subtle point for people to know.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending
  2019-12-19 19:53 ` Matthew Wilcox
@ 2019-12-20 16:00   ` Masahiro Yamada
  0 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-12-20 16:00 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Linux Kbuild mailing list, Randy Dunlap, Sam Ravnborg,
	Johan Hovold, Jonathan Corbet, Michal Marek,
	open list:DOCUMENTATION, Linux Kernel Mailing List

On Fri, Dec 20, 2019 at 4:53 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Thu, Dec 19, 2019 at 08:51:00PM +0900, Masahiro Yamada wrote:
> > Kbuild descends into a directory by either 'y' or 'm', but there is an
> > important difference.
> >
> > Kbuild combines the built-in objects into built-in.a in each directory.
> > The built-in.a in the directory visited by obj-y is merged into the
> > built-in.a in the parent directory. This merge happens recursively when
> > Kbuild is ascending back towards the top directory, so built-in objects
> > are linked into vmlinux eventually. This works properly only when the
> > Makefile that specifies obj-y is reachable by the chain of obj-y.
> >
> > On the other hand, Kbuild does not take built-in.a from the directory
> > visited by obj-m. This it, all the objects in that directory are supposed
> > to be modular. If Kbuild descends into a directory by obj-m, but the
> > Makefile in the sub-directory specifies obj-y, those objects are just
> > left orphan.
> >
> > The current statement "Kbuild only uses this information to decide that
> > it needs to visit the directory" is misleading. Clarify the difference.
>
> > +     Kbuild uses this information not only to decide that it needs to visit
> > +     the directory, but also to decide whether or not to link objects from
> > +     the directory into vmlinux.
> > +
> > +     When Kbuild descends into the directory with 'y', all built-in objects
> > +     from that directory are combined into the built-in.a, which will be
> > +     eventually linked into vmlinux.
> > +
> > +     When Kbuild descends into the directory with 'm', in contrast, nothing
> > +     from that directory will be linked into vmlinux. If the Makefile in
> > +     that directory specifies obj-y, those objects will be left orphan.
> > +     It is very likely a bug of the Makefile or of dependencies in Kconfig.
>
> Perhaps the implementation should be changed to match the documentation?
> This seems like a very subtle point for people to know.

I also considered this, but
I do not think the current behavior is too odd.
So, I am not changing it.

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending
  2019-12-19 16:49 ` Johan Hovold
@ 2019-12-21 15:32   ` Masahiro Yamada
  0 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-12-21 15:32 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Linux Kbuild mailing list, Randy Dunlap, Sam Ravnborg,
	Jonathan Corbet, Michal Marek, open list:DOCUMENTATION,
	Linux Kernel Mailing List

On Fri, Dec 20, 2019 at 1:49 AM Johan Hovold <johan@kernel.org> wrote:
>
> On Thu, Dec 19, 2019 at 08:51:00PM +0900, Masahiro Yamada wrote:
> > Kbuild descends into a directory by either 'y' or 'm', but there is an
> > important difference.
> >
> > Kbuild combines the built-in objects into built-in.a in each directory.
> > The built-in.a in the directory visited by obj-y is merged into the
> > built-in.a in the parent directory. This merge happens recursively when
> > Kbuild is ascending back towards the top directory, so built-in objects
> > are linked into vmlinux eventually. This works properly only when the
> > Makefile that specifies obj-y is reachable by the chain of obj-y.
> >
> > On the other hand, Kbuild does not take built-in.a from the directory
> > visited by obj-m. This it, all the objects in that directory are supposed
> > to be modular. If Kbuild descends into a directory by obj-m, but the
> > Makefile in the sub-directory specifies obj-y, those objects are just
> > left orphan.
> >
> > The current statement "Kbuild only uses this information to decide that
> > it needs to visit the directory" is misleading. Clarify the difference.
> >
> > Reported-by: Johan Hovold <johan@kernel.org>
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> Looks good! Thanks for fixing this.
>
> Reviewed-by: Johan Hovold <johan@kernel.org>

Applied to linux-kbuild.

> > ---
> >
> >  Documentation/kbuild/makefiles.rst | 16 +++++++++++++---
> >  1 file changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
> > index b9b50553bfc5..d7e6534a8505 100644
> > --- a/Documentation/kbuild/makefiles.rst
> > +++ b/Documentation/kbuild/makefiles.rst
> > @@ -297,9 +297,19 @@ more details, with real examples.
> >       If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
> >       the corresponding obj- variable will be set, and kbuild will descend
> >       down in the ext2 directory.
> > -     Kbuild only uses this information to decide that it needs to visit
> > -     the directory, it is the Makefile in the subdirectory that
> > -     specifies what is modular and what is built-in.
> > +
> > +     Kbuild uses this information not only to decide that it needs to visit
> > +     the directory, but also to decide whether or not to link objects from
> > +     the directory into vmlinux.
> > +
> > +     When Kbuild descends into the directory with 'y', all built-in objects
> > +     from that directory are combined into the built-in.a, which will be
> > +     eventually linked into vmlinux.
> > +
> > +     When Kbuild descends into the directory with 'm', in contrast, nothing
> > +     from that directory will be linked into vmlinux. If the Makefile in
> > +     that directory specifies obj-y, those objects will be left orphan.
> > +     It is very likely a bug of the Makefile or of dependencies in Kconfig.
> >
> >       It is good practice to use a `CONFIG_` variable when assigning directory
> >       names. This allows kbuild to totally skip the directory if the



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-21 15:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19 11:51 [PATCH] kbuild: clarify the difference between obj-y and obj-m w.r.t. descending Masahiro Yamada
2019-12-19 16:49 ` Johan Hovold
2019-12-21 15:32   ` Masahiro Yamada
2019-12-19 19:53 ` Matthew Wilcox
2019-12-20 16:00   ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).