kconfig-language.rst 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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 m 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. - module attribute: "modules"
  172. This declares the symbol to be used as the MODULES symbol, which
  173. enables the third modular state for all config symbols.
  174. At most one symbol may have the "modules" option set.
  175. Menu dependencies
  176. -----------------
  177. Dependencies define the visibility of a menu entry and can also reduce
  178. the input range of tristate symbols. The tristate logic used in the
  179. expressions uses one more state than normal boolean logic to express the
  180. module state. Dependency expressions have the following syntax::
  181. <expr> ::= <symbol> (1)
  182. <symbol> '=' <symbol> (2)
  183. <symbol> '!=' <symbol> (3)
  184. <symbol1> '<' <symbol2> (4)
  185. <symbol1> '>' <symbol2> (4)
  186. <symbol1> '<=' <symbol2> (4)
  187. <symbol1> '>=' <symbol2> (4)
  188. '(' <expr> ')' (5)
  189. '!' <expr> (6)
  190. <expr> '&&' <expr> (7)
  191. <expr> '||' <expr> (8)
  192. Expressions are listed in decreasing order of precedence.
  193. (1) Convert the symbol into an expression. Boolean and tristate symbols
  194. are simply converted into the respective expression values. All
  195. other symbol types result in 'n'.
  196. (2) If the values of both symbols are equal, it returns 'y',
  197. otherwise 'n'.
  198. (3) If the values of both symbols are equal, it returns 'n',
  199. otherwise 'y'.
  200. (4) If value of <symbol1> is respectively lower, greater, lower-or-equal,
  201. or greater-or-equal than value of <symbol2>, it returns 'y',
  202. otherwise 'n'.
  203. (5) Returns the value of the expression. Used to override precedence.
  204. (6) Returns the result of (2-/expr/).
  205. (7) Returns the result of min(/expr/, /expr/).
  206. (8) Returns the result of max(/expr/, /expr/).
  207. An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
  208. respectively for calculations). A menu entry becomes visible when its
  209. expression evaluates to 'm' or 'y'.
  210. There are two types of symbols: constant and non-constant symbols.
  211. Non-constant symbols are the most common ones and are defined with the
  212. 'config' statement. Non-constant symbols consist entirely of alphanumeric
  213. characters or underscores.
  214. Constant symbols are only part of expressions. Constant symbols are
  215. always surrounded by single or double quotes. Within the quote, any
  216. other character is allowed and the quotes can be escaped using '\'.
  217. Menu structure
  218. --------------
  219. The position of a menu entry in the tree is determined in two ways. First
  220. it can be specified explicitly::
  221. menu "Network device support"
  222. depends on NET
  223. config NETDEVICES
  224. ...
  225. endmenu
  226. All entries within the "menu" ... "endmenu" block become a submenu of
  227. "Network device support". All subentries inherit the dependencies from
  228. the menu entry, e.g. this means the dependency "NET" is added to the
  229. dependency list of the config option NETDEVICES.
  230. The other way to generate the menu structure is done by analyzing the
  231. dependencies. If a menu entry somehow depends on the previous entry, it
  232. can be made a submenu of it. First, the previous (parent) symbol must
  233. be part of the dependency list and then one of these two conditions
  234. must be true:
  235. - the child entry must become invisible, if the parent is set to 'n'
  236. - the child entry must only be visible, if the parent is visible::
  237. config MODULES
  238. bool "Enable loadable module support"
  239. config MODVERSIONS
  240. bool "Set version information on all module symbols"
  241. depends on MODULES
  242. comment "module support disabled"
  243. depends on !MODULES
  244. MODVERSIONS directly depends on MODULES, this means it's only visible if
  245. MODULES is different from 'n'. The comment on the other hand is only
  246. visible when MODULES is set to 'n'.
  247. Kconfig syntax
  248. --------------
  249. The configuration file describes a series of menu entries, where every
  250. line starts with a keyword (except help texts). The following keywords
  251. end a menu entry:
  252. - config
  253. - menuconfig
  254. - choice/endchoice
  255. - comment
  256. - menu/endmenu
  257. - if/endif
  258. - source
  259. The first five also start the definition of a menu entry.
  260. config::
  261. "config" <symbol>
  262. <config options>
  263. This defines a config symbol <symbol> and accepts any of above
  264. attributes as options.
  265. menuconfig::
  266. "menuconfig" <symbol>
  267. <config options>
  268. This is similar to the simple config entry above, but it also gives a
  269. hint to front ends, that all suboptions should be displayed as a
  270. separate list of options. To make sure all the suboptions will really
  271. show up under the menuconfig entry and not outside of it, every item
  272. from the <config options> list must depend on the menuconfig symbol.
  273. In practice, this is achieved by using one of the next two constructs::
  274. (1):
  275. menuconfig M
  276. if M
  277. config C1
  278. config C2
  279. endif
  280. (2):
  281. menuconfig M
  282. config C1
  283. depends on M
  284. config C2
  285. depends on M
  286. In the following examples (3) and (4), C1 and C2 still have the M
  287. dependency, but will not appear under menuconfig M anymore, because
  288. of C0, which doesn't depend on M::
  289. (3):
  290. menuconfig M
  291. config C0
  292. if M
  293. config C1
  294. config C2
  295. endif
  296. (4):
  297. menuconfig M
  298. config C0
  299. config C1
  300. depends on M
  301. config C2
  302. depends on M
  303. choices::
  304. "choice" [symbol]
  305. <choice options>
  306. <choice block>
  307. "endchoice"
  308. This defines a choice group and accepts any of the above attributes as
  309. options. A choice can only be of type bool or tristate. If no type is
  310. specified for a choice, its type will be determined by the type of
  311. the first choice element in the group or remain unknown if none of the
  312. choice elements have a type specified, as well.
  313. While a boolean choice only allows a single config entry to be
  314. selected, a tristate choice also allows any number of config entries
  315. to be set to 'm'. This can be used if multiple drivers for a single
  316. hardware exists and only a single driver can be compiled/loaded into
  317. the kernel, but all drivers can be compiled as modules.
  318. A choice accepts another option "optional", which allows to set the
  319. choice to 'n' and no entry needs to be selected.
  320. If no [symbol] is associated with a choice, then you can not have multiple
  321. definitions of that choice. If a [symbol] is associated to the choice,
  322. then you may define the same choice (i.e. with the same entries) in another
  323. place.
  324. comment::
  325. "comment" <prompt>
  326. <comment options>
  327. This defines a comment which is displayed to the user during the
  328. configuration process and is also echoed to the output files. The only
  329. possible options are dependencies.
  330. menu::
  331. "menu" <prompt>
  332. <menu options>
  333. <menu block>
  334. "endmenu"
  335. This defines a menu block, see "Menu structure" above for more
  336. information. The only possible options are dependencies and "visible"
  337. attributes.
  338. if::
  339. "if" <expr>
  340. <if block>
  341. "endif"
  342. This defines an if block. The dependency expression <expr> is appended
  343. to all enclosed menu entries.
  344. source::
  345. "source" <prompt>
  346. This reads the specified configuration file. This file is always parsed.
  347. mainmenu::
  348. "mainmenu" <prompt>
  349. This sets the config program's title bar if the config program chooses
  350. to use it. It should be placed at the top of the configuration, before any
  351. other statement.
  352. '#' Kconfig source file comment:
  353. An unquoted '#' character anywhere in a source file line indicates
  354. the beginning of a source file comment. The remainder of that line
  355. is a comment.
  356. Kconfig hints
  357. -------------
  358. This is a collection of Kconfig tips, most of which aren't obvious at
  359. first glance and most of which have become idioms in several Kconfig
  360. files.
  361. Adding common features and make the usage configurable
  362. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  363. It is a common idiom to implement a feature/functionality that are
  364. relevant for some architectures but not all.
  365. The recommended way to do so is to use a config variable named HAVE_*
  366. that is defined in a common Kconfig file and selected by the relevant
  367. architectures.
  368. An example is the generic IOMAP functionality.
  369. We would in lib/Kconfig see::
  370. # Generic IOMAP is used to ...
  371. config HAVE_GENERIC_IOMAP
  372. config GENERIC_IOMAP
  373. depends on HAVE_GENERIC_IOMAP && FOO
  374. And in lib/Makefile we would see::
  375. obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
  376. For each architecture using the generic IOMAP functionality we would see::
  377. config X86
  378. select ...
  379. select HAVE_GENERIC_IOMAP
  380. select ...
  381. Note: we use the existing config option and avoid creating a new
  382. config variable to select HAVE_GENERIC_IOMAP.
  383. Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is
  384. introduced to overcome the limitation of select which will force a
  385. config option to 'y' no matter the dependencies.
  386. The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the
  387. situation where select forces a symbol equals to 'y'.
  388. Adding features that need compiler support
  389. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  390. There are several features that need compiler support. The recommended way
  391. to describe the dependency on the compiler feature is to use "depends on"
  392. followed by a test macro::
  393. config STACKPROTECTOR
  394. bool "Stack Protector buffer overflow detection"
  395. depends on $(cc-option,-fstack-protector)
  396. ...
  397. If you need to expose a compiler capability to makefiles and/or C source files,
  398. `CC_HAS_` is the recommended prefix for the config option::
  399. config CC_HAS_FOO
  400. def_bool $(success,$(srctree)/scripts/cc-check-foo.sh $(CC))
  401. Build as module only
  402. ~~~~~~~~~~~~~~~~~~~~
  403. To restrict a component build to module-only, qualify its config symbol
  404. with "depends on m". E.g.::
  405. config FOO
  406. depends on BAR && m
  407. limits FOO to module (=m) or disabled (=n).
  408. Compile-testing
  409. ~~~~~~~~~~~~~~~
  410. If a config symbol has a dependency, but the code controlled by the config
  411. symbol can still be compiled if the dependency is not met, it is encouraged to
  412. increase build coverage by adding an "|| COMPILE_TEST" clause to the
  413. dependency. This is especially useful for drivers for more exotic hardware, as
  414. it allows continuous-integration systems to compile-test the code on a more
  415. common system, and detect bugs that way.
  416. Note that compile-tested code should avoid crashing when run on a system where
  417. the dependency is not met.
  418. Architecture and platform dependencies
  419. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  420. Due to the presence of stubs, most drivers can now be compiled on most
  421. architectures. However, this does not mean it makes sense to have all drivers
  422. available everywhere, as the actual hardware may only exist on specific
  423. architectures and platforms. This is especially true for on-SoC IP cores,
  424. which may be limited to a specific vendor or SoC family.
  425. To prevent asking the user about drivers that cannot be used on the system(s)
  426. the user is compiling a kernel for, and if it makes sense, config symbols
  427. controlling the compilation of a driver should contain proper dependencies,
  428. limiting the visibility of the symbol to (a superset of) the platform(s) the
  429. driver can be used on. The dependency can be an architecture (e.g. ARM) or
  430. platform (e.g. ARCH_OMAP4) dependency. This makes life simpler not only for
  431. distro config owners, but also for every single developer or user who
  432. configures a kernel.
  433. Such a dependency can be relaxed by combining it with the compile-testing rule
  434. above, leading to:
  435. config FOO
  436. bool "Support for foo hardware"
  437. depends on ARCH_FOO_VENDOR || COMPILE_TEST
  438. Kconfig recursive dependency limitations
  439. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  440. If you've hit the Kconfig error: "recursive dependency detected" you've run
  441. into a recursive dependency issue with Kconfig, a recursive dependency can be
  442. summarized as a circular dependency. The kconfig tools need to ensure that
  443. Kconfig files comply with specified configuration requirements. In order to do
  444. that kconfig must determine the values that are possible for all Kconfig
  445. symbols, this is currently not possible if there is a circular relation
  446. between two or more Kconfig symbols. For more details refer to the "Simple
  447. Kconfig recursive issue" subsection below. Kconfig does not do recursive
  448. dependency resolution; this has a few implications for Kconfig file writers.
  449. We'll first explain why this issues exists and then provide an example
  450. technical limitation which this brings upon Kconfig developers. Eager
  451. developers wishing to try to address this limitation should read the next
  452. subsections.
  453. Simple Kconfig recursive issue
  454. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  455. Read: Documentation/kbuild/Kconfig.recursion-issue-01
  456. Test with::
  457. make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig
  458. Cumulative Kconfig recursive issue
  459. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  460. Read: Documentation/kbuild/Kconfig.recursion-issue-02
  461. Test with::
  462. make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig
  463. Practical solutions to kconfig recursive issue
  464. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  465. Developers who run into the recursive Kconfig issue have two options
  466. at their disposal. We document them below and also provide a list of
  467. historical issues resolved through these different solutions.
  468. a) Remove any superfluous "select FOO" or "depends on FOO"
  469. b) Match dependency semantics:
  470. b1) Swap all "select FOO" to "depends on FOO" or,
  471. b2) Swap all "depends on FOO" to "select FOO"
  472. The resolution to a) can be tested with the sample Kconfig file
  473. Documentation/kbuild/Kconfig.recursion-issue-01 through the removal
  474. of the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already
  475. since CORE_BELL_A depends on CORE. At times it may not be possible to remove
  476. some dependency criteria, for such cases you can work with solution b).
  477. The two different resolutions for b) can be tested in the sample Kconfig file
  478. Documentation/kbuild/Kconfig.recursion-issue-02.
  479. Below is a list of examples of prior fixes for these types of recursive issues;
  480. all errors appear to involve one or more "select" statements and one or more
  481. "depends on".
  482. ============ ===================================
  483. commit fix
  484. ============ ===================================
  485. 06b718c01208 select A -> depends on A
  486. c22eacfe82f9 depends on A -> depends on B
  487. 6a91e854442c select A -> depends on A
  488. 118c565a8f2e select A -> select B
  489. f004e5594705 select A -> depends on A
  490. c7861f37b4c6 depends on A -> (null)
  491. 80c69915e5fb select A -> (null) (1)
  492. c2218e26c0d0 select A -> depends on A (1)
  493. d6ae99d04e1c select A -> depends on A
  494. 95ca19cf8cbf select A -> depends on A
  495. 8f057d7bca54 depends on A -> (null)
  496. 8f057d7bca54 depends on A -> select A
  497. a0701f04846e select A -> depends on A
  498. 0c8b92f7f259 depends on A -> (null)
  499. e4e9e0540928 select A -> depends on A (2)
  500. 7453ea886e87 depends on A > (null) (1)
  501. 7b1fff7e4fdf select A -> depends on A
  502. 86c747d2a4f0 select A -> depends on A
  503. d9f9ab51e55e select A -> depends on A
  504. 0c51a4d8abd6 depends on A -> select A (3)
  505. e98062ed6dc4 select A -> depends on A (3)
  506. 91e5d284a7f1 select A -> (null)
  507. ============ ===================================
  508. (1) Partial (or no) quote of error.
  509. (2) That seems to be the gist of that fix.
  510. (3) Same error.
  511. Future kconfig work
  512. ~~~~~~~~~~~~~~~~~~~
  513. Work on kconfig is welcomed on both areas of clarifying semantics and on
  514. evaluating the use of a full SAT solver for it. A full SAT solver can be
  515. desirable to enable more complex dependency mappings and / or queries,
  516. for instance one possible use case for a SAT solver could be that of handling
  517. the current known recursive dependency issues. It is not known if this would
  518. address such issues but such evaluation is desirable. If support for a full SAT
  519. solver proves too complex or that it cannot address recursive dependency issues
  520. Kconfig should have at least clear and well defined semantics which also
  521. addresses and documents limitations or requirements such as the ones dealing
  522. with recursive dependencies.
  523. Further work on both of these areas is welcomed on Kconfig. We elaborate
  524. on both of these in the next two subsections.
  525. Semantics of Kconfig
  526. ~~~~~~~~~~~~~~~~~~~~
  527. The use of Kconfig is broad, Linux is now only one of Kconfig's users:
  528. one study has completed a broad analysis of Kconfig use in 12 projects [0]_.
  529. Despite its widespread use, and although this document does a reasonable job
  530. in documenting basic Kconfig syntax a more precise definition of Kconfig
  531. semantics is welcomed. One project deduced Kconfig semantics through
  532. the use of the xconfig configurator [1]_. Work should be done to confirm if
  533. the deduced semantics matches our intended Kconfig design goals.
  534. Another project formalized a denotational semantics of a core subset of
  535. the Kconfig language [10]_.
  536. Having well defined semantics can be useful for tools for practical
  537. evaluation of dependencies, for instance one such case was work to
  538. express in boolean abstraction of the inferred semantics of Kconfig to
  539. translate Kconfig logic into boolean formulas and run a SAT solver on this to
  540. find dead code / features (always inactive), 114 dead features were found in
  541. Linux using this methodology [1]_ (Section 8: Threats to validity).
  542. The kismet tool, based on the semantics in [10]_, finds abuses of reverse
  543. dependencies and has led to dozens of committed fixes to Linux Kconfig files [11]_.
  544. Confirming this could prove useful as Kconfig stands as one of the leading
  545. industrial variability modeling languages [1]_ [2]_. Its study would help
  546. evaluate practical uses of such languages, their use was only theoretical
  547. and real world requirements were not well understood. As it stands though
  548. only reverse engineering techniques have been used to deduce semantics from
  549. variability modeling languages such as Kconfig [3]_.
  550. .. [0] https://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf
  551. .. [1] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
  552. .. [2] https://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf
  553. .. [3] https://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf
  554. Full SAT solver for Kconfig
  555. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  556. Although SAT solvers [4]_ haven't yet been used by Kconfig directly, as noted
  557. in the previous subsection, work has been done however to express in boolean
  558. abstraction the inferred semantics of Kconfig to translate Kconfig logic into
  559. boolean formulas and run a SAT solver on it [5]_. Another known related project
  560. is CADOS [6]_ (former VAMOS [7]_) and the tools, mainly undertaker [8]_, which
  561. has been introduced first with [9]_. The basic concept of undertaker is to
  562. extract variability models from Kconfig and put them together with a
  563. propositional formula extracted from CPP #ifdefs and build-rules into a SAT
  564. solver in order to find dead code, dead files, and dead symbols. If using a SAT
  565. solver is desirable on Kconfig one approach would be to evaluate repurposing
  566. such efforts somehow on Kconfig. There is enough interest from mentors of
  567. existing projects to not only help advise how to integrate this work upstream
  568. but also help maintain it long term. Interested developers should visit:
  569. https://kernelnewbies.org/KernelProjects/kconfig-sat
  570. .. [4] https://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf
  571. .. [5] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
  572. .. [6] https://cados.cs.fau.de
  573. .. [7] https://vamos.cs.fau.de
  574. .. [8] https://undertaker.cs.fau.de
  575. .. [9] https://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf
  576. .. [10] https://paulgazzillo.com/papers/esecfse21.pdf
  577. .. [11] https://github.com/paulgazz/kmax