xref: /linux/Documentation/kbuild/Kconfig.recursion-issue-02 (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
11c199f28SLuis R. Rodriguez# Cumulative Kconfig recursive issue
21c199f28SLuis R. Rodriguez# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31c199f28SLuis R. Rodriguez#
41c199f28SLuis R. Rodriguez# Test with:
51c199f28SLuis R. Rodriguez#
61c199f28SLuis R. Rodriguez# make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig
71c199f28SLuis R. Rodriguez#
81c199f28SLuis R. Rodriguez# The recursive limitations with Kconfig has some non intuitive implications on
9879a3209SBhaskar Chowdhury# kconfig semantics which are documented here. One known practical implication
101c199f28SLuis R. Rodriguez# of the recursive limitation is that drivers cannot negate features from other
111c199f28SLuis R. Rodriguez# drivers if they share a common core requirement and use disjoint semantics to
121c199f28SLuis R. Rodriguez# annotate those requirements, ie, some drivers use "depends on" while others
131c199f28SLuis R. Rodriguez# use "select". For instance it means if a driver A and driver B share the same
141c199f28SLuis R. Rodriguez# core requirement, and one uses "select" while the other uses "depends on" to
151c199f28SLuis R. Rodriguez# annotate this, all features that driver A selects cannot now be negated by
161c199f28SLuis R. Rodriguez# driver B.
171c199f28SLuis R. Rodriguez#
181c199f28SLuis R. Rodriguez# A perhaps not so obvious implication of this is that, if semantics on these
191c199f28SLuis R. Rodriguez# core requirements are not carefully synced, as drivers evolve features
201c199f28SLuis R. Rodriguez# they select or depend on end up becoming shared requirements which cannot be
211c199f28SLuis R. Rodriguez# negated by other drivers.
221c199f28SLuis R. Rodriguez#
231c199f28SLuis R. Rodriguez# The example provided in Documentation/kbuild/Kconfig.recursion-issue-02
241c199f28SLuis R. Rodriguez# describes a simple driver core layout of example features a kernel might
251c199f28SLuis R. Rodriguez# have. Let's assume we have some CORE functionality, then the kernel has a
261c199f28SLuis R. Rodriguez# series of bells and whistles it desires to implement, its not so advanced so
271c199f28SLuis R. Rodriguez# it only supports bells at this time: CORE_BELL_A and CORE_BELL_B. If
281c199f28SLuis R. Rodriguez# CORE_BELL_A has some advanced feature CORE_BELL_A_ADVANCED which selects
291c199f28SLuis R. Rodriguez# CORE_BELL_A then CORE_BELL_A ends up becoming a common BELL feature which
301c199f28SLuis R. Rodriguez# other bells in the system cannot negate. The reason for this issue is
311c199f28SLuis R. Rodriguez# due to the disjoint use of semantics on expressing each bell's relationship
321c199f28SLuis R. Rodriguez# with CORE, one uses "depends on" while the other uses "select". Another
331c199f28SLuis R. Rodriguez# more important reason is that kconfig does not check for dependencies listed
341c199f28SLuis R. Rodriguez# under 'select' for a symbol, when such symbols are selected kconfig them
351c199f28SLuis R. Rodriguez# as mandatory required symbols. For more details on the heavy handed nature
361c199f28SLuis R. Rodriguez# of select refer to Documentation/kbuild/Kconfig.select-break
371c199f28SLuis R. Rodriguez#
381c199f28SLuis R. Rodriguez# To fix this the "depends on CORE" must be changed to "select CORE", or the
391c199f28SLuis R. Rodriguez# "select CORE" must be changed to "depends on CORE".
401c199f28SLuis R. Rodriguez#
411c199f28SLuis R. Rodriguez# For an example real world scenario issue refer to the attempt to remove
421c199f28SLuis R. Rodriguez# "select FW_LOADER" [0], in the end the simple alternative solution to this
431c199f28SLuis R. Rodriguez# problem consisted on matching semantics with newly introduced features.
441c199f28SLuis R. Rodriguez#
45*a9d85efbSThorsten Leemhuis# [0] https://lore.kernel.org/r/1432241149-8762-1-git-send-email-mcgrof@do-not-panic.com
461c199f28SLuis R. Rodriguez
471c199f28SLuis R. Rodriguezmainmenu "Simple example to demo cumulative kconfig recursive dependency implication"
481c199f28SLuis R. Rodriguez
491c199f28SLuis R. Rodriguezconfig CORE
501c199f28SLuis R. Rodriguez	tristate
511c199f28SLuis R. Rodriguez
521c199f28SLuis R. Rodriguezconfig CORE_BELL_A
531c199f28SLuis R. Rodriguez	tristate
541c199f28SLuis R. Rodriguez	depends on CORE
551c199f28SLuis R. Rodriguez
561c199f28SLuis R. Rodriguezconfig CORE_BELL_A_ADVANCED
571c199f28SLuis R. Rodriguez	tristate
581c199f28SLuis R. Rodriguez	select CORE_BELL_A
591c199f28SLuis R. Rodriguez
601c199f28SLuis R. Rodriguezconfig CORE_BELL_B
611c199f28SLuis R. Rodriguez	tristate
621c199f28SLuis R. Rodriguez	depends on !CORE_BELL_A
631c199f28SLuis R. Rodriguez	select CORE
64