18c2ecf20Sopenharmony_ci# Cumulative Kconfig recursive issue
28c2ecf20Sopenharmony_ci# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Test with:
58c2ecf20Sopenharmony_ci#
68c2ecf20Sopenharmony_ci# make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig
78c2ecf20Sopenharmony_ci#
88c2ecf20Sopenharmony_ci# The recursive limitations with Kconfig has some non intuitive implications on
98c2ecf20Sopenharmony_ci# kconfig sematics which are documented here. One known practical implication
108c2ecf20Sopenharmony_ci# of the recursive limitation is that drivers cannot negate features from other
118c2ecf20Sopenharmony_ci# drivers if they share a common core requirement and use disjoint semantics to
128c2ecf20Sopenharmony_ci# annotate those requirements, ie, some drivers use "depends on" while others
138c2ecf20Sopenharmony_ci# use "select". For instance it means if a driver A and driver B share the same
148c2ecf20Sopenharmony_ci# core requirement, and one uses "select" while the other uses "depends on" to
158c2ecf20Sopenharmony_ci# annotate this, all features that driver A selects cannot now be negated by
168c2ecf20Sopenharmony_ci# driver B.
178c2ecf20Sopenharmony_ci#
188c2ecf20Sopenharmony_ci# A perhaps not so obvious implication of this is that, if semantics on these
198c2ecf20Sopenharmony_ci# core requirements are not carefully synced, as drivers evolve features
208c2ecf20Sopenharmony_ci# they select or depend on end up becoming shared requirements which cannot be
218c2ecf20Sopenharmony_ci# negated by other drivers.
228c2ecf20Sopenharmony_ci#
238c2ecf20Sopenharmony_ci# The example provided in Documentation/kbuild/Kconfig.recursion-issue-02
248c2ecf20Sopenharmony_ci# describes a simple driver core layout of example features a kernel might
258c2ecf20Sopenharmony_ci# have. Let's assume we have some CORE functionality, then the kernel has a
268c2ecf20Sopenharmony_ci# series of bells and whistles it desires to implement, its not so advanced so
278c2ecf20Sopenharmony_ci# it only supports bells at this time: CORE_BELL_A and CORE_BELL_B. If
288c2ecf20Sopenharmony_ci# CORE_BELL_A has some advanced feature CORE_BELL_A_ADVANCED which selects
298c2ecf20Sopenharmony_ci# CORE_BELL_A then CORE_BELL_A ends up becoming a common BELL feature which
308c2ecf20Sopenharmony_ci# other bells in the system cannot negate. The reason for this issue is
318c2ecf20Sopenharmony_ci# due to the disjoint use of semantics on expressing each bell's relationship
328c2ecf20Sopenharmony_ci# with CORE, one uses "depends on" while the other uses "select". Another
338c2ecf20Sopenharmony_ci# more important reason is that kconfig does not check for dependencies listed
348c2ecf20Sopenharmony_ci# under 'select' for a symbol, when such symbols are selected kconfig them
358c2ecf20Sopenharmony_ci# as mandatory required symbols. For more details on the heavy handed nature
368c2ecf20Sopenharmony_ci# of select refer to Documentation/kbuild/Kconfig.select-break
378c2ecf20Sopenharmony_ci#
388c2ecf20Sopenharmony_ci# To fix this the "depends on CORE" must be changed to "select CORE", or the
398c2ecf20Sopenharmony_ci# "select CORE" must be changed to "depends on CORE".
408c2ecf20Sopenharmony_ci#
418c2ecf20Sopenharmony_ci# For an example real world scenario issue refer to the attempt to remove
428c2ecf20Sopenharmony_ci# "select FW_LOADER" [0], in the end the simple alternative solution to this
438c2ecf20Sopenharmony_ci# problem consisted on matching semantics with newly introduced features.
448c2ecf20Sopenharmony_ci#
458c2ecf20Sopenharmony_ci# [0] https://lkml.kernel.org/r/1432241149-8762-1-git-send-email-mcgrof@do-not-panic.com
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cimainmenu "Simple example to demo cumulative kconfig recursive dependency implication"
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciconfig CORE
508c2ecf20Sopenharmony_ci	tristate
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciconfig CORE_BELL_A
538c2ecf20Sopenharmony_ci	tristate
548c2ecf20Sopenharmony_ci	depends on CORE
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ciconfig CORE_BELL_A_ADVANCED
578c2ecf20Sopenharmony_ci	tristate
588c2ecf20Sopenharmony_ci	select CORE_BELL_A
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ciconfig CORE_BELL_B
618c2ecf20Sopenharmony_ci	tristate
628c2ecf20Sopenharmony_ci	depends on !CORE_BELL_A
638c2ecf20Sopenharmony_ci	select CORE
64