Skip to content

Commit 28f94a4

Browse files
committed
kbuild: clarify the difference between obj-y and obj-m w.r.t. descending
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, then built-in objects are linked into vmlinux eventually. This works properly only when the Makefile specifying 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 <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Johan Hovold <[email protected]>
1 parent 8f26888 commit 28f94a4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Documentation/kbuild/makefiles.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,19 @@ more details, with real examples.
297297
If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
298298
the corresponding obj- variable will be set, and kbuild will descend
299299
down in the ext2 directory.
300-
Kbuild only uses this information to decide that it needs to visit
301-
the directory, it is the Makefile in the subdirectory that
302-
specifies what is modular and what is built-in.
300+
301+
Kbuild uses this information not only to decide that it needs to visit
302+
the directory, but also to decide whether or not to link objects from
303+
the directory into vmlinux.
304+
305+
When Kbuild descends into the directory with 'y', all built-in objects
306+
from that directory are combined into the built-in.a, which will be
307+
eventually linked into vmlinux.
308+
309+
When Kbuild descends into the directory with 'm', in contrast, nothing
310+
from that directory will be linked into vmlinux. If the Makefile in
311+
that directory specifies obj-y, those objects will be left orphan.
312+
It is very likely a bug of the Makefile or of dependencies in Kconfig.
303313

304314
It is good practice to use a `CONFIG_` variable when assigning directory
305315
names. This allows kbuild to totally skip the directory if the

0 commit comments

Comments
 (0)