kconfig-language.rst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. ================
  2. Kconfig Language
  3. ================
  4. Introduction
  5. ------------
  6. The configuration database is a collection of configuration options
  7. organized in a tree structure::
  8. +- Code maturity level options
  9. | +- Prompt for development and/or incomplete code/drivers
  10. +- General setup
  11. | +- Networking support
  12. | +- System V IPC
  13. | +- BSD Process Accounting
  14. | +- Sysctl support
  15. +- Loadable module support
  16. | +- Enable loadable module support
  17. | +- Set version information on all module symbols
  18. | +- Kernel module loader
  19. +- ...
  20. Every entry has its own dependencies. These dependencies are used
  21. to determine the visibility of an entry. Any child entry is only
  22. visible if its parent entry is also visible.
  23. Menu entries
  24. ------------
  25. Most entries define a config option; all other entries help to organize
  26. them. A single configuration option is defined like this::
  27. config MODVERSIONS
  28. bool "Set version information on all module symbols"
  29. depends on MODULES
  30. help
  31. Usually, modules have to be recompiled whenever you switch to a new
  32. kernel. ...
  33. Every line starts with a key word and can be followed by multiple
  34. arguments. "config" starts a new config entry. The following lines
  35. define attributes for this config option. Attributes can be the type of
  36. the config option, input prompt, dependencies, help text and default
  37. values. A config option can be defined multiple times with the same
  38. name, but every definition can have only a single input prompt and the
  39. type must not conflict.
  40. Menu attributes
  41. ---------------
  42. A menu entry can have a number of attributes. Not all of them are
  43. applicable everywhere (see syntax).
  44. - type definition: "bool"/"tristate"/"string"/"hex"/"int"
  45. Every config option must have a type. There are only two basic types:
  46. tristate and string; the other types are based on these two. The type
  47. definition optionally accepts an input prompt, so these two examples
  48. are equivalent::
  49. bool "Networking support"
  50. and::
  51. bool
  52. prompt "Networking support"
  53. - input prompt: "prompt" <prompt> ["if" <expr>]
  54. Every menu entry can have at most one prompt, which is used to display
  55. to the user. Optionally dependencies only for this prompt can be added
  56. with "if".
  57. - default value: "default" <expr> ["if" <expr>]
  58. A config option can have any number of default values. If multiple
  59. default values are visible, only the first defined one is active.
  60. Default values are not limited to the menu entry where they are
  61. defined. This means the default can be defined somewhere else or be
  62. overridden by an earlier definition.
  63. The default value is only assigned to the config symbol if no other
  64. value was set by the user (via the input prompt above). If an input
  65. prompt is visible the default value is presented to the user and can
  66. be overridden by him.
  67. Optionally, dependencies only for this default value can be added with
  68. "if".
  69. The default value deliberately defaults to 'n' in order to avoid bloating the
  70. build. With few exceptions, new config options should not change this. The
  71. intent is for "make oldconfig" to add as little as possible to the config from
  72. release to release.
  73. Note:
  74. Things that merit "default y/m" include:
  75. a) A new Kconfig option for something that used to always be built
  76. should be "default y".
  77. b) A new gatekeeping Kconfig option that hides/shows other Kconfig
  78. options (but does not generate any code of its own), should be
  79. "default y" so people will see those other options.
  80. c) Sub-driver behavior or similar options for a driver that is
  81. "default n". This allows you to provide sane defaults.
  82. d) Hardware or infrastructure that everybody expects, such as CONFIG_NET
  83. or CONFIG_BLOCK. These are rare exceptions.
  84. - type definition + default value::
  85. "def_bool"/"def_tristate" <expr> ["if" <expr>]
  86. This is a shorthand notation for a type definition plus a value.
  87. Optionally dependencies for this default value can be added with "if".
  88. - dependencies: "depends on" <expr>
  89. This defines a dependency for this menu entry. If multiple
  90. dependencies are defined, they are connected with '&&'. Dependencies
  91. are applied to all other options within this menu entry (which also
  92. accept an "if" expression), so these two examples are equivalent::
  93. bool "foo" if BAR
  94. default y if BAR
  95. and::
  96. depends on BAR
  97. bool "foo"
  98. default y
  99. - reverse dependencies: "select" <symbol> ["if" <expr>]
  100. While normal dependencies reduce the upper limit of a symbol (see
  101. below), reverse dependencies can be used to force a lower limit of
  102. another symbol. The value of the current menu symbol is used as the
  103. minimal value <symbol> can be set to. If <symbol> is selected multiple
  104. times, the limit is set to the largest selection.
  105. Reverse dependencies can only be used with boolean or tristate
  106. symbols.
  107. Note:
  108. select should be used with care. select will force
  109. a symbol to a value without visiting the dependencies.
  110. By abusing select you are able to select a symbol FOO even
  111. if FOO depends on BAR that is not set.
  112. In general use select only for non-visible symbols
  113. (no prompts anywhere) and for symbols with no dependencies.
  114. That will limit the usefulness but on the other hand avoid
  115. the illegal configurations all over.
  116. - weak reverse dependencies: "imply" <symbol> ["if" <expr>]
  117. This is similar to "select" as it enforces a lower limit on another
  118. symbol except that the "implied" symbol's value may still be set to n
  119. from a direct dependency or with a visible prompt.
  120. Given the following example::
  121. config FOO
  122. tristate "foo"
  123. imply BAZ
  124. config BAZ
  125. tristate "baz"
  126. depends on BAR
  127. The following values are possible:
  128. === === ============= ==============
  129. FOO BAR BAZ's default choice for BAZ
  130. === === ============= ==============
  131. n y n N/m/y
  132. m y m M/y/n
  133. y y y Y/m/n
  134. n m n N/m
  135. m m m M/n
  136. y m n M/n
  137. y n * N
  138. === === ============= ==============
  139. This is useful e.g. with multiple drivers that want to indicate their
  140. ability to hook into a secondary subsystem while allowing the user to
  141. configure that subsystem out without also having to unset these drivers.
  142. Note: If the combination of FOO=y and BAR=m causes a link error,
  143. you can guard the function call with IS_REACHABLE()::
  144. foo_init()
  145. {
  146. if (IS_REACHABLE(CONFIG_BAZ))
  147. baz_register(&foo);
  148. ...
  149. }
  150. Note: If the feature provided by BAZ is highly desirable for FOO,
  151. FOO should imply not only BAZ, but also its dependency BAR::
  152. config FOO
  153. tristate "foo"
  154. imply BAR
  155. imply BAZ
  156. - limiting menu display: "visible if" <expr>
  157. This attribute is only applicable to menu blocks, if the condition is
  158. false, the menu block is not displayed to the user (the symbols
  159. contained there can still be selected by other symbols, though). It is
  160. similar to a conditional "prompt" attribute for individual menu
  161. entries. Default value of "visible" is true.
  162. - numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
  163. This allows to limit the range of possible input values for int
  164. and hex symbols. The user can only input a value which is larger than
  165. or equal to the first symbol and smaller than or equal to the second
  166. symbol.
  167. - help text: "help"
  168. This defines a help text. The end of the help text is determined by
  169. the indentation level, this means it ends at the first line which has
  170. a smaller indentation than the first line of the help text.
  171. - misc options: "option" <symbol>[=<value>]
  172. Various less common options can be defined via this option syntax,
  173. which can modify the behaviour of the menu entry and its config
  174. symbol. These options are currently possible:
  175. - "defconfig_list"
  176. This declares a list of default entries which can be used when
  177. looking for the default configuration (which is used when the main
  178. .config doesn't exists yet.)
  179. - "modules"
  180. This declares the symbol to be used as the MODULES symbol, which
  181. enables the third modular state for all config symbols.
  182. At most one symbol may have the "modules" option set.
  183. - "allnoconfig_y"
  184. This declares the symbol as one that should have the value y when
  185. using "allnoconfig". Used for symbols that hide other symbols.
  186. Menu dependencies
  187. -----------------
  188. Dependencies define the visibility of a menu entry and can also reduce
  189. the input range of tristate symbols. The tristate logic used in the
  190. expressions uses one more state than normal boolean logic to express the
  191. module state. Dependency expressions have the following syntax::
  192. <expr> ::= <symbol> (1)
  193. <symbol> '=' <symbol> (2)
  194. <symbol> '!=' <symbol> (3)
  195. <symbol1> '<' <symbol2> (4)
  196. <symbol1> '>' <symbol2> (4)
  197. <symbol1> '<=' <symbol2> (4)
  198. <symbol1> '>=' <symbol2> (4)
  199. '(' <expr> ')' (5)
  200. '!' <expr> (6)
  201. <expr> '&&' <expr> (7)
  202. <expr> '||' <expr> (8)
  203. Expressions are listed in decreasing order of precedence.
  204. (1) Convert the symbol into an expression. Boolean and tristate symbols
  205. are simply converted into the respective expression values. All
  206. other symbol types result in 'n'.
  207. (2) If the values of both symbols are equal, it returns 'y',
  208. otherwise 'n'.
  209. (3) If the values of both symbols are equal, it returns 'n',
  210. otherwise 'y'.
  211. (4) If value of <symbol1> is respectively lower, greater, lower-or-equal,
  212. or greater-or-equal than value of <symbol2>, it returns 'y',
  213. otherwise 'n'.
  214. (5) Returns the value of the expression. Used to override precedence.
  215. (6) Returns the result of (2-/expr/).
  216. (7) Returns the result of min(/expr/, /expr/).
  217. (8) Returns the result of max(/expr/, /expr/).
  218. An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
  219. respectively for calculations). A menu entry becomes visible when its
  220. expression evaluates to 'm' or 'y'.
  221. There are two types of symbols: constant and non-constant symbols.
  222. Non-constant symbols are the most common ones and are defined with the
  223. 'config' statement. Non-constant symbols consist entirely of alphanumeric
  224. characters or underscores.
  225. Constant symbols are only part of expressions. Constant symbols are
  226. always surrounded by single or double quotes. Within the quote, any
  227. other character is allowed and the quotes can be escaped using '\'.
  228. Menu structure
  229. --------------
  230. The position of a menu entry in the tree is determined in two ways. First
  231. it can be specified explicitly::
  232. menu "Network device support"
  233. depends on NET
  234. config NETDEVICES
  235. ...
  236. endmenu
  237. All entries within the "menu" ... "endmenu" block become a submenu of
  238. "Network device support". All subentries inherit the dependencies from
  239. the menu entry, e.g. this means the dependency "NET" is added to the
  240. dependency list of the config option NETDEVICES.
  241. The other way to generate the menu structure is done by analyzing the
  242. dependencies. If a menu entry somehow depends on the previous entry, it
  243. can be made a submenu of it. First, the previous (parent) symbol must
  244. be part of the dependency list and then one of these two conditions
  245. must be true:
  246. - the child entry must become invisible, if the parent is set to 'n'
  247. - the child entry must only be visible, if the parent is visible::
  248. config MODULES
  249. bool "Enable loadable module support"
  250. config MODVERSIONS
  251. bool "Set version information on all module symbols"
  252. depends on MODULES
  253. comment "module support disabled"
  254. depends on !MODULES
  255. MODVERSIONS directly depends on MODULES, this means it's only visible if
  256. MODULES is different from 'n'. The comment on the other hand is only
  257. visible when MODULES is set to 'n'.
  258. Kconfig syntax
  259. --------------
  260. The configuration file describes a series of menu entries, where every
  261. line starts with a keyword (except help texts). The following keywords
  262. end a menu entry:
  263. - config
  264. - menuconfig
  265. - choice/endchoice
  266. - comment
  267. - menu/endmenu
  268. - if/endif
  269. - source
  270. The first five also start the definition of a menu entry.
  271. config::
  272. "config" <symbol>
  273. <config options>
  274. This defines a config symbol <symbol> and accepts any of above
  275. attributes as options.
  276. menuconfig::
  277. "menuconfig" <symbol>
  278. <config options>
  279. This is similar to the simple config entry above, but it also gives a
  280. hint to front ends, that all suboptions should be displayed as a
  281. separate list of options. To make sure all the suboptions will really
  282. show up under the menuconfig entry and not outside of it, every item
  283. from the <config options> list must depend on the menuconfig symbol.
  284. In practice, this is achieved by using one of the next two constructs::
  285. (1):
  286. menuconfig M
  287. if M
  288. config C1
  289. config C2
  290. endif
  291. (2):
  292. menuconfig M
  293. config C1
  294. depends on M
  295. config C2
  296. depends on M
  297. In the following examples (3) and (4), C1 and C2 still have the M
  298. dependency, but will not appear under menuconfig M anymore, because
  299. of C0, which doesn't depend on M::
  300. (3):
  301. menuconfig M
  302. config C0
  303. if M
  304. config C1
  305. config C2
  306. endif
  307. (4):
  308. menuconfig M
  309. config C0
  310. config C1
  311. depends on M
  312. config C2
  313. depends on M
  314. choices::
  315. "choice" [symbol]
  316. <choice options>
  317. <choice block>
  318. "endchoice"
  319. This defines a choice group and accepts any of the above attributes as
  320. options. A choice can only be of type bool or tristate. If no type is
  321. specified for a choice, its type will be determined by the type of
  322. the first choice element in the group or remain unknown if none of the
  323. choice elements have a type specified, as well.
  324. While a boolean choice only allows a single config entry to be
  325. selected, a tristate choice also allows any number of config entries
  326. to be set to 'm'. This can be used if multiple drivers for a single
  327. hardware exists and only a single driver can be compiled/loaded into
  328. the kernel, but all drivers can be compiled as modules.
  329. A choice accepts another option "optional", which allows to set the
  330. choice to 'n' and no entry needs to be selected.
  331. If no [symbol] is associated with a choice, then you can not have multiple
  332. definitions of that choice. If a [symbol] is associated to the choice,
  333. then you may define the same choice (i.e. with the same entries) in another
  334. place.
  335. comment::
  336. "comment" <prompt>
  337. <comment options>
  338. This defines a comment which is displayed to the user during the
  339. configuration process and is also echoed to the output files. The only
  340. possible options are dependencies.
  341. menu::
  342. "menu" <prompt>
  343. <menu options>
  344. <menu block>
  345. "endmenu"
  346. This defines a menu block, see "Menu structure" above for more
  347. information. The only possible options are dependencies and "visible"
  348. attributes.
  349. if::
  350. "if" <expr>
  351. <if block>
  352. "endif"
  353. This defines an if block. The dependency expression <expr> is appended
  354. to all enclosed menu entries.
  355. source::
  356. "source" <prompt>
  357. This reads the specified configuration file. This file is always parsed.
  358. mainmenu::
  359. "mainmenu" <prompt>
  360. This sets the config program's title bar if the config program chooses
  361. to use it. It should be placed at the top of the configuration, before any
  362. other statement.
  363. '#' Kconfig source file comment:
  364. An unquoted '#' character anywhere in a source file line indicates
  365. the beginning of a source file comment. The remainder of that line
  366. is a comment.
  367. Kconfig hints
  368. -------------
  369. This is a collection of Kconfig tips, most of which aren't obvious at
  370. first glance and most of which have become idioms in several Kconfig
  371. files.
  372. Adding common features and make the usage configurable
  373. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  374. It is a common idiom to implement a feature/functionality that are
  375. relevant for some architectures but not all.
  376. The recommended way to do so is to use a config variable named HAVE_*
  377. that is defined in a common Kconfig file and selected by the relevant
  378. architectures.
  379. An example is the generic IOMAP functionality.
  380. We would in lib/Kconfig see::
  381. # Generic IOMAP is used to ...
  382. config HAVE_GENERIC_IOMAP
  383. config GENERIC_IOMAP
  384. depends on HAVE_GENERIC_IOMAP && FOO
  385. And in lib/Makefile we would see::
  386. obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
  387. For each architecture using the generic IOMAP functionality we would see::
  388. config X86
  389. select ...
  390. select HAVE_GENERIC_IOMAP
  391. select ...
  392. Note: we use the existing config option and avoid creating a new
  393. config variable to select HAVE_GENERIC_IOMAP.
  394. Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is
  395. introduced to overcome the limitation of select which will force a
  396. config option to 'y' no matter the dependencies.
  397. The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the
  398. situation where select forces a symbol equals to 'y'.
  399. Adding features that need compiler support
  400. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  401. There are several features that need compiler support. The recommended way
  402. to describe the dependency on the compiler feature is to use "depends on"
  403. followed by a test macro::
  404. config STACKPROTECTOR
  405. bool "Stack Protector buffer overflow detection"
  406. depends on $(cc-option,-fstack-protector)
  407. ...
  408. If you need to expose a compiler capability to makefiles and/or C source files,
  409. `CC_HAS_` is the recommended prefix for the config option::
  410. config CC_HAS_ASM_GOTO
  411. def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
  412. Build as module only
  413. ~~~~~~~~~~~~~~~~~~~~
  414. To restrict a component build to module-only, qualify its config symbol
  415. with "depends on m". E.g.::
  416. config FOO
  417. depends on BAR && m
  418. limits FOO to module (=m) or disabled (=n).
  419. Kconfig recursive dependency limitations
  420. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  421. If you've hit the Kconfig error: "recursive dependency detected" you've run
  422. into a recursive dependency issue with Kconfig, a recursive dependency can be
  423. summarized as a circular dependency. The kconfig tools need to ensure that
  424. Kconfig files comply with specified configuration requirements. In order to do
  425. that kconfig must determine the values that are possible for all Kconfig
  426. symbols, this is currently not possible if there is a circular relation
  427. between two or more Kconfig symbols. For more details refer to the "Simple
  428. Kconfig recursive issue" subsection below. Kconfig does not do recursive
  429. dependency resolution; this has a few implications for Kconfig file writers.
  430. We'll first explain why this issues exists and then provide an example
  431. technical limitation which this brings upon Kconfig developers. Eager
  432. developers wishing to try to address this limitation should read the next
  433. subsections.
  434. Simple Kconfig recursive issue
  435. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  436. Read: Documentation/kbuild/Kconfig.recursion-issue-01
  437. Test with::
  438. make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig
  439. Cumulative Kconfig recursive issue
  440. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  441. Read: Documentation/kbuild/Kconfig.recursion-issue-02
  442. Test with::
  443. make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig
  444. Practical solutions to kconfig recursive issue
  445. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  446. Developers who run into the recursive Kconfig issue have two options
  447. at their disposal. We document them below and also provide a list of
  448. historical issues resolved through these different solutions.
  449. a) Remove any superfluous "select FOO" or "depends on FOO"
  450. b) Match dependency semantics:
  451. b1) Swap all "select FOO" to "depends on FOO" or,
  452. b2) Swap all "depends on FOO" to "select FOO"
  453. The resolution to a) can be tested with the sample Kconfig file
  454. Documentation/kbuild/Kconfig.recursion-issue-01 through the removal
  455. of the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already
  456. since CORE_BELL_A depends on CORE. At times it may not be possible to remove
  457. some dependency criteria, for such cases you can work with solution b).
  458. The two different resolutions for b) can be tested in the sample Kconfig file
  459. Documentation/kbuild/Kconfig.recursion-issue-02.
  460. Below is a list of examples of prior fixes for these types of recursive issues;
  461. all errors appear to involve one or more "select" statements and one or more
  462. "depends on".
  463. ============ ===================================
  464. commit fix
  465. ============ ===================================
  466. 06b718c01208 select A -> depends on A
  467. c22eacfe82f9 depends on A -> depends on B
  468. 6a91e854442c select A -> depends on A
  469. 118c565a8f2e select A -> select B
  470. f004e5594705 select A -> depends on A
  471. c7861f37b4c6 depends on A -> (null)
  472. 80c69915e5fb select A -> (null) (1)
  473. c2218e26c0d0 select A -> depends on A (1)
  474. d6ae99d04e1c select A -> depends on A
  475. 95ca19cf8cbf select A -> depends on A
  476. 8f057d7bca54 depends on A -> (null)
  477. 8f057d7bca54 depends on A -> select A
  478. a0701f04846e select A -> depends on A
  479. 0c8b92f7f259 depends on A -> (null)
  480. e4e9e0540928 select A -> depends on A (2)
  481. 7453ea886e87 depends on A > (null) (1)
  482. 7b1fff7e4fdf select A -> depends on A
  483. 86c747d2a4f0 select A -> depends on A
  484. d9f9ab51e55e select A -> depends on A
  485. 0c51a4d8abd6 depends on A -> select A (3)
  486. e98062ed6dc4 select A -> depends on A (3)
  487. 91e5d284a7f1 select A -> (null)
  488. ============ ===================================
  489. (1) Partial (or no) quote of error.
  490. (2) That seems to be the gist of that fix.
  491. (3) Same error.
  492. Future kconfig work
  493. ~~~~~~~~~~~~~~~~~~~
  494. Work on kconfig is welcomed on both areas of clarifying semantics and on
  495. evaluating the use of a full SAT solver for it. A full SAT solver can be
  496. desirable to enable more complex dependency mappings and / or queries,
  497. for instance on possible use case for a SAT solver could be that of handling
  498. the current known recursive dependency issues. It is not known if this would
  499. address such issues but such evaluation is desirable. If support for a full SAT
  500. solver proves too complex or that it cannot address recursive dependency issues
  501. Kconfig should have at least clear and well defined semantics which also
  502. addresses and documents limitations or requirements such as the ones dealing
  503. with recursive dependencies.
  504. Further work on both of these areas is welcomed on Kconfig. We elaborate
  505. on both of these in the next two subsections.
  506. Semantics of Kconfig
  507. ~~~~~~~~~~~~~~~~~~~~
  508. The use of Kconfig is broad, Linux is now only one of Kconfig's users:
  509. one study has completed a broad analysis of Kconfig use in 12 projects [0]_.
  510. Despite its widespread use, and although this document does a reasonable job
  511. in documenting basic Kconfig syntax a more precise definition of Kconfig
  512. semantics is welcomed. One project deduced Kconfig semantics through
  513. the use of the xconfig configurator [1]_. Work should be done to confirm if
  514. the deduced semantics matches our intended Kconfig design goals.
  515. Having well defined semantics can be useful for tools for practical
  516. evaluation of dependencies, for instance one such case was work to
  517. express in boolean abstraction of the inferred semantics of Kconfig to
  518. translate Kconfig logic into boolean formulas and run a SAT solver on this to
  519. find dead code / features (always inactive), 114 dead features were found in
  520. Linux using this methodology [1]_ (Section 8: Threats to validity).
  521. Confirming this could prove useful as Kconfig stands as one of the leading
  522. industrial variability modeling languages [1]_ [2]_. Its study would help
  523. evaluate practical uses of such languages, their use was only theoretical
  524. and real world requirements were not well understood. As it stands though
  525. only reverse engineering techniques have been used to deduce semantics from
  526. variability modeling languages such as Kconfig [3]_.
  527. .. [0] https://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf
  528. .. [1] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
  529. .. [2] https://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf
  530. .. [3] https://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf
  531. Full SAT solver for Kconfig
  532. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  533. Although SAT solvers [4]_ haven't yet been used by Kconfig directly, as noted
  534. in the previous subsection, work has been done however to express in boolean
  535. abstraction the inferred semantics of Kconfig to translate Kconfig logic into
  536. boolean formulas and run a SAT solver on it [5]_. Another known related project
  537. is CADOS [6]_ (former VAMOS [7]_) and the tools, mainly undertaker [8]_, which
  538. has been introduced first with [9]_. The basic concept of undertaker is to
  539. extract variability models from Kconfig and put them together with a
  540. propositional formula extracted from CPP #ifdefs and build-rules into a SAT
  541. solver in order to find dead code, dead files, and dead symbols. If using a SAT
  542. solver is desirable on Kconfig one approach would be to evaluate repurposing
  543. such efforts somehow on Kconfig. There is enough interest from mentors of
  544. existing projects to not only help advise how to integrate this work upstream
  545. but also help maintain it long term. Interested developers should visit:
  546. https://kernelnewbies.org/KernelProjects/kconfig-sat
  547. .. [4] https://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf
  548. .. [5] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
  549. .. [6] https://cados.cs.fau.de
  550. .. [7] https://vamos.cs.fau.de
  551. .. [8] https://undertaker.cs.fau.de
  552. .. [9] https://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf