^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # Simple Kconfig recursive issue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Test with:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # This Kconfig file has a simple recursive dependency issue. In order to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # understand why this recursive dependency issue occurs lets consider what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # Kconfig needs to address. We iterate over what Kconfig needs to address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # by stepping through the questions it needs to address sequentially.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # * What values are possible for CORE?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) # CORE_BELL_A_ADVANCED selects CORE, which means that it influences the values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # that are possible for CORE. So for example if CORE_BELL_A_ADVANCED is 'y',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # CORE must be 'y' too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # * What influences CORE_BELL_A_ADVANCED ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # As the name implies CORE_BELL_A_ADVANCED is an advanced feature of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) # CORE_BELL_A so naturally it depends on CORE_BELL_A. So if CORE_BELL_A is 'y'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) # we know CORE_BELL_A_ADVANCED can be 'y' too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) # * What influences CORE_BELL_A ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) # CORE_BELL_A depends on CORE, so CORE influences CORE_BELL_A.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) # But that is a problem, because this means that in order to determine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) # what values are possible for CORE we ended up needing to address questions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) # regarding possible values of CORE itself again. Answering the original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) # question of what are the possible values of CORE would make the kconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) # tools run in a loop. When this happens Kconfig exits and complains about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # the "recursive dependency detected" error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) # Reading the Documentation/kbuild/Kconfig.recursion-issue-01 file it may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) # obvious that an easy to solution to this problem should just be the removal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) # of the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) # since CORE_BELL_A depends on CORE. Recursive dependency issues are not always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) # so trivial to resolve, we provide another example below of practical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) # implications of this recursive issue where the solution is perhaps not so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) # easy to understand. Note that matching semantics on the dependency on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) # CORE also consist of a solution to this recursive problem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) mainmenu "Simple example to demo kconfig recursive dependency issue"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) config CORE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) tristate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) config CORE_BELL_A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) tristate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) depends on CORE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) config CORE_BELL_A_ADVANCED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) tristate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) depends on CORE_BELL_A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) select CORE