xref: /linux/Documentation/kbuild/Kconfig.recursion-issue-01 (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
11c199f28SLuis R. Rodriguez# Simple 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-01 allnoconfig
71c199f28SLuis R. Rodriguez#
81c199f28SLuis R. Rodriguez# This Kconfig file has a simple recursive dependency issue. In order to
91c199f28SLuis R. Rodriguez# understand why this recursive dependency issue occurs lets consider what
101c199f28SLuis R. Rodriguez# Kconfig needs to address. We iterate over what Kconfig needs to address
111c199f28SLuis R. Rodriguez# by stepping through the questions it needs to address sequentially.
121c199f28SLuis R. Rodriguez#
131c199f28SLuis R. Rodriguez#  * What values are possible for CORE?
141c199f28SLuis R. Rodriguez#
151c199f28SLuis R. Rodriguez# CORE_BELL_A_ADVANCED selects CORE, which means that it influences the values
161c199f28SLuis R. Rodriguez# that are possible for CORE. So for example if CORE_BELL_A_ADVANCED is 'y',
171c199f28SLuis R. Rodriguez# CORE must be 'y' too.
181c199f28SLuis R. Rodriguez#
191c199f28SLuis R. Rodriguez#  * What influences CORE_BELL_A_ADVANCED?
201c199f28SLuis R. Rodriguez#
211c199f28SLuis R. Rodriguez# As the name implies CORE_BELL_A_ADVANCED is an advanced feature of
221c199f28SLuis R. Rodriguez# CORE_BELL_A so naturally it depends on CORE_BELL_A. So if CORE_BELL_A is 'y'
231c199f28SLuis R. Rodriguez# we know CORE_BELL_A_ADVANCED can be 'y' too.
241c199f28SLuis R. Rodriguez#
251c199f28SLuis R. Rodriguez#   * What influences CORE_BELL_A?
261c199f28SLuis R. Rodriguez#
271c199f28SLuis R. Rodriguez# CORE_BELL_A depends on CORE, so CORE influences CORE_BELL_A.
281c199f28SLuis R. Rodriguez#
291c199f28SLuis R. Rodriguez# But that is a problem, because this means that in order to determine
301c199f28SLuis R. Rodriguez# what values are possible for CORE we ended up needing to address questions
311c199f28SLuis R. Rodriguez# regarding possible values of CORE itself again. Answering the original
321c199f28SLuis R. Rodriguez# question of what are the possible values of CORE would make the kconfig
331c199f28SLuis R. Rodriguez# tools run in a loop. When this happens Kconfig exits and complains about
341c199f28SLuis R. Rodriguez# the "recursive dependency detected" error.
351c199f28SLuis R. Rodriguez#
361c199f28SLuis R. Rodriguez# Reading the Documentation/kbuild/Kconfig.recursion-issue-01 file it may be
37*6388cfd0SThorsten Blum# obvious that an easy solution to this problem should just be the removal
381c199f28SLuis R. Rodriguez# of the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already
391c199f28SLuis R. Rodriguez# since CORE_BELL_A depends on CORE. Recursive dependency issues are not always
401c199f28SLuis R. Rodriguez# so trivial to resolve, we provide another example below of practical
411c199f28SLuis R. Rodriguez# implications of this recursive issue where the solution is perhaps not so
421c199f28SLuis R. Rodriguez# easy to understand. Note that matching semantics on the dependency on
431c199f28SLuis R. Rodriguez# CORE also consist of a solution to this recursive problem.
441c199f28SLuis R. Rodriguez
451c199f28SLuis R. Rodriguezmainmenu "Simple example to demo kconfig recursive dependency issue"
461c199f28SLuis R. Rodriguez
471c199f28SLuis R. Rodriguezconfig CORE
481c199f28SLuis R. Rodriguez	tristate
491c199f28SLuis R. Rodriguez
501c199f28SLuis R. Rodriguezconfig CORE_BELL_A
511c199f28SLuis R. Rodriguez	tristate
521c199f28SLuis R. Rodriguez	depends on CORE
531c199f28SLuis R. Rodriguez
541c199f28SLuis R. Rodriguezconfig CORE_BELL_A_ADVANCED
551c199f28SLuis R. Rodriguez	tristate
561c199f28SLuis R. Rodriguez	depends on CORE_BELL_A
571c199f28SLuis R. Rodriguez	select CORE
58