xref: /linux/Documentation/kbuild/Kconfig.recursion-issue-02 (revision 1c199f2878f6c1b8c52125ad9805e94fe2dde472)
1*1c199f28SLuis R. Rodriguez# Cumulative 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-02 allnoconfig
7*1c199f28SLuis R. Rodriguez#
8*1c199f28SLuis R. Rodriguez# The recursive limitations with Kconfig has some non intuitive implications on
9*1c199f28SLuis R. Rodriguez# kconfig sematics which are documented here. One known practical implication
10*1c199f28SLuis R. Rodriguez# of the recursive limitation is that drivers cannot negate features from other
11*1c199f28SLuis R. Rodriguez# drivers if they share a common core requirement and use disjoint semantics to
12*1c199f28SLuis R. Rodriguez# annotate those requirements, ie, some drivers use "depends on" while others
13*1c199f28SLuis R. Rodriguez# use "select". For instance it means if a driver A and driver B share the same
14*1c199f28SLuis R. Rodriguez# core requirement, and one uses "select" while the other uses "depends on" to
15*1c199f28SLuis R. Rodriguez# annotate this, all features that driver A selects cannot now be negated by
16*1c199f28SLuis R. Rodriguez# driver B.
17*1c199f28SLuis R. Rodriguez#
18*1c199f28SLuis R. Rodriguez# A perhaps not so obvious implication of this is that, if semantics on these
19*1c199f28SLuis R. Rodriguez# core requirements are not carefully synced, as drivers evolve features
20*1c199f28SLuis R. Rodriguez# they select or depend on end up becoming shared requirements which cannot be
21*1c199f28SLuis R. Rodriguez# negated by other drivers.
22*1c199f28SLuis R. Rodriguez#
23*1c199f28SLuis R. Rodriguez# The example provided in Documentation/kbuild/Kconfig.recursion-issue-02
24*1c199f28SLuis R. Rodriguez# describes a simple driver core layout of example features a kernel might
25*1c199f28SLuis R. Rodriguez# have. Let's assume we have some CORE functionality, then the kernel has a
26*1c199f28SLuis R. Rodriguez# series of bells and whistles it desires to implement, its not so advanced so
27*1c199f28SLuis R. Rodriguez# it only supports bells at this time: CORE_BELL_A and CORE_BELL_B. If
28*1c199f28SLuis R. Rodriguez# CORE_BELL_A has some advanced feature CORE_BELL_A_ADVANCED which selects
29*1c199f28SLuis R. Rodriguez# CORE_BELL_A then CORE_BELL_A ends up becoming a common BELL feature which
30*1c199f28SLuis R. Rodriguez# other bells in the system cannot negate. The reason for this issue is
31*1c199f28SLuis R. Rodriguez# due to the disjoint use of semantics on expressing each bell's relationship
32*1c199f28SLuis R. Rodriguez# with CORE, one uses "depends on" while the other uses "select". Another
33*1c199f28SLuis R. Rodriguez# more important reason is that kconfig does not check for dependencies listed
34*1c199f28SLuis R. Rodriguez# under 'select' for a symbol, when such symbols are selected kconfig them
35*1c199f28SLuis R. Rodriguez# as mandatory required symbols. For more details on the heavy handed nature
36*1c199f28SLuis R. Rodriguez# of select refer to Documentation/kbuild/Kconfig.select-break
37*1c199f28SLuis R. Rodriguez#
38*1c199f28SLuis R. Rodriguez# To fix this the "depends on CORE" must be changed to "select CORE", or the
39*1c199f28SLuis R. Rodriguez# "select CORE" must be changed to "depends on CORE".
40*1c199f28SLuis R. Rodriguez#
41*1c199f28SLuis R. Rodriguez# For an example real world scenario issue refer to the attempt to remove
42*1c199f28SLuis R. Rodriguez# "select FW_LOADER" [0], in the end the simple alternative solution to this
43*1c199f28SLuis R. Rodriguez# problem consisted on matching semantics with newly introduced features.
44*1c199f28SLuis R. Rodriguez#
45*1c199f28SLuis R. Rodriguez# [0] http://lkml.kernel.org/r/1432241149-8762-1-git-send-email-mcgrof@do-not-panic.com
46*1c199f28SLuis R. Rodriguez
47*1c199f28SLuis R. Rodriguezmainmenu "Simple example to demo cumulative kconfig recursive dependency implication"
48*1c199f28SLuis R. Rodriguez
49*1c199f28SLuis R. Rodriguezconfig CORE
50*1c199f28SLuis R. Rodriguez	tristate
51*1c199f28SLuis R. Rodriguez
52*1c199f28SLuis R. Rodriguezconfig CORE_BELL_A
53*1c199f28SLuis R. Rodriguez	tristate
54*1c199f28SLuis R. Rodriguez	depends on CORE
55*1c199f28SLuis R. Rodriguez
56*1c199f28SLuis R. Rodriguezconfig CORE_BELL_A_ADVANCED
57*1c199f28SLuis R. Rodriguez	tristate
58*1c199f28SLuis R. Rodriguez	select CORE_BELL_A
59*1c199f28SLuis R. Rodriguez
60*1c199f28SLuis R. Rodriguezconfig CORE_BELL_B
61*1c199f28SLuis R. Rodriguez	tristate
62*1c199f28SLuis R. Rodriguez	depends on !CORE_BELL_A
63*1c199f28SLuis R. Rodriguez	select CORE
64