162306a36Sopenharmony_ci# Cumulative Kconfig recursive issue
262306a36Sopenharmony_ci# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362306a36Sopenharmony_ci#
462306a36Sopenharmony_ci# Test with:
562306a36Sopenharmony_ci#
662306a36Sopenharmony_ci# make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig
762306a36Sopenharmony_ci#
862306a36Sopenharmony_ci# The recursive limitations with Kconfig has some non intuitive implications on
962306a36Sopenharmony_ci# kconfig semantics which are documented here. One known practical implication
1062306a36Sopenharmony_ci# of the recursive limitation is that drivers cannot negate features from other
1162306a36Sopenharmony_ci# drivers if they share a common core requirement and use disjoint semantics to
1262306a36Sopenharmony_ci# annotate those requirements, ie, some drivers use "depends on" while others
1362306a36Sopenharmony_ci# use "select". For instance it means if a driver A and driver B share the same
1462306a36Sopenharmony_ci# core requirement, and one uses "select" while the other uses "depends on" to
1562306a36Sopenharmony_ci# annotate this, all features that driver A selects cannot now be negated by
1662306a36Sopenharmony_ci# driver B.
1762306a36Sopenharmony_ci#
1862306a36Sopenharmony_ci# A perhaps not so obvious implication of this is that, if semantics on these
1962306a36Sopenharmony_ci# core requirements are not carefully synced, as drivers evolve features
2062306a36Sopenharmony_ci# they select or depend on end up becoming shared requirements which cannot be
2162306a36Sopenharmony_ci# negated by other drivers.
2262306a36Sopenharmony_ci#
2362306a36Sopenharmony_ci# The example provided in Documentation/kbuild/Kconfig.recursion-issue-02
2462306a36Sopenharmony_ci# describes a simple driver core layout of example features a kernel might
2562306a36Sopenharmony_ci# have. Let's assume we have some CORE functionality, then the kernel has a
2662306a36Sopenharmony_ci# series of bells and whistles it desires to implement, its not so advanced so
2762306a36Sopenharmony_ci# it only supports bells at this time: CORE_BELL_A and CORE_BELL_B. If
2862306a36Sopenharmony_ci# CORE_BELL_A has some advanced feature CORE_BELL_A_ADVANCED which selects
2962306a36Sopenharmony_ci# CORE_BELL_A then CORE_BELL_A ends up becoming a common BELL feature which
3062306a36Sopenharmony_ci# other bells in the system cannot negate. The reason for this issue is
3162306a36Sopenharmony_ci# due to the disjoint use of semantics on expressing each bell's relationship
3262306a36Sopenharmony_ci# with CORE, one uses "depends on" while the other uses "select". Another
3362306a36Sopenharmony_ci# more important reason is that kconfig does not check for dependencies listed
3462306a36Sopenharmony_ci# under 'select' for a symbol, when such symbols are selected kconfig them
3562306a36Sopenharmony_ci# as mandatory required symbols. For more details on the heavy handed nature
3662306a36Sopenharmony_ci# of select refer to Documentation/kbuild/Kconfig.select-break
3762306a36Sopenharmony_ci#
3862306a36Sopenharmony_ci# To fix this the "depends on CORE" must be changed to "select CORE", or the
3962306a36Sopenharmony_ci# "select CORE" must be changed to "depends on CORE".
4062306a36Sopenharmony_ci#
4162306a36Sopenharmony_ci# For an example real world scenario issue refer to the attempt to remove
4262306a36Sopenharmony_ci# "select FW_LOADER" [0], in the end the simple alternative solution to this
4362306a36Sopenharmony_ci# problem consisted on matching semantics with newly introduced features.
4462306a36Sopenharmony_ci#
4562306a36Sopenharmony_ci# [0] https://lore.kernel.org/r/1432241149-8762-1-git-send-email-mcgrof@do-not-panic.com
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cimainmenu "Simple example to demo cumulative kconfig recursive dependency implication"
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciconfig CORE
5062306a36Sopenharmony_ci	tristate
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciconfig CORE_BELL_A
5362306a36Sopenharmony_ci	tristate
5462306a36Sopenharmony_ci	depends on CORE
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciconfig CORE_BELL_A_ADVANCED
5762306a36Sopenharmony_ci	tristate
5862306a36Sopenharmony_ci	select CORE_BELL_A
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciconfig CORE_BELL_B
6162306a36Sopenharmony_ci	tristate
6262306a36Sopenharmony_ci	depends on !CORE_BELL_A
6362306a36Sopenharmony_ci	select CORE
64