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