History

Merge tag 'kbuild-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada: - Generate a list of built DTB files (arch/*/boot/dts/dtbs-list) - Use more threads when building Debian packages in parallel - Fix warnings shown during the RPM kernel package uninstallation - Change OBJECT_FILES_NON_STANDARD_*.o etc. to take a relative path to Makefile - Support GCC's -fmin-function-alignment flag - Fix a null pointer dereference bug in modpost - Add the DTB support to the RPM package - Various fixes and cleanups in Kconfig * tag 'kbuild-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (67 commits) kconfig: tests: test dependency after shuffling choices kconfig: tests: add a test for randconfig with dependent choices kconfig: tests: support KCONFIG_SEED for the randconfig runner kbuild: rpm-pkg: add dtb files in kernel rpm kconfig: remove unneeded menu_is_visible() call in conf_write_defconfig() kconfig: check prompt for choice while parsing kconfig: lxdialog: remove unused dialog colors kconfig: lxdialog: fix button color for blackbg theme modpost: fix null pointer dereference kbuild: remove GCC's default -Wpacked-bitfield-compat flag kbuild: unexport abs_srctree and abs_objtree kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1 kconfig: remove named choice support kconfig: use linked list in get_symbol_str() to iterate over menus kconfig: link menus to a symbol kbuild: fix inconsistent indentation in top Makefile kbuild: Use -fmin-function-alignment when available alpha: merge two entries for CONFIG_ALPHA_GAMMA alpha: merge two entries for CONFIG_ALPHA_EV4 kbuild: change DTC_FLAGS_<basetarget>.o to take the path relative to $(obj) ...

Linus Torvalds committed 2 years ago

Commit 1d35aae2 parents 88d92fb f2fd2aa69 files · +1133 −792Browse files

Unified · Split

69 files
  1. .gitignore +1 −0
  2. Documentation/kbuild/kconfig-language.rst +1 −5
  3. Documentation/kbuild/kconfig.rst +166 −197
  4. Makefile +28 −21
  5. arch/Kconfig +12 −0
  6. arch/alpha/Kconfig +4 −11
  7. arch/hexagon/Kconfig +3 −9
  8. arch/parisc/Kconfig +2 −2
  9. arch/riscv/kernel/tests/Kconfig.debug +1 −1
  10. arch/x86/entry/vdso/Makefile +2 −0
  11. arch/x86/kvm/Kconfig +1 −1
  12. arch/x86/kvm/Makefile +2 −1
  13. arch/x86/xen/Kconfig +0 −1
  14. drivers/acpi/Kconfig +0 −1
  15. drivers/iommu/intel/Kconfig +1 −1
  16. drivers/md/Kconfig +0 −1
  17. include/linux/compiler_types.h +5 −5
  18. init/Kconfig +1 −1
  19. kernel/module/Kconfig +1 −2
  20. lib/Kconfig.debug +1 −1
  21. mm/Kconfig +3 −4
  22. net/dccp/ccids/Kconfig +1 −1
  23. rust/Makefile +2 −2
  24. scripts/Kbuild.include +0 −6
  25. scripts/Makefile.build +13 −9
  26. scripts/Makefile.dtbinst +18 −14
  27. scripts/Makefile.extrawarn +2 −1
  28. scripts/Makefile.lib +16 −10
  29. scripts/Makefile.package +1 −1
  30. scripts/kconfig/array_size.h +11 −0
  31. scripts/kconfig/conf.c +6 −6
  32. scripts/kconfig/confdata.c +18 −78
  33. scripts/kconfig/expr.h +11 −18
  34. scripts/kconfig/hashtable.h +48 −0
  35. scripts/kconfig/internal.h +12 −0
  36. scripts/kconfig/lexer.l +61 −69
  37. scripts/kconfig/list.h +189 −65
  38. scripts/kconfig/list_types.h +17 −0
  39. scripts/kconfig/lkc.h +3 −3
  40. scripts/kconfig/lkc_proto.h +0 −15
  41. scripts/kconfig/lxdialog/checklist.c +2 −3
  42. scripts/kconfig/lxdialog/dialog.h +0 −4
  43. scripts/kconfig/lxdialog/util.c +1 −19
  44. scripts/kconfig/mconf.c +1 −0
  45. scripts/kconfig/menu.c +20 −28
  46. scripts/kconfig/nconf.c +1 −0
  47. scripts/kconfig/parser.y +76 −49
  48. scripts/kconfig/preprocess.c +13 −10
  49. scripts/kconfig/preprocess.h +19 −0
  50. scripts/kconfig/qconf.cc +1 −1
  51. scripts/kconfig/symbol.c +22 −27
  52. scripts/kconfig/tests/choice_randomize/Kconfig +22 −0
  53. scripts/kconfig/tests/choice_randomize/__init__.py +34 −0
  54. scripts/kconfig/tests/choice_randomize/expected_config0 +6 −0
  55. scripts/kconfig/tests/choice_randomize/expected_config1 +8 −0
  56. scripts/kconfig/tests/choice_randomize/expected_config2 +8 −0
  57. scripts/kconfig/tests/choice_randomize2/Kconfig +32 −0
  58. scripts/kconfig/tests/choice_randomize2/__init__.py +18 −0
  59. scripts/kconfig/tests/choice_randomize2/expected_config0 +8 −0
  60. scripts/kconfig/tests/choice_randomize2/expected_config1 +7 −0
  61. scripts/kconfig/tests/choice_randomize2/expected_config2 +6 −0
  62. scripts/kconfig/tests/conftest.py +10 −6
  63. scripts/kconfig/tests/err_recursive_dep/expected_stderr +11 −11
  64. scripts/kconfig/util.c +36 −11
  65. scripts/mod/modpost.c +3 −1
  66. scripts/package/builddeb +12 −38
  67. scripts/package/debian/rules +54 −9
  68. scripts/package/kernel.spec +37 −11
  69. tools/lib/bpf/Makefile +1 −1
.gitignore+1−0
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 *.xz
5353 *.zst
5454 Module.symvers
55+dtbs-list
5556 modules.order
5657
5758 #
Documentation/kbuild/kconfig-language.rst+1−5
@@ -393,7 +393,7 @@ of C0, which doesn't depend on M:: · 392 unmodified lines
393393
394394 choices::
395395
396− "choice" [symbol]
396+ "choice"
397397 <choice options>
398398 <choice block>
399399 "endchoice"
@@ -412,10 +412,6 @@ the kernel, but all drivers can be compiled as modules. · 12 unmodified lines
412412
413413 A choice accepts another option "optional", which allows to set the
414414 choice to 'n' and no entry needs to be selected.
415−If no [symbol] is associated with a choice, then you can not have multiple
416−definitions of that choice. If a [symbol] is associated to the choice,
417−then you may define the same choice (i.e. with the same entries) in another
418−place.
419415
420416 comment::
421417
Documentation/kbuild/kconfig.rst+166−197
@@ -1,10 +1,10 @@
1−===================
2−Kconfig make config
3−===================
1+=================================
2+Configuration targets and editors
3+=================================
44
5−This file contains some assistance for using `make *config`.
5+This file contains some assistance for using ``make *config``.
66
7−Use "make help" to list all of the possible configuration targets.
7+Use ``make help`` to list all of the possible configuration targets.
88
99 The xconfig ('qconf'), menuconfig ('mconf'), and nconfig ('nconf')
1010 programs also have embedded help text. Be sure to check that for
@@ -12,8 +12,9 @@ navigation, search, and other general help text. · 1 unmodified line
1212
1313 The gconfig ('gconf') program has limited help text.
1414
15+
1516 General
16−-------
17+=======
1718
1819 New kernel releases often introduce new config symbols. Often more
1920 important, new kernel releases may rename config symbols. When
@@ -24,118 +25,102 @@ symbols have been introduced. · 4 unmodified lines
2425
2526 To see a list of new config symbols, use::
2627
27− cp user/some/old.config .config
28− make listnewconfig
28+ cp user/some/old.config .config
29+ make listnewconfig
2930
3031 and the config program will list any new symbols, one per line.
3132
3233 Alternatively, you can use the brute force method::
3334
34− make oldconfig
35− scripts/diffconfig .config.old .config | less
36−
37−----------------------------------------------------------------------
38−
39−Environment variables for `*config`
35+ make oldconfig
36+ scripts/diffconfig .config.old .config | less
4037
41−KCONFIG_CONFIG
42−--------------
43−This environment variable can be used to specify a default kernel config
44−file name to override the default name of ".config".
4538
46−KCONFIG_DEFCONFIG_LIST
47−----------------------
39+Environment variables
40+=====================
4841
49−This environment variable specifies a list of config files which can be used
50−as a base configuration in case the .config does not exist yet. Entries in
51−the list are separated with whitespaces to each other, and the first one
52−that exists is used.
42+Environment variables for ``*config``:
5343
54−KCONFIG_OVERWRITECONFIG
55−-----------------------
56−If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
57−break symlinks when .config is a symlink to somewhere else.
44+``KCONFIG_CONFIG``
45+ This environment variable can be used to specify a default kernel config
46+ file name to override the default name of ".config".
5847
59−KCONFIG_WARN_UNKNOWN_SYMBOLS
60−----------------------------
61−This environment variable makes Kconfig warn about all unrecognized
62−symbols in the config input.
48+``KCONFIG_DEFCONFIG_LIST``
49+ This environment variable specifies a list of config files which can be
50+ used as a base configuration in case the .config does not exist yet.
51+ Entries in the list are separated with whitespaces to each other, and
52+ the first one that exists is used.
6353
64−KCONFIG_WERROR
65−--------------
66−If set, Kconfig treats warnings as errors.
54+``KCONFIG_OVERWRITECONFIG``
55+ If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
56+ break symlinks when .config is a symlink to somewhere else.
6757
68−`CONFIG_`
69−---------
70−If you set `CONFIG_` in the environment, Kconfig will prefix all symbols
71−with its value when saving the configuration, instead of using the default,
72−`CONFIG_`.
58+``KCONFIG_WARN_UNKNOWN_SYMBOLS``
59+ This environment variable makes Kconfig warn about all unrecognized
60+ symbols in the config input.
7361
74−----------------------------------------------------------------------
62+``KCONFIG_WERROR``
63+ If set, Kconfig treats warnings as errors.
7564
76−Environment variables for '{allyes/allmod/allno/rand}config'
65+``CONFIG_``
66+ If you set ``CONFIG_`` in the environment, Kconfig will prefix all symbols
67+ with its value when saving the configuration, instead of using the
68+ default, ``CONFIG_``.
7769
78−KCONFIG_ALLCONFIG
79−-----------------
80−(partially based on lkml email from/by Rob Landley, re: miniconfig)
70+Environment variables for ``{allyes/allmod/allno/rand}config``:
8171
82−--------------------------------------------------
72+``KCONFIG_ALLCONFIG``
73+ The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also
74+ use the environment variable KCONFIG_ALLCONFIG as a flag or a filename
75+ that contains config symbols that the user requires to be set to a
76+ specific value. If KCONFIG_ALLCONFIG is used without a filename where
77+ KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", ``make *config``
78+ checks for a file named "all{yes/mod/no/def/random}.config"
79+ (corresponding to the ``*config`` command that was used) for symbol values
80+ that are to be forced. If this file is not found, it checks for a
81+ file named "all.config" to contain forced values.
8382
84−The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also
85−use the environment variable KCONFIG_ALLCONFIG as a flag or a filename
86−that contains config symbols that the user requires to be set to a
87−specific value. If KCONFIG_ALLCONFIG is used without a filename where
88−KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", `make *config`
89−checks for a file named "all{yes/mod/no/def/random}.config"
90−(corresponding to the `*config` command that was used) for symbol values
91−that are to be forced. If this file is not found, it checks for a
92−file named "all.config" to contain forced values.
83+ This enables you to create "miniature" config (miniconfig) or custom
84+ config files containing just the config symbols that you are interested
85+ in. Then the kernel config system generates the full .config file,
86+ including symbols of your miniconfig file.
9387
94−This enables you to create "miniature" config (miniconfig) or custom
95−config files containing just the config symbols that you are interested
96−in. Then the kernel config system generates the full .config file,
97−including symbols of your miniconfig file.
98−
99−This 'KCONFIG_ALLCONFIG' file is a config file which contains
100−(usually a subset of all) preset config symbols. These variable
101−settings are still subject to normal dependency checks.
102−
103−Examples::
88+ This ``KCONFIG_ALLCONFIG`` file is a config file which contains
89+ (usually a subset of all) preset config symbols. These variable
90+ settings are still subject to normal dependency checks.
10491
105− KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig
92+ Examples::
10693
107−or::
94+ KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig
10895
109− KCONFIG_ALLCONFIG=mini.config make allnoconfig
96+ or::
11097
111−or::
98+ KCONFIG_ALLCONFIG=mini.config make allnoconfig
11299
113− make KCONFIG_ALLCONFIG=mini.config allnoconfig
100+ or::
114101
115−These examples will disable most options (allnoconfig) but enable or
116−disable the options that are explicitly listed in the specified
117−mini-config files.
102+ make KCONFIG_ALLCONFIG=mini.config allnoconfig
118103
119−----------------------------------------------------------------------
104+ These examples will disable most options (allnoconfig) but enable or
105+ disable the options that are explicitly listed in the specified
106+ mini-config files.
120107
121−Environment variables for 'randconfig'
108+Environment variables for ``randconfig``:
122109
123−KCONFIG_SEED
124−------------
125−You can set this to the integer value used to seed the RNG, if you want
126−to somehow debug the behaviour of the kconfig parser/frontends.
127−If not set, the current time will be used.
110+``KCONFIG_SEED``
111+ You can set this to the integer value used to seed the RNG, if you want
112+ to somehow debug the behaviour of the kconfig parser/frontends.
113+ If not set, the current time will be used.
128114
129−KCONFIG_PROBABILITY
130−-------------------
131−This variable can be used to skew the probabilities. This variable can
132−be unset or empty, or set to three different formats:
115+``KCONFIG_PROBABILITY``
116+ This variable can be used to skew the probabilities. This variable can
117+ be unset or empty, or set to three different formats:
133118
134119 ======================= ================== =====================
135− KCONFIG_PROBABILITY y:n split y:m:n split
120+ KCONFIG_PROBABILITY y:n split y:m:n split
136121 ======================= ================== =====================
137− unset or empty 50 : 50 33 : 33 : 34
138− N N : 100-N N/2 : N/2 : 100-N
122+ unset or empty 50 : 50 33 : 33 : 34
123+ N N : 100-N N/2 : N/2 : 100-N
139124 [1] N:M N+M : 100-(N+M) N : M : 100-(N+M)
140125 [2] N:M:L N : 100-N M : L : 100-(M+L)
141126 ======================= ================== =====================
@@ -149,112 +134,98 @@ that: · 7 unmodified lines
149134
150135 Examples::
151136
152− KCONFIG_PROBABILITY=10
153− 10% of booleans will be set to 'y', 90% to 'n'
154− 5% of tristates will be set to 'y', 5% to 'm', 90% to 'n'
155− KCONFIG_PROBABILITY=15:25
156− 40% of booleans will be set to 'y', 60% to 'n'
157− 15% of tristates will be set to 'y', 25% to 'm', 60% to 'n'
158− KCONFIG_PROBABILITY=10:15:15
159− 10% of booleans will be set to 'y', 90% to 'n'
160− 15% of tristates will be set to 'y', 15% to 'm', 70% to 'n'
137+ KCONFIG_PROBABILITY=10
138+ 10% of booleans will be set to 'y', 90% to 'n'
139+ 5% of tristates will be set to 'y', 5% to 'm', 90% to 'n'
140+ KCONFIG_PROBABILITY=15:25
141+ 40% of booleans will be set to 'y', 60% to 'n'
142+ 15% of tristates will be set to 'y', 25% to 'm', 60% to 'n'
143+ KCONFIG_PROBABILITY=10:15:15
144+ 10% of booleans will be set to 'y', 90% to 'n'
145+ 15% of tristates will be set to 'y', 15% to 'm', 70% to 'n'
161146
162−----------------------------------------------------------------------
147+Environment variables for ``syncconfig``:
163148
164−Environment variables for 'syncconfig'
149+``KCONFIG_NOSILENTUPDATE``
150+ If this variable has a non-blank value, it prevents silent kernel
151+ config updates (requires explicit updates).
165152
166−KCONFIG_NOSILENTUPDATE
167−----------------------
168−If this variable has a non-blank value, it prevents silent kernel
169−config updates (requires explicit updates).
153+``KCONFIG_AUTOCONFIG``
154+ This environment variable can be set to specify the path & name of the
155+ "auto.conf" file. Its default value is "include/config/auto.conf".
170156
171−KCONFIG_AUTOCONFIG
172−------------------
173−This environment variable can be set to specify the path & name of the
174−"auto.conf" file. Its default value is "include/config/auto.conf".
157+``KCONFIG_AUTOHEADER``
158+ This environment variable can be set to specify the path & name of the
159+ "autoconf.h" (header) file.
160+ Its default value is "include/generated/autoconf.h".
175161
176−KCONFIG_AUTOHEADER
177−------------------
178−This environment variable can be set to specify the path & name of the
179−"autoconf.h" (header) file.
180−Its default value is "include/generated/autoconf.h".
181−
182−
183−----------------------------------------------------------------------
184162
185163 menuconfig
186−----------
187−
188−SEARCHING for CONFIG symbols
164+==========
189165
190166 Searching in menuconfig:
191167
192− The Search function searches for kernel configuration symbol
193− names, so you have to know something close to what you are
194− looking for.
168+ The Search function searches for kernel configuration symbol
169+ names, so you have to know something close to what you are
170+ looking for.
195171
196− Example::
172+ Example::
197173
198− /hotplug
199− This lists all config symbols that contain "hotplug",
200− e.g., HOTPLUG_CPU, MEMORY_HOTPLUG.
174+ /hotplug
175+ This lists all config symbols that contain "hotplug",
176+ e.g., HOTPLUG_CPU, MEMORY_HOTPLUG.
201177
202− For search help, enter / followed by TAB-TAB (to highlight
203− <Help>) and Enter. This will tell you that you can also use
204− regular expressions (regexes) in the search string, so if you
205− are not interested in MEMORY_HOTPLUG, you could try::
178+ For search help, enter / followed by TAB-TAB (to highlight
179+ <Help>) and Enter. This will tell you that you can also use
180+ regular expressions (regexes) in the search string, so if you
181+ are not interested in MEMORY_HOTPLUG, you could try::
206182
207− /^hotplug
183+ /^hotplug
208184
209− When searching, symbols are sorted thus:
185+ When searching, symbols are sorted thus:
210186
211− - first, exact matches, sorted alphabetically (an exact match
212− is when the search matches the complete symbol name);
213− - then, other matches, sorted alphabetically.
187+ - first, exact matches, sorted alphabetically (an exact match
188+ is when the search matches the complete symbol name);
189+ - then, other matches, sorted alphabetically.
214190
215− For example: ^ATH.K matches:
191+ For example, ^ATH.K matches:
216192
217− ATH5K ATH9K ATH5K_AHB ATH5K_DEBUG [...] ATH6KL ATH6KL_DEBUG
218− [...] ATH9K_AHB ATH9K_BTCOEX_SUPPORT ATH9K_COMMON [...]
193+ ATH5K ATH9K ATH5K_AHB ATH5K_DEBUG [...] ATH6KL ATH6KL_DEBUG
194+ [...] ATH9K_AHB ATH9K_BTCOEX_SUPPORT ATH9K_COMMON [...]
219195
220− of which only ATH5K and ATH9K match exactly and so are sorted
221− first (and in alphabetical order), then come all other symbols,
222− sorted in alphabetical order.
196+ of which only ATH5K and ATH9K match exactly and so are sorted
197+ first (and in alphabetical order), then come all other symbols,
198+ sorted in alphabetical order.
223199
224− In this menu, pressing the key in the (#) prefix will jump
225− directly to that location. You will be returned to the current
226− search results after exiting this new menu.
200+ In this menu, pressing the key in the (#) prefix will jump
201+ directly to that location. You will be returned to the current
202+ search results after exiting this new menu.
227203
228−----------------------------------------------------------------------
204+User interface options for 'menuconfig':
229205
230−User interface options for 'menuconfig'
206+``MENUCONFIG_COLOR``
207+ It is possible to select different color themes using the variable
208+ MENUCONFIG_COLOR. To select a theme use::
231209
232−MENUCONFIG_COLOR
233−----------------
234−It is possible to select different color themes using the variable
235−MENUCONFIG_COLOR. To select a theme use::
210+ make MENUCONFIG_COLOR=<theme> menuconfig
236211
237− make MENUCONFIG_COLOR=<theme> menuconfig
212+ Available themes are::
238213
239−Available themes are::
214+ - mono => selects colors suitable for monochrome displays
215+ - blackbg => selects a color scheme with black background
216+ - classic => theme with blue background. The classic look
217+ - bluetitle => a LCD friendly version of classic. (default)
240218
241− - mono => selects colors suitable for monochrome displays
242− - blackbg => selects a color scheme with black background
243− - classic => theme with blue background. The classic look
244− - bluetitle => a LCD friendly version of classic. (default)
219+``MENUCONFIG_MODE``
220+ This mode shows all sub-menus in one large tree.
245221
246−MENUCONFIG_MODE
247−---------------
248−This mode shows all sub-menus in one large tree.
222+ Example::
249223
250−Example::
224+ make MENUCONFIG_MODE=single_menu menuconfig
251225
252− make MENUCONFIG_MODE=single_menu menuconfig
253−
254−----------------------------------------------------------------------
255226
256227 nconfig
257−-------
228+=======
258229
259230 nconfig is an alternate text-based configurator. It lists function
260231 keys across the bottom of the terminal (window) that execute commands.
@@ -266,61 +237,59 @@ Use F1 for Global help or F3 for the Short help menu. · 5 unmodified lines
266237
267238 Searching in nconfig:
268239
269− You can search either in the menu entry "prompt" strings
270− or in the configuration symbols.
240+ You can search either in the menu entry "prompt" strings
241+ or in the configuration symbols.
242+
243+ Use / to begin a search through the menu entries. This does
244+ not support regular expressions. Use <Down> or <Up> for
245+ Next hit and Previous hit, respectively. Use <Esc> to
246+ terminate the search mode.
271247
272− Use / to begin a search through the menu entries. This does
273− not support regular expressions. Use <Down> or <Up> for
274− Next hit and Previous hit, respectively. Use <Esc> to
275− terminate the search mode.
248+ F8 (SymSearch) searches the configuration symbols for the
249+ given string or regular expression (regex).
276250
277− F8 (SymSearch) searches the configuration symbols for the
278− given string or regular expression (regex).
251+ In the SymSearch, pressing the key in the (#) prefix will
252+ jump directly to that location. You will be returned to the
253+ current search results after exiting this new menu.
279254
280− In the SymSearch, pressing the key in the (#) prefix will
281− jump directly to that location. You will be returned to the
282− current search results after exiting this new menu.
255+Environment variables:
283256
284−NCONFIG_MODE
285−------------
286−This mode shows all sub-menus in one large tree.
257+``NCONFIG_MODE``
258+ This mode shows all sub-menus in one large tree.
287259
288−Example::
260+ Example::
289261
290− make NCONFIG_MODE=single_menu nconfig
262+ make NCONFIG_MODE=single_menu nconfig
291263
292−----------------------------------------------------------------------
293264
294265 xconfig
295−-------
266+=======
296267
297268 Searching in xconfig:
298269
299− The Search function searches for kernel configuration symbol
300− names, so you have to know something close to what you are
301− looking for.
302−
303− Example::
270+ The Search function searches for kernel configuration symbol
271+ names, so you have to know something close to what you are
272+ looking for.
304273
305− Ctrl-F hotplug
274+ Example::
306275
307− or::
276+ Ctrl-F hotplug
308277
309− Menu: File, Search, hotplug
278+ or::
310279
311− lists all config symbol entries that contain "hotplug" in
312− the symbol name. In this Search dialog, you may change the
313− config setting for any of the entries that are not grayed out.
314− You can also enter a different search string without having
315− to return to the main menu.
280+ Menu: File, Search, hotplug
316281
282+ lists all config symbol entries that contain "hotplug" in
283+ the symbol name. In this Search dialog, you may change the
284+ config setting for any of the entries that are not grayed out.
285+ You can also enter a different search string without having
286+ to return to the main menu.
317287
318−----------------------------------------------------------------------
319288
320289 gconfig
321−-------
290+=======
322291
323292 Searching in gconfig:
324293
325− There is no search command in gconfig. However, gconfig does
326− have several different viewing choices, modes, and options.
294+ There is no search command in gconfig. However, gconfig does
295+ have several different viewing choices, modes, and options.
Makefile+28−21
@@ -39,8 +39,8 @@ __all: · 38 unmodified lines
3939 # prepare rule.
4040
4141 this-makefile := $(lastword $(MAKEFILE_LIST))
42−export abs_srctree := $(realpath $(dir $(this-makefile)))
43−export abs_objtree := $(CURDIR)
42+abs_srctree := $(realpath $(dir $(this-makefile)))
43+abs_objtree := $(CURDIR)
4444
4545 ifneq ($(sub_make_done),1)
4646
@@ -295,51 +295,51 @@ single-build := · 248 unmodified lines
295295
296296 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
297297 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
298− need-config :=
298+ need-config :=
299299 endif
300300 endif
301301
302302 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
303303 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
304− may-sync-config :=
304+ may-sync-config :=
305305 endif
306306 endif
307307
308308 need-compiler := $(may-sync-config)
309309
310310 ifneq ($(KBUILD_EXTMOD),)
311− may-sync-config :=
311+ may-sync-config :=
312312 endif
313313
314314 ifeq ($(KBUILD_EXTMOD),)
315− ifneq ($(filter %config,$(MAKECMDGOALS)),)
316− config-build := 1
317− ifneq ($(words $(MAKECMDGOALS)),1)
318− mixed-build := 1
319− endif
315+ ifneq ($(filter %config,$(MAKECMDGOALS)),)
316+ config-build := 1
317+ ifneq ($(words $(MAKECMDGOALS)),1)
318+ mixed-build := 1
320319 endif
320+ endif
321321 endif
322322
323323 # We cannot build single targets and the others at the same time
324324 ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
325− single-build := 1
325+ single-build := 1
326326 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
327− mixed-build := 1
327+ mixed-build := 1
328328 endif
329329 endif
330330
331331 # For "make -j clean all", "make -j mrproper defconfig all", etc.
332332 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
333− ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
334− mixed-build := 1
335− endif
333+ ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
334+ mixed-build := 1
335+ endif
336336 endif
337337
338338 # install and modules_install need also be processed one by one
339339 ifneq ($(filter install,$(MAKECMDGOALS)),)
340− ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
341− mixed-build := 1
342− endif
340+ ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
341+ mixed-build := 1
342+ endif
343343 endif
344344
345345 ifdef mixed-build
@@ -965,8 +965,15 @@ export CC_FLAGS_CFI · 619 unmodified lines
965965 endif
966966
967967 ifneq ($(CONFIG_FUNCTION_ALIGNMENT),0)
968+# Set the minimal function alignment. Use the newer GCC option
969+# -fmin-function-alignment if it is available, or fall back to -falign-funtions.
970+# See also CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT.
971+ifdef CONFIG_CC_HAS_MIN_FUNCTION_ALIGNMENT
972+KBUILD_CFLAGS += -fmin-function-alignment=$(CONFIG_FUNCTION_ALIGNMENT)
973+else
968974 KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
969975 endif
976+endif
970977
971978 # arch Makefile may override CC so keep this after arch Makefile is included
972979 NOSTDINC_FLAGS += -nostdinc
@@ -1384,7 +1391,7 @@ ifneq ($(dtstree),) · 411 unmodified lines
13841391
13851392 PHONY += dtbs dtbs_prepare dtbs_install dtbs_check
13861393 dtbs: dtbs_prepare
1387− $(Q)$(MAKE) $(build)=$(dtstree)
1394+ $(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
13881395
13891396 # include/config/kernel.release is actually needed when installing DTBs because
13901397 # INSTALL_DTBS_PATH contains $(KERNELRELEASE). However, we do not want to make
@@ -1402,7 +1409,7 @@ endif · 11 unmodified lines
14021409 dtbs_check: dtbs
14031410
14041411 dtbs_install:
1405− $(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH)
1412+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=$(dtstree)
14061413
14071414 ifdef CONFIG_OF_EARLY_FLATTREE
14081415 all: dtbs
@@ -1923,7 +1930,7 @@ clean: $(clean-dirs) · 514 unmodified lines
19231930 -o -name '*.ko.*' \
19241931 -o -name '*.dtb' -o -name '*.dtbo' \
19251932 -o -name '*.dtb.S' -o -name '*.dtbo.S' \
1926− -o -name '*.dt.yaml' \
1933+ -o -name '*.dt.yaml' -o -name 'dtbs-list' \
19271934 -o -name '*.dwo' -o -name '*.lst' \
19281935 -o -name '*.su' -o -name '*.mod' \
19291936 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
arch/Kconfig+12−0
@@ -1597,4 +1597,16 @@ config FUNCTION_ALIGNMENT · 1596 unmodified lines
15971597 default 4 if FUNCTION_ALIGNMENT_4B
15981598 default 0
15991599
1600+config CC_HAS_MIN_FUNCTION_ALIGNMENT
1601+ # Detect availability of the GCC option -fmin-function-alignment which
1602+ # guarantees minimal alignment for all functions, unlike
1603+ # -falign-functions which the compiler ignores for cold functions.
1604+ def_bool $(cc-option, -fmin-function-alignment=8)
1605+
1606+config CC_HAS_SANE_FUNCTION_ALIGNMENT
1607+ # Set if the guaranteed alignment with -fmin-function-alignment is
1608+ # available or extra care is required in the kernel. Clang provides
1609+ # strict alignment always, even with -falign-functions.
1610+ def_bool CC_HAS_MIN_FUNCTION_ALIGNMENT || CC_IS_CLANG
1611+
16001612 endmenu
arch/alpha/Kconfig+4−11
@@ -339,6 +339,7 @@ config ALPHA_EV4 · 338 unmodified lines
339339 bool
340340 depends on ALPHA_JENSEN || (ALPHA_SABLE && !ALPHA_GAMMA) || ALPHA_LYNX || ALPHA_NORITAKE && !ALPHA_PRIMO || ALPHA_MIKASA && !ALPHA_PRIMO || ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P_CH || ALPHA_XL || ALPHA_NONAME || ALPHA_EB66 || ALPHA_EB66P || ALPHA_P2K
341341 default y if !ALPHA_LYNX
342+ default y if !ALPHA_EV5
342343
343344 config ALPHA_LCA
344345 bool
@@ -366,10 +367,6 @@ config ALPHA_EV5 · 21 unmodified lines
366367 bool "EV5 CPU(s) (model 5/xxx)?" if ALPHA_LYNX
367368 default y if ALPHA_RX164 || ALPHA_RAWHIDE || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_RUFFIAN || ALPHA_SABLE && ALPHA_GAMMA || ALPHA_NORITAKE && ALPHA_PRIMO || ALPHA_MIKASA && ALPHA_PRIMO || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR
368369
369−config ALPHA_EV4
370− bool
371− default y if ALPHA_LYNX && !ALPHA_EV5
372−
373370 config ALPHA_CIA
374371 bool
375372 depends on ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_RUFFIAN || ALPHA_NORITAKE && ALPHA_PRIMO || ALPHA_MIKASA && ALPHA_PRIMO || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR
@@ -394,16 +391,12 @@ config ALPHA_PRIMO · 18 unmodified lines
394391 Say Y if you have an AS 1000 5/xxx or an AS 1000A 5/xxx.
395392
396393 config ALPHA_GAMMA
397− bool "EV5 CPU(s) (model 5/xxx)?"
398− depends on ALPHA_SABLE
394+ bool "EV5 CPU(s) (model 5/xxx)?" if ALPHA_SABLE
395+ depends on ALPHA_SABLE || ALPHA_LYNX
396+ default ALPHA_LYNX
399397 help
400398 Say Y if you have an AS 2000 5/xxx or an AS 2100 5/xxx.
401399
402−config ALPHA_GAMMA
403− bool
404− depends on ALPHA_LYNX
405− default y
406−
407400 config ALPHA_T2
408401 bool
409402 depends on ALPHA_SABLE || ALPHA_LYNX
arch/hexagon/Kconfig+3−9
@@ -7,11 +7,13 @@ config HEXAGON · 6 unmodified lines
77 select ARCH_32BIT_OFF_T
88 select ARCH_HAS_SYNC_DMA_FOR_DEVICE
99 select ARCH_NO_PREEMPT
10+ select ARCH_WANT_FRAME_POINTERS
1011 select DMA_GLOBAL_POOL
1112 select HAVE_PAGE_SIZE_4KB
1213 select HAVE_PAGE_SIZE_16KB
1314 select HAVE_PAGE_SIZE_64KB
1415 select HAVE_PAGE_SIZE_256KB
16+ select FRAME_POINTER
1517 # Other pending projects/to-do items.
1618 # select HAVE_REGS_AND_STACK_ACCESS_API
1719 # select HAVE_HW_BREAKPOINT if PERF_EVENTS
@@ -23,6 +25,7 @@ config HEXAGON · 5 unmodified lines
2325 select HAVE_PERF_EVENTS
2426 # GENERIC_ALLOCATOR is used by dma_alloc_coherent()
2527 select GENERIC_ALLOCATOR
28+ select GENERIC_IRQ_PROBE
2629 select GENERIC_IRQ_SHOW
2730 select HAVE_ARCH_KGDB
2831 select HAVE_ARCH_TRACEHOOK
@@ -47,9 +50,6 @@ config HEXAGON_PHYS_OFFSET · 18 unmodified lines
4750 help
4851 Platforms that don't load the kernel at zero set this.
4952
50−config FRAME_POINTER
51− def_bool y
52−
5353 config LOCKDEP_SUPPORT
5454 def_bool y
5555
@@ -62,12 +62,6 @@ config MMU · 6 unmodified lines
6262 config GENERIC_CSUM
6363 def_bool y
6464
65−#
66−# Use the generic interrupt handling code in kernel/irq/:
67−#
68−config GENERIC_IRQ_PROBE
69− def_bool y
70−
7165 config GENERIC_HWEIGHT
7266 def_bool y
7367
arch/parisc/Kconfig+2−2
@@ -238,9 +238,9 @@ config PARISC_HUGE_KERNEL · 237 unmodified lines
238238 def_bool y if !MODULES || UBSAN || FTRACE || COMPILE_TEST
239239
240240 config MLONGCALLS
241− def_bool y if PARISC_HUGE_KERNEL
242241 bool "Enable the -mlong-calls compiler option for big kernels" if !PARISC_HUGE_KERNEL
243242 depends on PA8X00
243+ default PARISC_HUGE_KERNEL
244244 help
245245 If you configure the kernel to include many drivers built-in instead
246246 as modules, the kernel executable may become too big, so that the
@@ -255,9 +255,9 @@ config MLONGCALLS · 8 unmodified lines
255255 Enabling this option will probably slow down your kernel.
256256
257257 config 64BIT
258− def_bool y if "$(ARCH)" = "parisc64"
259258 bool "64-bit kernel" if "$(ARCH)" = "parisc"
260259 depends on PA8X00
260+ default "$(ARCH)" = "parisc64"
261261 help
262262 Enable this if you want to support 64bit kernel on PA-RISC platform.
263263
arch/riscv/kernel/tests/Kconfig.debug+1−1
@@ -6,7 +6,7 @@ config AS_HAS_ULEB128 · 5 unmodified lines
66
77 menuconfig RUNTIME_KERNEL_TESTING_MENU
88 bool "arch/riscv/kernel runtime Testing"
9− def_bool y
9+ default y
1010 help
1111 Enable riscv kernel runtime testing.
1212
arch/x86/entry/vdso/Makefile+2−0
@@ -9,7 +9,9 @@ include $(srctree)/lib/vdso/Makefile · 8 unmodified lines
99 # Sanitizer runtimes are unavailable and cannot be linked here.
1010 KASAN_SANITIZE := n
1111 KMSAN_SANITIZE_vclock_gettime.o := n
12+KMSAN_SANITIZE_vdso32/vclock_gettime.o := n
1213 KMSAN_SANITIZE_vgetcpu.o := n
14+KMSAN_SANITIZE_vdso32/vgetcpu.o := n
1315
1416 UBSAN_SANITIZE := n
1517 KCSAN_SANITIZE := n
arch/x86/kvm/Kconfig+1−1
@@ -118,8 +118,8 @@ config KVM_AMD · 117 unmodified lines
118118 will be called kvm-amd.
119119
120120 config KVM_AMD_SEV
121− def_bool y
122121 bool "AMD Secure Encrypted Virtualization (SEV) support"
122+ default y
123123 depends on KVM_AMD && X86_64
124124 depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y && CRYPTO_DEV_CCP_DD=m)
125125 help
arch/x86/kvm/Makefile+2−1
@@ -4,7 +4,8 @@ ccflags-y += -I $(srctree)/arch/x86/kvm · 3 unmodified lines
44 ccflags-$(CONFIG_KVM_WERROR) += -Werror
55
66 ifeq ($(CONFIG_FRAME_POINTER),y)
7−OBJECT_FILES_NON_STANDARD_vmenter.o := y
7+OBJECT_FILES_NON_STANDARD_vmx/vmenter.o := y
8+OBJECT_FILES_NON_STANDARD_svm/vmenter.o := y
89 endif
910
1011 include $(srctree)/virt/kvm/Makefile.kvm
arch/x86/xen/Kconfig+0−1
@@ -81,7 +81,6 @@ config XEN_PVH · 80 unmodified lines
8181 bool "Xen PVH guest support"
8282 depends on XEN && XEN_PVHVM && ACPI
8383 select PVH
84− def_bool n
8584 help
8685 Support for running as a Xen PVH guest.
8786
drivers/acpi/Kconfig+0−1
@@ -460,7 +460,6 @@ config ACPI_BGRT · 459 unmodified lines
460460
461461 config ACPI_REDUCED_HARDWARE_ONLY
462462 bool "Hardware-reduced ACPI support only" if EXPERT
463− def_bool n
464463 help
465464 This config item changes the way the ACPI code is built. When this
466465 option is selected, the kernel will use a specialized version of
drivers/iommu/intel/Kconfig+1−1
@@ -87,8 +87,8 @@ config INTEL_IOMMU_SCALABLE_MODE_DEFAULT_ON · 86 unmodified lines
8787 the default value.
8888
8989 config INTEL_IOMMU_PERF_EVENTS
90− def_bool y
9190 bool "Intel IOMMU performance events"
91+ default y
9292 depends on INTEL_IOMMU && PERF_EVENTS
9393 help
9494 Selecting this option will enable the performance monitoring
drivers/md/Kconfig+0−1
@@ -519,7 +519,6 @@ config DM_VERITY · 518 unmodified lines
519519 If unsure, say N.
520520
521521 config DM_VERITY_VERIFY_ROOTHASH_SIG
522− def_bool n
523522 bool "Verity data device root hash signature verification support"
524523 depends on DM_VERITY
525524 select SYSTEM_DATA_VERIFICATION
include/linux/compiler_types.h+5−5
@@ -99,17 +99,17 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } · 98 unmodified lines
9999 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html#index-cold-label-attribute
100100 *
101101 * When -falign-functions=N is in use, we must avoid the cold attribute as
102− * contemporary versions of GCC drop the alignment for cold functions. Worse,
103− * GCC can implicitly mark callees of cold functions as cold themselves, so
104− * it's not sufficient to add __function_aligned here as that will not ensure
105− * that callees are correctly aligned.
102+ * GCC drops the alignment for cold functions. Worse, GCC can implicitly mark
103+ * callees of cold functions as cold themselves, so it's not sufficient to add
104+ * __function_aligned here as that will not ensure that callees are correctly
105+ * aligned.
106106 *
107107 * See:
108108 *
109109 * https://lore.kernel.org/lkml/Y77%2FqVgvaJidFpYt@FVFF77S0Q05N
110110 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345#c9
111111 */
112−#if !defined(CONFIG_CC_IS_GCC) || (CONFIG_FUNCTION_ALIGNMENT == 0)
112+#if defined(CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT) || (CONFIG_FUNCTION_ALIGNMENT == 0)
113113 #define __cold __attribute__((__cold__))
114114 #else
115115 #define __cold
init/Kconfig+1−1
@@ -1499,7 +1499,7 @@ config MULTIUSER · 1498 unmodified lines
14991499
15001500 config SGETMASK_SYSCALL
15011501 bool "sgetmask/ssetmask syscalls support" if EXPERT
1502− def_bool PARISC || M68K || PPC || MIPS || X86 || SPARC || MICROBLAZE || SUPERH
1502+ default PARISC || M68K || PPC || MIPS || X86 || SPARC || MICROBLAZE || SUPERH
15031503 help
15041504 sys_sgetmask and sys_ssetmask are obsolete system calls
15051505 no longer supported in libc but still enabled by default in some
kernel/module/Kconfig+1−2
@@ -362,8 +362,7 @@ config MODPROBE_PATH · 361 unmodified lines
362362 userspace can still load modules explicitly).
363363
364364 config TRIM_UNUSED_KSYMS
365− bool "Trim unused exported kernel symbols" if EXPERT
366− depends on !COMPILE_TEST
365+ bool "Trim unused exported kernel symbols"
367366 help
368367 The kernel and some modules make many symbols available for
369368 other modules to use via EXPORT_SYMBOL() and variants. Depending
lib/Kconfig.debug+1−1
@@ -2127,7 +2127,7 @@ config KCOV_IRQ_AREA_SIZE · 2126 unmodified lines
21272127
21282128 menuconfig RUNTIME_TESTING_MENU
21292129 bool "Runtime Testing"
2130− def_bool y
2130+ default y
21312131
21322132 if RUNTIME_TESTING_MENU
21332133
mm/Kconfig+3−4
@@ -583,7 +583,7 @@ config MEMORY_BALLOON · 582 unmodified lines
583583 # support for memory balloon compaction
584584 config BALLOON_COMPACTION
585585 bool "Allow for balloon memory compaction/migration"
586− def_bool y
586+ default y
587587 depends on COMPACTION && MEMORY_BALLOON
588588 help
589589 Memory fragmentation introduced by ballooning might reduce
@@ -598,7 +598,7 @@ config BALLOON_COMPACTION · 8 unmodified lines
598598 # support for memory compaction
599599 config COMPACTION
600600 bool "Allow for memory compaction"
601− def_bool y
601+ default y
602602 select MIGRATION
603603 depends on MMU
604604 help
@@ -621,7 +621,6 @@ config COMPACT_UNEVICTABLE_DEFAULT · 16 unmodified lines
621621 # support for free page reporting
622622 config PAGE_REPORTING
623623 bool "Free page reporting"
624− def_bool n
625624 help
626625 Free page reporting allows for the incremental acquisition of
627626 free pages from the buddy allocator for the purpose of reporting
@@ -633,7 +632,7 @@ config PAGE_REPORTING · 5 unmodified lines
633632 #
634633 config MIGRATION
635634 bool "Page migration"
636− def_bool y
635+ default y
637636 depends on (NUMA || ARCH_ENABLE_MEMORY_HOTREMOVE || COMPACTION || CMA) && MMU
638637 help
639638 Allows the migration of the physical location of pages of processes
net/dccp/ccids/Kconfig+1−1
@@ -13,7 +13,7 @@ config IP_DCCP_CCID2_DEBUG · 12 unmodified lines
1313
1414 config IP_DCCP_CCID3
1515 bool "CCID-3 (TCP-Friendly)"
16− def_bool y if (IP_DCCP = y || IP_DCCP = m)
16+ default IP_DCCP = y || IP_DCCP = m
1717 help
1818 CCID-3 denotes TCP-Friendly Rate Control (TFRC), an equation-based
1919 rate-controlled congestion control mechanism. TFRC is designed to
rust/Makefile+2−2
@@ -100,7 +100,7 @@ rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \ · 99 unmodified lines
100100 -e 's:rust-logo-[0-9a-f]+\.svg:logo.svg:g' \
101101 -e 's:favicon-[0-9a-f]+\.svg:logo.svg:g' \
102102 -e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-[0-9a-f]+\.png">::g' \
103− -e 's:<a href="srctree/([^"]+)">:<a href="$(abs_srctree)/\1">:g'
103+ -e 's:<a href="srctree/([^"]+)">:<a href="$(realpath $(srctree))/\1">:g'
104104 $(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \
105105 echo ".logo-container > img { object-fit: contain; }" >> $$f; done
106106
@@ -414,7 +414,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L · 307 unmodified lines
414414 rust-analyzer:
415415 $(Q)$(srctree)/scripts/generate_rust_analyzer.py \
416416 --cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
417− $(abs_srctree) $(abs_objtree) \
417+ $(realpath $(srctree)) $(realpath $(objtree)) \
418418 $(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
419419 $(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
420420
scripts/Kbuild.include+0−6
@@ -113,12 +113,6 @@ endef · 112 unmodified lines
113113 # $(Q)$(MAKE) $(build)=dir
114114 build := -f $(srctree)/scripts/Makefile.build obj
115115
116−###
117−# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=
118−# Usage:
119−# $(Q)$(MAKE) $(dtbinst)=dir
120−dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj
121−
122116 ###
123117 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=
124118 # Usage:
scripts/Makefile.build+13−9
@@ -71,6 +71,7 @@ endif · 70 unmodified lines
7171 # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
7272 subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
7373 subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
74+subdir-dtbslist := $(sort $(filter %/dtbs-list, $(dtb-y)))
7475
7576 targets-for-builtin := $(extra-y)
7677
@@ -213,7 +214,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT · 136 unmodified lines
213214 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
214215 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
215216
216−is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
217+is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),y)
217218
218219 $(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
219220
@@ -388,6 +389,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler · 168 unmodified lines
388389 # To build objects in subdirs, we need to descend into the directories
389390 $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
390391 $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
392+$(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ;
391393
392394 #
393395 # Rule to compile a set of .o files into one .a file (without symbol table)
@@ -404,19 +406,21 @@ $(obj)/built-in.a: $(real-obj-y) FORCE · 10 unmodified lines
404406 $(call if_changed,ar_builtin)
405407
406408 #
407−# Rule to create modules.order file
409+# Rule to create modules.order and dtbs-list
408410 #
409−# Create commands to either record .ko file or cat modules.order from
410−# a subdirectory
411−# Add $(obj-m) as the prerequisite to avoid updating the timestamp of
412−# modules.order unless contained modules are updated.
411+# This is a list of build artifacts (module or dtb) from the current Makefile
412+# and its sub-directories. The timestamp should be updated when any of the
413+# member files.
413414
414−cmd_modules_order = { $(foreach m, $(real-prereqs), \
415− $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
415+cmd_gen_order = { $(foreach m, $(real-prereqs), \
416+ $(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \
416417 > $@
417418
418419 $(obj)/modules.order: $(obj-m) FORCE
419− $(call if_changed,modules_order)
420+ $(call if_changed,gen_order)
421+
422+$(obj)/dtbs-list: $(dtb-y) FORCE
423+ $(call if_changed,gen_order)
420424
421425 #
422426 # Rule to compile a set of .o files into one .a file (with symbol table)
scripts/Makefile.dtbinst+18−14
@@ -8,32 +8,36 @@ · 7 unmodified lines
88 # $INSTALL_PATH/dtbs/$KERNELRELEASE
99 # ==========================================================================
1010
11−src := $(obj)
12−
1311 PHONY := __dtbs_install
1412 __dtbs_install:
1513
1614 include include/config/auto.conf
1715 include $(srctree)/scripts/Kbuild.include
18−include $(kbuild-file)
19−
20−dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
21−subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m))
2216
23−__dtbs_install: $(dtbs) $(subdirs)
24− @:
17+dst := $(INSTALL_DTBS_PATH)
2518
2619 quiet_cmd_dtb_install = INSTALL $@
2720 cmd_dtb_install = install -D $< $@
2821
29−$(dst)/%.dtb: $(obj)/%.dtb
22+$(dst)/%: $(obj)/%
3023 $(call cmd,dtb_install)
3124
32−$(dst)/%.dtbo: $(obj)/%.dtbo
33− $(call cmd,dtb_install)
25+dtbs := $(patsubst $(obj)/%,%,$(call read-file, $(obj)/dtbs-list))
26+
27+ifdef CONFIG_ARCH_WANT_FLAT_DTB_INSTALL
3428
35−PHONY += $(subdirs)
36−$(subdirs):
37− $(Q)$(MAKE) $(dtbinst)=$@ dst=$(if $(CONFIG_ARCH_WANT_FLAT_DTB_INSTALL),$(dst),$(patsubst $(obj)/%,$(dst)/%,$@))
29+define gen_install_rules
30+$(dst)/%: $(obj)/$(1)%
31+ $$(call cmd,dtb_install)
32+endef
33+
34+$(foreach d, $(sort $(dir $(dtbs))), $(eval $(call gen_install_rules,$(d))))
35+
36+dtbs := $(notdir $(dtbs))
37+
38+endif # CONFIG_ARCH_WANT_FLAT_DTB_INSTALL
39+
40+__dtbs_install: $(addprefix $(dst)/, $(dtbs))
41+ @:
3842
3943 .PHONY: $(PHONY)
scripts/Makefile.extrawarn+2−1
@@ -132,6 +132,8 @@ KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) · 131 unmodified lines
132132 KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
133133 KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
134134 KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
135+KBUILD_CFLAGS += -Wno-enum-compare-conditional
136+KBUILD_CFLAGS += -Wno-enum-enum-conversion
135137 endif
136138
137139 endif
@@ -185,7 +187,6 @@ KBUILD_CFLAGS += -Wpointer-arith · 47 unmodified lines
185187 KBUILD_CFLAGS += -Wredundant-decls
186188 KBUILD_CFLAGS += -Wsign-compare
187189 KBUILD_CFLAGS += -Wswitch-default
188−KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
189190
190191 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
191192
scripts/Makefile.lib+16−10
@@ -45,6 +45,11 @@ else · 44 unmodified lines
4545 obj-y := $(filter-out %/, $(obj-y))
4646 endif
4747
48+ifdef need-dtbslist
49+dtb-y += $(addsuffix /dtbs-list, $(subdir-ym))
50+always-y += dtbs-list
51+endif
52+
4853 # Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
4954 suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
5055 # List composite targets that are constructed by combining other targets
@@ -99,6 +104,7 @@ lib-y := $(addprefix $(obj)/,$(lib-y)) · 48 unmodified lines
99104 real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
100105 real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
101106 multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m))
107+dtb-y := $(addprefix $(obj)/, $(dtb-y))
102108 multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
103109 real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
104110 subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
@@ -148,7 +154,7 @@ _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) · 43 unmodified lines
148154 #
149155 ifeq ($(CONFIG_GCOV_KERNEL),y)
150156 _c_flags += $(if $(patsubst n%,, \
151− $(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
157+ $(GCOV_PROFILE_$(target-stem).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
152158 $(CFLAGS_GCOV))
153159 endif
154160
@@ -159,32 +165,32 @@ endif · 4 unmodified lines
159165 ifeq ($(CONFIG_KASAN),y)
160166 ifneq ($(CONFIG_KASAN_HW_TAGS),y)
161167 _c_flags += $(if $(patsubst n%,, \
162− $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
168+ $(KASAN_SANITIZE_$(target-stem).o)$(KASAN_SANITIZE)y), \
163169 $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE))
164170 endif
165171 endif
166172
167173 ifeq ($(CONFIG_KMSAN),y)
168174 _c_flags += $(if $(patsubst n%,, \
169− $(KMSAN_SANITIZE_$(basetarget).o)$(KMSAN_SANITIZE)y), \
175+ $(KMSAN_SANITIZE_$(target-stem).o)$(KMSAN_SANITIZE)y), \
170176 $(CFLAGS_KMSAN))
171177 _c_flags += $(if $(patsubst n%,, \
172− $(KMSAN_ENABLE_CHECKS_$(basetarget).o)$(KMSAN_ENABLE_CHECKS)y), \
178+ $(KMSAN_ENABLE_CHECKS_$(target-stem).o)$(KMSAN_ENABLE_CHECKS)y), \
173179 , -mllvm -msan-disable-checks=1)
174180 endif
175181
176182 ifeq ($(CONFIG_UBSAN),y)
177183 _c_flags += $(if $(patsubst n%,, \
178− $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)y), \
184+ $(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SANITIZE)y), \
179185 $(CFLAGS_UBSAN))
180186 _c_flags += $(if $(patsubst n%,, \
181− $(UBSAN_SIGNED_WRAP_$(basetarget).o)$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SIGNED_WRAP)$(UBSAN_SANITIZE)y), \
187+ $(UBSAN_SIGNED_WRAP_$(target-stem).o)$(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SIGNED_WRAP)$(UBSAN_SANITIZE)y), \
182188 $(CFLAGS_UBSAN_SIGNED_WRAP))
183189 endif
184190
185191 ifeq ($(CONFIG_KCOV),y)
186192 _c_flags += $(if $(patsubst n%,, \
187− $(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \
193+ $(KCOV_INSTRUMENT_$(target-stem).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \
188194 $(CFLAGS_KCOV))
189195 endif
190196
@@ -194,12 +200,12 @@ endif · 3 unmodified lines
194200 #
195201 ifeq ($(CONFIG_KCSAN),y)
196202 _c_flags += $(if $(patsubst n%,, \
197− $(KCSAN_SANITIZE_$(basetarget).o)$(KCSAN_SANITIZE)y), \
203+ $(KCSAN_SANITIZE_$(target-stem).o)$(KCSAN_SANITIZE)y), \
198204 $(CFLAGS_KCSAN))
199205 # Some uninstrumented files provide implied barriers required to avoid false
200206 # positives: set KCSAN_INSTRUMENT_BARRIERS for barrier instrumentation only.
201207 _c_flags += $(if $(patsubst n%,, \
202− $(KCSAN_INSTRUMENT_BARRIERS_$(basetarget).o)$(KCSAN_INSTRUMENT_BARRIERS)n), \
208+ $(KCSAN_INSTRUMENT_BARRIERS_$(target-stem).o)$(KCSAN_INSTRUMENT_BARRIERS)n), \
203209 -D__KCSAN_INSTRUMENT_BARRIERS__)
204210 endif
205211
@@ -364,7 +370,7 @@ DTC_FLAGS += -Wnode_name_chars_strict \ · 158 unmodified lines
364370 -Wunique_unit_address
365371 endif
366372
367−DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
373+DTC_FLAGS += $(DTC_FLAGS_$(target-stem))
368374
369375 # Set -@ if the target is a base DTB that overlay is applied onto
370376 DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@)
scripts/Makefile.package+1−1
@@ -135,7 +135,7 @@ snap-pkg: · 134 unmodified lines
135135 mkdir $(objtree)/snap
136136 $(MAKE) clean
137137 sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
138− s@SRCTREE@$(abs_srctree)@" \
138+ s@SRCTREE@$(realpath $(srctree))@" \
139139 $(srctree)/scripts/package/snapcraft.template > \
140140 $(objtree)/snap/snapcraft.yaml
141141 cd $(objtree)/snap && \
scripts/kconfig/array_size.h+11−0
@@ -0,0 +1,11 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+#ifndef ARRAY_SIZE_H
3+#define ARRAY_SIZE_H
4+
5+/**
6+ * ARRAY_SIZE - get the number of elements in array @arr
7+ * @arr: array to be sized
8+ */
9+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
10+
11+#endif /* ARRAY_SIZE_H */
scripts/kconfig/conf.c+6−6
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <sys/time.h>
1515 #include <errno.h>
1616
17+#include "internal.h"
1718 #include "lkc.h"
1819
1920 static void conf(struct menu *menu);
@@ -171,7 +172,7 @@ enum conf_def_mode { · 151 unmodified lines
171172 static bool conf_set_all_new_symbols(enum conf_def_mode mode)
172173 {
173174 struct symbol *sym, *csym;
174− int i, cnt;
175+ int cnt;
175176 /*
176177 * can't go as the default in switch-case below, otherwise gcc whines
177178 * about -Wmaybe-uninitialized
@@ -226,7 +227,7 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) · 48 unmodified lines
226227 }
227228 }
228229
229− for_all_symbols(i, sym) {
230+ for_all_symbols(sym) {
230231 if (sym_has_value(sym) || sym->flags & SYMBOL_VALID)
231232 continue;
232233 switch (sym_get_type(sym)) {
@@ -278,14 +279,14 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) · 45 unmodified lines
278279 * and the rest to no.
279280 */
280281 if (mode != def_random) {
281− for_all_symbols(i, csym) {
282+ for_all_symbols(csym) {
282283 if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
283284 sym_is_choice_value(csym))
284285 csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
285286 }
286287 }
287288
288− for_all_symbols(i, csym) {
289+ for_all_symbols(csym) {
289290 if (sym_has_value(csym) || !sym_is_choice(csym))
290291 continue;
291292
@@ -304,9 +305,8 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) · 12 unmodified lines
304305 static void conf_rewrite_tristates(tristate old_val, tristate new_val)
305306 {
306307 struct symbol *sym;
307− int i;
308308
309− for_all_symbols(i, sym) {
309+ for_all_symbols(sym) {
310310 if (sym_get_type(sym) == S_TRISTATE &&
311311 sym->def[S_DEF_USER].tri == old_val)
312312 sym->def[S_DEF_USER].tri = new_val;
scripts/kconfig/confdata.c+18−78
@@ -18,8 +18,11 @@ · 17 unmodified lines
1818 #include <time.h>
1919 #include <unistd.h>
2020
21+#include "internal.h"
2122 #include "lkc.h"
2223
24+struct gstr autoconf_cmd;
25+
2326 /* return true if 'path' exists, false otherwise */
2427 static bool is_present(const char *path)
2528 {
@@ -293,63 +296,12 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) · 267 unmodified lines
293296 return 0;
294297 }
295298
296−#define LINE_GROWTH 16
297−static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
298−{
299− size_t new_size = slen + 1;
300−
301− if (new_size > *n) {
302− new_size += LINE_GROWTH - 1;
303− new_size *= 2;
304− *lineptr = xrealloc(*lineptr, new_size);
305− *n = new_size;
306− }
307−
308− (*lineptr)[slen] = c;
309−
310− return 0;
311−}
312−
313−static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
314−{
315− char *line = *lineptr;
316− size_t slen = 0;
317−
318− for (;;) {
319− int c = getc(stream);
320−
321− switch (c) {
322− case '\n':
323− if (add_byte(c, &line, slen, n) < 0)
324− goto e_out;
325− slen++;
326− /* fall through */
327− case EOF:
328− if (add_byte('\0', &line, slen, n) < 0)
329− goto e_out;
330− *lineptr = line;
331− if (slen == 0)
332− return -1;
333− return slen;
334− default:
335− if (add_byte(c, &line, slen, n) < 0)
336− goto e_out;
337− slen++;
338− }
339− }
340−
341−e_out:
342− line[slen-1] = '\0';
343− *lineptr = line;
344− return -1;
345−}
346−
347299 /* like getline(), but the newline character is stripped away */
348300 static ssize_t getline_stripped(char **lineptr, size_t *n, FILE *stream)
349301 {
350302 ssize_t len;
351303
352− len = compat_getline(lineptr, n, stream);
304+ len = getline(lineptr, n, stream);
353305
354306 if (len > 0 && (*lineptr)[len - 1] == '\n') {
355307 len--;
@@ -371,7 +323,7 @@ int conf_read_simple(const char *name, int def) · 15 unmodified lines
371323 size_t line_asize = 0;
372324 char *p, *val;
373325 struct symbol *sym;
374− int i, def_flags;
326+ int def_flags;
375327 const char *warn_unknown, *sym_name;
376328
377329 warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS");
@@ -429,7 +381,7 @@ load: · 51 unmodified lines
429381 conf_warnings = 0;
430382
431383 def_flags = SYMBOL_DEF << def;
432− for_all_symbols(i, sym) {
384+ for_all_symbols(sym) {
433385 sym->flags |= SYMBOL_CHANGED;
434386 sym->flags &= ~(def_flags|SYMBOL_VALID);
435387 if (sym_is_choice(sym))
@@ -538,7 +490,6 @@ int conf_read(const char *name) · 102 unmodified lines
538490 {
539491 struct symbol *sym;
540492 int conf_unsaved = 0;
541− int i;
542493
543494 conf_set_changed(false);
544495
@@ -549,7 +500,7 @@ int conf_read(const char *name) · 4 unmodified lines
549500
550501 sym_calc_value(modules_sym);
551502
552− for_all_symbols(i, sym) {
503+ for_all_symbols(sym) {
553504 sym_calc_value(sym);
554505 if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE))
555506 continue;
@@ -573,7 +524,7 @@ int conf_read(const char *name) · 17 unmodified lines
573524 /* maybe print value in verbose mode... */
574525 }
575526
576− for_all_symbols(i, sym) {
527+ for_all_symbols(sym) {
577528 if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
578529 /* Reset values of generates values, so they'll appear
579530 * as new, if they should become visible, but that
@@ -848,10 +799,7 @@ int conf_write_defconfig(const char *filename) · 268 unmodified lines
848799 while (menu != NULL)
849800 {
850801 sym = menu->sym;
851− if (sym == NULL) {
852− if (!menu_is_visible(menu))
853− goto next_menu;
854− } else if (!sym_is_choice(sym)) {
802+ if (sym && !sym_is_choice(sym)) {
855803 sym_calc_value(sym);
856804 if (!(sym->flags & SYMBOL_WRITE))
857805 goto next_menu;
@@ -911,7 +859,6 @@ int conf_write(const char *name) · 53 unmodified lines
911859 const char *str;
912860 char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
913861 char *env;
914− int i;
915862 bool need_newline = false;
916863
917864 if (!name)
@@ -995,7 +942,7 @@ end_check: · 77 unmodified lines
995942 }
996943 fclose(out);
997944
998− for_all_symbols(i, sym)
945+ for_all_symbols(sym)
999946 sym->flags &= ~SYMBOL_WRITTEN;
1000947
1001948 if (*tmpname) {
@@ -1023,7 +970,6 @@ end_check: · 21 unmodified lines
1023970 static int conf_write_autoconf_cmd(const char *autoconf_name)
1024971 {
1025972 char name[PATH_MAX], tmp[PATH_MAX];
1026− struct file *file;
1027973 FILE *out;
1028974 int ret;
1029975
@@ -1044,15 +990,9 @@ static int conf_write_autoconf_cmd(const char *autoconf_name) · 14 unmodified lines
1044990 return -1;
1045991 }
1046992
1047− fprintf(out, "deps_config := \\\n");
1048− for (file = file_list; file; file = file->next)
1049− fprintf(out, "\t%s \\\n", file->name);
1050−
1051− fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name);
993+ fprintf(out, "autoconfig := %s\n", autoconf_name);
1052994
1053− env_write_dep(out, autoconf_name);
1054−
1055− fprintf(out, "\n$(deps_config): ;\n");
995+ fputs(str_get(&autoconf_cmd), out);
1056996
1057997 fflush(out);
1058998 ret = ferror(out); /* error check for all fprintf() calls */
@@ -1072,7 +1012,7 @@ static int conf_touch_deps(void) · 13 unmodified lines
10721012 {
10731013 const char *name, *tmp;
10741014 struct symbol *sym;
1075− int res, i;
1015+ int res;
10761016
10771017 name = conf_get_autoconfig_name();
10781018 tmp = strrchr(name, '/');
@@ -1086,7 +1026,7 @@ static int conf_touch_deps(void) · 7 unmodified lines
10861026 conf_read_simple(name, S_DEF_AUTO);
10871027 sym_calc_value(modules_sym);
10881028
1089− for_all_symbols(i, sym) {
1029+ for_all_symbols(sym) {
10901030 sym_calc_value(sym);
10911031 if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name)
10921032 continue;
@@ -1152,7 +1092,7 @@ static int __conf_write_autoconf(const char *filename, · 59 unmodified lines
11521092 char tmp[PATH_MAX];
11531093 FILE *file;
11541094 struct symbol *sym;
1155− int ret, i;
1095+ int ret;
11561096
11571097 if (make_parent_dir(filename))
11581098 return -1;
@@ -1169,7 +1109,7 @@ static int __conf_write_autoconf(const char *filename, · 10 unmodified lines
11691109
11701110 conf_write_heading(file, comment_style);
11711111
1172− for_all_symbols(i, sym)
1112+ for_all_symbols(sym)
11731113 if ((sym->flags & SYMBOL_WRITE) && sym->name)
11741114 print_symbol(file, sym);
11751115
@@ -1192,7 +1132,7 @@ int conf_write_autoconf(int overwrite) · 16 unmodified lines
11921132 {
11931133 struct symbol *sym;
11941134 const char *autoconf_name = conf_get_autoconfig_name();
1195− int ret, i;
1135+ int ret;
11961136
11971137 if (!overwrite && is_present(autoconf_name))
11981138 return 0;
@@ -1204,7 +1144,7 @@ int conf_write_autoconf(int overwrite) · 5 unmodified lines
12041144 if (conf_touch_deps())
12051145 return 1;
12061146
1207− for_all_symbols(i, sym)
1147+ for_all_symbols(sym)
12081148 sym_calc_value(sym);
12091149
12101150 ret = __conf_write_autoconf(conf_get_autoheader_name(),
scripts/kconfig/expr.h+11−18
@@ -12,17 +12,12 @@ extern "C" { · 11 unmodified lines
1212
1313 #include <assert.h>
1414 #include <stdio.h>
15−#include "list.h"
15+#include "list_types.h"
1616 #ifndef __cplusplus
1717 #include <stdbool.h>
1818 #endif
1919
20−struct file {
21− struct file *next;
22− struct file *parent;
23− const char *name;
24− int lineno;
25−};
20+#include "list_types.h"
2621
2722 typedef enum tristate {
2823 no, mod, yes
@@ -81,8 +76,8 @@ enum { · 52 unmodified lines
8176 * SYMBOL_CHOICE bit set in 'flags'.
8277 */
8378 struct symbol {
84− /* The next symbol in the same bucket in the symbol hash table */
85− struct symbol *next;
79+ /* link node for the hash table */
80+ struct hlist_node node;
8681
8782 /* The name of the symbol, e.g. "FOO" for 'config FOO' */
8883 char *name;
@@ -113,6 +108,9 @@ struct symbol { · 24 unmodified lines
113108 */
114109 tristate visible;
115110
111+ /* config entries associated with this symbol */
112+ struct list_head menus;
113+
116114 /* SYMBOL_* flags */
117115 int flags;
118116
@@ -131,8 +129,6 @@ struct symbol { · 12 unmodified lines
131129 struct expr_value implied;
132130 };
133131
134−#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next)
135−
136132 #define SYMBOL_CONST 0x0001 /* symbol is const */
137133 #define SYMBOL_CHECK 0x0008 /* used during dependency checking */
138134 #define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */
@@ -157,7 +153,6 @@ struct symbol { · 18 unmodified lines
157153 #define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
158154
159155 #define SYMBOL_MAXLENGTH 256
160−#define SYMBOL_HASHSIZE 9973
161156
162157 /* A property represent the config options that can be associated
163158 * with a config "symbol".
@@ -195,7 +190,7 @@ struct property { · 31 unmodified lines
195190 struct menu *menu; /* the menu the property are associated with
196191 * valid for: P_SELECT, P_RANGE, P_CHOICE,
197192 * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */
198− struct file *file; /* what file was this property defined */
193+ const char *filename; /* what file was this property defined */
199194 int lineno; /* what lineno was this property defined */
200195 };
201196
@@ -230,6 +225,8 @@ struct menu { · 28 unmodified lines
230225 */
231226 struct symbol *sym;
232227
228+ struct list_head link; /* link to symbol::menus */
229+
233230 /*
234231 * The prompt associated with the node. This holds the prompt for a
235232 * symbol as well as the text for a menu or comment, along with the
@@ -256,7 +253,7 @@ struct menu { · 20 unmodified lines
256253 char *help;
257254
258255 /* The location where the menu node appears in the Kconfig files */
259− struct file *file;
256+ const char *filename;
260257 int lineno;
261258
262259 /* For use by front ends that need to store auxiliary data */
@@ -277,10 +274,6 @@ struct jump_key { · 14 unmodified lines
277274 struct menu *target;
278275 };
279276
280−extern struct file *file_list;
281−extern struct file *current_file;
282−struct file *lookup_file(const char *name);
283−
284277 extern struct symbol symbol_yes, symbol_no, symbol_mod;
285278 extern struct symbol *modules_sym;
286279 extern int cdebug;
scripts/kconfig/hashtable.h+48−0
@@ -0,0 +1,48 @@
1+/* SPDX-License-Identifier: GPL-2.0-only */
2+#ifndef HASHTABLE_H
3+#define HASHTABLE_H
4+
5+#include "array_size.h"
6+#include "list.h"
7+
8+#define HASH_SIZE(name) (ARRAY_SIZE(name))
9+
10+#define HASHTABLE_DECLARE(name, size) struct hlist_head name[size]
11+
12+#define HASHTABLE_DEFINE(name, size) \
13+ HASHTABLE_DECLARE(name, size) = \
14+ { [0 ... ((size) - 1)] = HLIST_HEAD_INIT }
15+
16+#define hash_head(table, key) (&(table)[(key) % HASH_SIZE(table)])
17+
18+/**
19+ * hash_add - add an object to a hashtable
20+ * @table: hashtable to add to
21+ * @node: the &struct hlist_node of the object to be added
22+ * @key: the key of the object to be added
23+ */
24+#define hash_add(table, node, key) \
25+ hlist_add_head(node, hash_head(table, key))
26+
27+/**
28+ * hash_for_each - iterate over a hashtable
29+ * @table: hashtable to iterate
30+ * @obj: the type * to use as a loop cursor for each entry
31+ * @member: the name of the hlist_node within the struct
32+ */
33+#define hash_for_each(table, obj, member) \
34+ for (int _bkt = 0; _bkt < HASH_SIZE(table); _bkt++) \
35+ hlist_for_each_entry(obj, &table[_bkt], member)
36+
37+/**
38+ * hash_for_each_possible - iterate over all possible objects hashing to the
39+ * same bucket
40+ * @table: hashtable to iterate
41+ * @obj: the type * to use as a loop cursor for each entry
42+ * @member: the name of the hlist_node within the struct
43+ * @key: the key of the objects to iterate over
44+ */
45+#define hash_for_each_possible(table, obj, member, key) \
46+ hlist_for_each_entry(obj, hash_head(table, key), member)
47+
48+#endif /* HASHTABLE_H */
scripts/kconfig/internal.h+12−0
@@ -2,8 +2,20 @@ · 1 unmodified line
22 #ifndef INTERNAL_H
33 #define INTERNAL_H
44
5+#include "hashtable.h"
6+
7+#define SYMBOL_HASHSIZE (1U << 14)
8+
9+extern HASHTABLE_DECLARE(sym_hashtable, SYMBOL_HASHSIZE);
10+
11+#define for_all_symbols(sym) \
12+ hash_for_each(sym_hashtable, sym, node)
13+
514 struct menu;
615
716 extern struct menu *current_menu, *current_entry;
817
18+extern const char *cur_filename;
19+extern int cur_lineno;
20+
921 #endif /* INTERNAL_H */
scripts/kconfig/lexer.l+61−69
@@ -14,16 +14,22 @@ · 13 unmodified lines
1414 #include <string.h>
1515
1616 #include "lkc.h"
17+#include "preprocess.h"
18+
1719 #include "parser.tab.h"
1820
1921 #define YY_DECL static int yylex1(void)
2022
2123 #define START_STRSIZE 16
2224
23−static struct {
24− struct file *file;
25− int lineno;
26−} current_pos;
25+/* The Kconfig file currently being parsed. */
26+const char *cur_filename;
27+
28+/*
29+ * The line number of the current statement. This does not match yylineno.
30+ * yylineno is used by the lexer, while cur_lineno is used by the parser.
31+ */
32+int cur_lineno;
2733
2834 static int prev_prev_token = T_EOL;
2935 static int prev_token = T_EOL;
@@ -33,6 +39,9 @@ static int text_size, text_asize; · 3 unmodified lines
3339 struct buffer {
3440 struct buffer *parent;
3541 YY_BUFFER_STATE state;
42+ int yylineno;
43+ const char *filename;
44+ int source_lineno;
3645 };
3746
3847 static struct buffer *current_buf;
@@ -77,7 +86,7 @@ static void warn_ignored_character(char chr) · 38 unmodified lines
7786 {
7887 fprintf(stderr,
7988 "%s:%d:warning: ignoring unsupported character '%c'\n",
80− current_file->name, yylineno, chr);
89+ cur_filename, yylineno, chr);
8190 }
8291 %}
8392
@@ -180,7 +189,7 @@ n [A-Za-z0-9_-] · 96 unmodified lines
180189 \n {
181190 fprintf(stderr,
182191 "%s:%d:warning: multi-line strings not supported\n",
183− zconf_curname(), zconf_lineno());
192+ cur_filename, cur_lineno);
184193 unput('\n');
185194 BEGIN(INITIAL);
186195 yylval.string = text;
@@ -246,9 +255,9 @@ n [A-Za-z0-9_-] · 59 unmodified lines
246255
247256 if (prev_token != T_EOL && prev_token != T_HELPTEXT)
248257 fprintf(stderr, "%s:%d:warning: no new line at end of file\n",
249− current_file->name, yylineno);
258+ cur_filename, yylineno);
250259
251− if (current_file) {
260+ if (current_buf) {
252261 zconf_endfile();
253262 return T_EOL;
254263 }
@@ -267,19 +276,17 @@ repeat: · 12 unmodified lines
267276 token = yylex1();
268277
269278 if (prev_token == T_EOL || prev_token == T_HELPTEXT) {
270− if (token == T_EOL) {
279+ if (token == T_EOL)
271280 /* Do not pass unneeded T_EOL to the parser. */
272281 goto repeat;
273− } else {
282+ else
274283 /*
275− * For the parser, update file/lineno at the first token
284+ * For the parser, update lineno at the first token
276285 * of each statement. Generally, \n is a statement
277286 * terminator in Kconfig, but it is not always true
278287 * because \n could be escaped by a backslash.
279288 */
280− current_pos.file = current_file;
281− current_pos.lineno = yylineno;
282− }
289+ cur_lineno = yylineno;
283290 }
284291
285292 if (prev_prev_token == T_EOL && prev_token == T_WORD &&
@@ -302,8 +309,11 @@ static char *expand_token(const char *in, size_t n) · 16 unmodified lines
302309 new_string();
303310 append_string(in, n);
304311
305− /* get the whole line because we do not know the end of token. */
306− while ((c = input()) != EOF) {
312+ /*
313+ * get the whole line because we do not know the end of token.
314+ * input() returns 0 (not EOF!) when it reachs the end of file.
315+ */
316+ while ((c = input()) != 0) {
307317 if (c == '\n') {
308318 unput(c);
309319 break;
@@ -391,78 +401,60 @@ void zconf_initscan(const char *name) · 81 unmodified lines
391401 exit(1);
392402 }
393403
394− current_buf = xmalloc(sizeof(*current_buf));
395− memset(current_buf, 0, sizeof(*current_buf));
396−
397− current_file = file_lookup(name);
404+ cur_filename = file_lookup(name);
398405 yylineno = 1;
399406 }
400407
401408 void zconf_nextfile(const char *name)
402409 {
403− struct file *iter;
404− struct file *file = file_lookup(name);
405410 struct buffer *buf = xmalloc(sizeof(*buf));
406− memset(buf, 0, sizeof(*buf));
411+ bool recur_include = false;
407412
408− current_buf->state = YY_CURRENT_BUFFER;
409− yyin = zconf_fopen(file->name);
413+ buf->state = YY_CURRENT_BUFFER;
414+ buf->yylineno = yylineno;
415+ buf->filename = cur_filename;
416+ buf->source_lineno = cur_lineno;
417+ buf->parent = current_buf;
418+ current_buf = buf;
419+ yyin = zconf_fopen(name);
410420 if (!yyin) {
411421 fprintf(stderr, "%s:%d: can't open file \"%s\"\n",
412− zconf_curname(), zconf_lineno(), file->name);
422+ cur_filename, cur_lineno, name);
413423 exit(1);
414424 }
415425 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
416− buf->parent = current_buf;
417− current_buf = buf;
418426
419− current_file->lineno = yylineno;
420− file->parent = current_file;
421−
422− for (iter = current_file; iter; iter = iter->parent) {
423− if (!strcmp(iter->name, file->name)) {
424− fprintf(stderr,
425− "Recursive inclusion detected.\n"
426− "Inclusion path:\n"
427− " current file : %s\n", file->name);
428− iter = file;
429− do {
430− iter = iter->parent;
431− fprintf(stderr, " included from: %s:%d\n",
432− iter->name, iter->lineno - 1);
433− } while (strcmp(iter->name, file->name));
434− exit(1);
435− }
427+ for (buf = current_buf; buf; buf = buf->parent) {
428+ if (!strcmp(buf->filename, name))
429+ recur_include = true;
436430 }
437431
438− yylineno = 1;
439− current_file = file;
440−}
441−
442−static void zconf_endfile(void)
443−{
444− struct buffer *parent;
445−
446− current_file = current_file->parent;
447− if (current_file)
448− yylineno = current_file->lineno;
432+ if (recur_include) {
433+ fprintf(stderr,
434+ "Recursive inclusion detected.\n"
435+ "Inclusion path:\n"
436+ " current file : %s\n", name);
449437
450− parent = current_buf->parent;
451− if (parent) {
452− fclose(yyin);
453− yy_delete_buffer(YY_CURRENT_BUFFER);
454− yy_switch_to_buffer(parent->state);
438+ for (buf = current_buf; buf; buf = buf->parent)
439+ fprintf(stderr, " included from: %s:%d\n",
440+ buf->filename, buf->source_lineno);
441+ exit(1);
455442 }
456− free(current_buf);
457− current_buf = parent;
458−}
459443
460−int zconf_lineno(void)
461−{
462− return current_pos.lineno;
444+ yylineno = 1;
445+ cur_filename = file_lookup(name);
463446 }
464447
465−const char *zconf_curname(void)
448+static void zconf_endfile(void)
466449 {
467− return current_pos.file ? current_pos.file->name : "<none>";
450+ struct buffer *tmp;
451+
452+ fclose(yyin);
453+ yy_delete_buffer(YY_CURRENT_BUFFER);
454+ yy_switch_to_buffer(current_buf->state);
455+ yylineno = current_buf->yylineno;
456+ cur_filename = current_buf->filename;
457+ tmp = current_buf;
458+ current_buf = current_buf->parent;
459+ free(tmp);
468460 }
scripts/kconfig/list.h+189−65
@@ -2,29 +2,39 @@ · 1 unmodified line
22 #ifndef LIST_H
33 #define LIST_H
44
5−/*
6− * Copied from include/linux/...
7− */
5+#include <stddef.h>
86
9−#undef offsetof
10−#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
7+#include "list_types.h"
8+
9+/* Are two types/vars the same type (ignoring qualifiers)? */
10+#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
1111
1212 /**
1313 * container_of - cast a member of a structure out to the containing structure
14− * @ptr: the pointer to the member.
15− * @type: the type of the container struct this is embedded in.
16− * @member: the name of the member within the struct.
14+ * @ptr: the pointer to the member.
15+ * @type: the type of the container struct this is embedded in.
16+ * @member: the name of the member within the struct.
1717 *
1818 */
19−#define container_of(ptr, type, member) ({ \
20− const typeof( ((type *)0)->member ) *__mptr = (ptr); \
21− (type *)( (char *)__mptr - offsetof(type,member) );})
22−
19+#define container_of(ptr, type, member) ({ \
20+ void *__mptr = (void *)(ptr); \
21+ _Static_assert(__same_type(*(ptr), ((type *)0)->member) || \
22+ __same_type(*(ptr), void), \
23+ "pointer type mismatch in container_of()"); \
24+ ((type *)(__mptr - offsetof(type, member))); })
2325
24−struct list_head {
25− struct list_head *next, *prev;
26−};
26+#define LIST_POISON1 ((void *) 0x100)
27+#define LIST_POISON2 ((void *) 0x122)
2728
29+/*
30+ * Circular doubly linked list implementation.
31+ *
32+ * Some of the internal functions ("__xxx") are useful when
33+ * manipulating whole lists rather than single entries, as
34+ * sometimes we already know the next/prev entries and we can
35+ * generate better code by using them directly rather than
36+ * using the generic single-entry routines.
37+ */
2838
2939 #define LIST_HEAD_INIT(name) { &(name), &(name) }
3040
@@ -32,45 +42,16 @@ struct list_head { · 1 unmodified line
3242 struct list_head name = LIST_HEAD_INIT(name)
3343
3444 /**
35− * list_entry - get the struct for this entry
36− * @ptr: the &struct list_head pointer.
37− * @type: the type of the struct this is embedded in.
38− * @member: the name of the list_head within the struct.
39− */
40−#define list_entry(ptr, type, member) \
41− container_of(ptr, type, member)
42−
43−/**
44− * list_for_each_entry - iterate over list of given type
45− * @pos: the type * to use as a loop cursor.
46− * @head: the head for your list.
47− * @member: the name of the list_head within the struct.
48− */
49−#define list_for_each_entry(pos, head, member) \
50− for (pos = list_entry((head)->next, typeof(*pos), member); \
51− &pos->member != (head); \
52− pos = list_entry(pos->member.next, typeof(*pos), member))
53−
54−/**
55− * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
56− * @pos: the type * to use as a loop cursor.
57− * @n: another type * to use as temporary storage
58− * @head: the head for your list.
59− * @member: the name of the list_head within the struct.
60− */
61−#define list_for_each_entry_safe(pos, n, head, member) \
62− for (pos = list_entry((head)->next, typeof(*pos), member), \
63− n = list_entry(pos->member.next, typeof(*pos), member); \
64− &pos->member != (head); \
65− pos = n, n = list_entry(n->member.next, typeof(*n), member))
66−
67−/**
68− * list_empty - tests whether a list is empty
69− * @head: the list to test.
45+ * INIT_LIST_HEAD - Initialize a list_head structure
46+ * @list: list_head structure to be initialized.
47+ *
48+ * Initializes the list_head to point to itself. If it is a list header,
49+ * the result is an empty list.
7050 */
71−static inline int list_empty(const struct list_head *head)
51+static inline void INIT_LIST_HEAD(struct list_head *list)
7252 {
73− return head->next == head;
53+ list->next = list;
54+ list->prev = list;
7455 }
7556
7657 /*
@@ -79,14 +60,27 @@ static inline int list_empty(const struct list_head *head) · 2 unmodified lines
7960 * This is only for internal list manipulation where we know
8061 * the prev/next entries already!
8162 */
82−static inline void __list_add(struct list_head *_new,
63+static inline void __list_add(struct list_head *new,
8364 struct list_head *prev,
8465 struct list_head *next)
8566 {
86− next->prev = _new;
87− _new->next = next;
88− _new->prev = prev;
89− prev->next = _new;
67+ next->prev = new;
68+ new->next = next;
69+ new->prev = prev;
70+ prev->next = new;
71+}
72+
73+/**
74+ * list_add - add a new entry
75+ * @new: new entry to be added
76+ * @head: list head to add it after
77+ *
78+ * Insert a new entry after the specified head.
79+ * This is good for implementing stacks.
80+ */
81+static inline void list_add(struct list_head *new, struct list_head *head)
82+{
83+ __list_add(new, head, head->next);
9084 }
9185
9286 /**
@@ -97,9 +91,9 @@ static inline void __list_add(struct list_head *_new, · 4 unmodified lines
9791 * Insert a new entry before the specified head.
9892 * This is useful for implementing queues.
9993 */
100−static inline void list_add_tail(struct list_head *_new, struct list_head *head)
94+static inline void list_add_tail(struct list_head *new, struct list_head *head)
10195 {
102− __list_add(_new, head->prev, head);
96+ __list_add(new, head->prev, head);
10397 }
10498
10599 /*
@@ -115,8 +109,11 @@ static inline void __list_del(struct list_head *prev, struct list_head *next) · 9 unmodified lines
115109 prev->next = next;
116110 }
117111
118−#define LIST_POISON1 ((void *) 0x00100100)
119−#define LIST_POISON2 ((void *) 0x00200200)
112+static inline void __list_del_entry(struct list_head *entry)
113+{
114+ __list_del(entry->prev, entry->next);
115+}
116+
120117 /**
121118 * list_del - deletes entry from list.
122119 * @entry: the element to delete from the list.
@@ -125,8 +122,135 @@ static inline void __list_del(struct list_head *prev, struct list_head *next) · 2 unmodified lines
125122 */
126123 static inline void list_del(struct list_head *entry)
127124 {
128− __list_del(entry->prev, entry->next);
129− entry->next = (struct list_head*)LIST_POISON1;
130− entry->prev = (struct list_head*)LIST_POISON2;
125+ __list_del_entry(entry);
126+ entry->next = LIST_POISON1;
127+ entry->prev = LIST_POISON2;
128+}
129+
130+/**
131+ * list_is_head - tests whether @list is the list @head
132+ * @list: the entry to test
133+ * @head: the head of the list
134+ */
135+static inline int list_is_head(const struct list_head *list, const struct list_head *head)
136+{
137+ return list == head;
138+}
139+
140+/**
141+ * list_empty - tests whether a list is empty
142+ * @head: the list to test.
143+ */
144+static inline int list_empty(const struct list_head *head)
145+{
146+ return head->next == head;
147+}
148+
149+/**
150+ * list_entry - get the struct for this entry
151+ * @ptr: the &struct list_head pointer.
152+ * @type: the type of the struct this is embedded in.
153+ * @member: the name of the list_head within the struct.
154+ */
155+#define list_entry(ptr, type, member) \
156+ container_of(ptr, type, member)
157+
158+/**
159+ * list_first_entry - get the first element from a list
160+ * @ptr: the list head to take the element from.
161+ * @type: the type of the struct this is embedded in.
162+ * @member: the name of the list_head within the struct.
163+ *
164+ * Note, that list is expected to be not empty.
165+ */
166+#define list_first_entry(ptr, type, member) \
167+ list_entry((ptr)->next, type, member)
168+
169+/**
170+ * list_next_entry - get the next element in list
171+ * @pos: the type * to cursor
172+ * @member: the name of the list_head within the struct.
173+ */
174+#define list_next_entry(pos, member) \
175+ list_entry((pos)->member.next, typeof(*(pos)), member)
176+
177+/**
178+ * list_entry_is_head - test if the entry points to the head of the list
179+ * @pos: the type * to cursor
180+ * @head: the head for your list.
181+ * @member: the name of the list_head within the struct.
182+ */
183+#define list_entry_is_head(pos, head, member) \
184+ (&pos->member == (head))
185+
186+/**
187+ * list_for_each_entry - iterate over list of given type
188+ * @pos: the type * to use as a loop cursor.
189+ * @head: the head for your list.
190+ * @member: the name of the list_head within the struct.
191+ */
192+#define list_for_each_entry(pos, head, member) \
193+ for (pos = list_first_entry(head, typeof(*pos), member); \
194+ !list_entry_is_head(pos, head, member); \
195+ pos = list_next_entry(pos, member))
196+
197+/**
198+ * list_for_each_entry_safe - iterate over list of given type. Safe against removal of list entry
199+ * @pos: the type * to use as a loop cursor.
200+ * @n: another type * to use as temporary storage
201+ * @head: the head for your list.
202+ * @member: the name of the list_head within the struct.
203+ */
204+#define list_for_each_entry_safe(pos, n, head, member) \
205+ for (pos = list_first_entry(head, typeof(*pos), member), \
206+ n = list_next_entry(pos, member); \
207+ !list_entry_is_head(pos, head, member); \
208+ pos = n, n = list_next_entry(n, member))
209+
210+/*
211+ * Double linked lists with a single pointer list head.
212+ * Mostly useful for hash tables where the two pointer list head is
213+ * too wasteful.
214+ * You lose the ability to access the tail in O(1).
215+ */
216+
217+#define HLIST_HEAD_INIT { .first = NULL }
218+
219+/**
220+ * hlist_add_head - add a new entry at the beginning of the hlist
221+ * @n: new entry to be added
222+ * @h: hlist head to add it after
223+ *
224+ * Insert a new entry after the specified head.
225+ * This is good for implementing stacks.
226+ */
227+static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
228+{
229+ struct hlist_node *first = h->first;
230+
231+ n->next = first;
232+ if (first)
233+ first->pprev = &n->next;
234+ h->first = n;
235+ n->pprev = &h->first;
131236 }
132−#endif
237+
238+#define hlist_entry(ptr, type, member) container_of(ptr, type, member)
239+
240+#define hlist_entry_safe(ptr, type, member) \
241+ ({ typeof(ptr) ____ptr = (ptr); \
242+ ____ptr ? hlist_entry(____ptr, type, member) : NULL; \
243+ })
244+
245+/**
246+ * hlist_for_each_entry - iterate over list of given type
247+ * @pos: the type * to use as a loop cursor.
248+ * @head: the head for your list.
249+ * @member: the name of the hlist_node within the struct.
250+ */
251+#define hlist_for_each_entry(pos, head, member) \
252+ for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
253+ pos; \
254+ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
255+
256+#endif /* LIST_H */
scripts/kconfig/list_types.h+17−0
@@ -0,0 +1,17 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+#ifndef LIST_TYPES_H
3+#define LIST_TYPES_H
4+
5+struct list_head {
6+ struct list_head *next, *prev;
7+};
8+
9+struct hlist_head {
10+ struct hlist_node *first;
11+};
12+
13+struct hlist_node {
14+ struct hlist_node *next, **pprev;
15+};
16+
17+#endif /* LIST_TYPES_H */
scripts/kconfig/lkc.h+3−3
@@ -36,10 +36,9 @@ void zconf_starthelp(void); · 35 unmodified lines
3636 FILE *zconf_fopen(const char *name);
3737 void zconf_initscan(const char *name);
3838 void zconf_nextfile(const char *name);
39−int zconf_lineno(void);
40−const char *zconf_curname(void);
4139
4240 /* confdata.c */
41+extern struct gstr autoconf_cmd;
4342 const char *conf_get_configname(void);
4443 void set_all_choice_values(struct symbol *csym);
4544
@@ -53,7 +52,8 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) · 7 unmodified lines
5352 }
5453
5554 /* util.c */
56−struct file *file_lookup(const char *name);
55+unsigned int strhash(const char *s);
56+const char *file_lookup(const char *name);
5757 void *xmalloc(size_t size);
5858 void *xcalloc(size_t nmemb, size_t size);
5959 void *xrealloc(void *p, size_t size);
scripts/kconfig/lkc_proto.h+0−15
@@ -18,8 +18,6 @@ void conf_set_message_callback(void (*fn)(const char *s)); · 17 unmodified lines
1818 bool conf_errors(void);
1919
2020 /* symbol.c */
21−extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
22−
2321 struct symbol * sym_lookup(const char *name, int flags);
2422 struct symbol * sym_find(const char *name);
2523 void print_symbol_for_listconfig(struct symbol *sym);
@@ -40,19 +38,6 @@ const char * sym_get_string_value(struct symbol *sym); · 14 unmodified lines
4038
4139 const char * prop_get_type_name(enum prop_type type);
4240
43−/* preprocess.c */
44−enum variable_flavor {
45− VAR_SIMPLE,
46− VAR_RECURSIVE,
47− VAR_APPEND,
48−};
49−void env_write_dep(FILE *f, const char *auto_conf_name);
50−void variable_add(const char *name, const char *value,
51− enum variable_flavor flavor);
52−void variable_all_del(void);
53−char *expand_dollar(const char **str);
54−char *expand_one_token(const char **str);
55−
5641 /* expr.c */
5742 void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken);
5843
scripts/kconfig/lxdialog/checklist.c+2−3
@@ -188,9 +188,8 @@ do_resize: · 187 unmodified lines
188188
189189 print_buttons(dialog, height, width, 0);
190190
191− wnoutrefresh(dialog);
192− wnoutrefresh(list);
193− doupdate();
191+ wmove(list, choice, check_x + 1);
192+ wrefresh(list);
194193
195194 while (key != KEY_ESC) {
196195 key = wgetch(dialog);
scripts/kconfig/lxdialog/dialog.h+0−4
@@ -91,10 +91,6 @@ struct dialog_info { · 90 unmodified lines
9191 struct dialog_color button_label_active;
9292 struct dialog_color button_label_inactive;
9393 struct dialog_color inputbox;
94− struct dialog_color inputbox_border;
95− struct dialog_color searchbox;
96− struct dialog_color searchbox_title;
97− struct dialog_color searchbox_border;
9894 struct dialog_color position_indicator;
9995 struct dialog_color menubox;
10096 struct dialog_color menubox_border;
scripts/kconfig/lxdialog/util.c+1−19
@@ -29,10 +29,6 @@ static void set_mono_theme(void) · 28 unmodified lines
2929 dlg.button_label_active.atr = A_REVERSE;
3030 dlg.button_label_inactive.atr = A_NORMAL;
3131 dlg.inputbox.atr = A_NORMAL;
32− dlg.inputbox_border.atr = A_NORMAL;
33− dlg.searchbox.atr = A_NORMAL;
34− dlg.searchbox_title.atr = A_BOLD;
35− dlg.searchbox_border.atr = A_NORMAL;
3632 dlg.position_indicator.atr = A_BOLD;
3733 dlg.menubox.atr = A_NORMAL;
3834 dlg.menubox_border.atr = A_NORMAL;
@@ -69,10 +65,6 @@ static void set_classic_theme(void) · 30 unmodified lines
6965 DLG_COLOR(button_label_active, COLOR_YELLOW, COLOR_BLUE, true);
7066 DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_WHITE, true);
7167 DLG_COLOR(inputbox, COLOR_BLACK, COLOR_WHITE, false);
72− DLG_COLOR(inputbox_border, COLOR_BLACK, COLOR_WHITE, false);
73− DLG_COLOR(searchbox, COLOR_BLACK, COLOR_WHITE, false);
74− DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_WHITE, true);
75− DLG_COLOR(searchbox_border, COLOR_WHITE, COLOR_WHITE, true);
7668 DLG_COLOR(position_indicator, COLOR_YELLOW, COLOR_WHITE, true);
7769 DLG_COLOR(menubox, COLOR_BLACK, COLOR_WHITE, false);
7870 DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true);
@@ -101,14 +93,9 @@ static void set_blackbg_theme(void) · 22 unmodified lines
10193 DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_RED, true);
10294 DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_BLACK, false);
10395 DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_RED, false);
104− DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_BLACK, true);
96+ DLG_COLOR(button_label_inactive, COLOR_WHITE, COLOR_BLACK, false);
10597
10698 DLG_COLOR(inputbox, COLOR_YELLOW, COLOR_BLACK, false);
107− DLG_COLOR(inputbox_border, COLOR_YELLOW, COLOR_BLACK, false);
108−
109− DLG_COLOR(searchbox, COLOR_YELLOW, COLOR_BLACK, false);
110− DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_BLACK, true);
111− DLG_COLOR(searchbox_border, COLOR_BLACK, COLOR_BLACK, true);
11299
113100 DLG_COLOR(position_indicator, COLOR_RED, COLOR_BLACK, false);
114101
@@ -136,7 +123,6 @@ static void set_bluetitle_theme(void) · 21 unmodified lines
136123 DLG_COLOR(title, COLOR_BLUE, COLOR_WHITE, true);
137124 DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_BLUE, true);
138125 DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_BLUE, true);
139− DLG_COLOR(searchbox_title, COLOR_BLUE, COLOR_WHITE, true);
140126 DLG_COLOR(position_indicator, COLOR_BLUE, COLOR_WHITE, true);
141127 DLG_COLOR(tag, COLOR_BLUE, COLOR_WHITE, true);
142128 DLG_COLOR(tag_key, COLOR_BLUE, COLOR_WHITE, true);
@@ -189,10 +175,6 @@ static void init_dialog_colors(void) · 46 unmodified lines
189175 init_one_color(&dlg.button_label_active);
190176 init_one_color(&dlg.button_label_inactive);
191177 init_one_color(&dlg.inputbox);
192− init_one_color(&dlg.inputbox_border);
193− init_one_color(&dlg.searchbox);
194− init_one_color(&dlg.searchbox_title);
195− init_one_color(&dlg.searchbox_border);
196178 init_one_color(&dlg.position_indicator);
197179 init_one_color(&dlg.menubox);
198180 init_one_color(&dlg.menubox_border);
scripts/kconfig/mconf.c+1−0
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <signal.h>
2020 #include <unistd.h>
2121
22+#include "list.h"
2223 #include "lkc.h"
2324 #include "lxdialog/dialog.h"
2425 #include "mnconf-common.h"
scripts/kconfig/menu.c+20−28
@@ -10,20 +10,18 @@ · 9 unmodified lines
1010
1111 #include "lkc.h"
1212 #include "internal.h"
13+#include "list.h"
1314
1415 static const char nohelp_text[] = "There is no help available for this option.";
1516
1617 struct menu rootmenu;
1718 static struct menu **last_entry_ptr;
1819
19−struct file *file_list;
20−struct file *current_file;
21−
2220 void menu_warn(struct menu *menu, const char *fmt, ...)
2321 {
2422 va_list ap;
2523 va_start(ap, fmt);
26− fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno);
24+ fprintf(stderr, "%s:%d:warning: ", menu->filename, menu->lineno);
2725 vfprintf(stderr, fmt, ap);
2826 fprintf(stderr, "\n");
2927 va_end(ap);
@@ -33,7 +31,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...) · 3 unmodified lines
3331 {
3432 va_list ap;
3533 va_start(ap, fmt);
36− fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno);
34+ fprintf(stderr, "%s:%d:warning: ", prop->filename, prop->lineno);
3735 vfprintf(stderr, fmt, ap);
3836 fprintf(stderr, "\n");
3937 va_end(ap);
@@ -53,14 +51,16 @@ void menu_add_entry(struct symbol *sym) · 13 unmodified lines
5351 memset(menu, 0, sizeof(*menu));
5452 menu->sym = sym;
5553 menu->parent = current_menu;
56− menu->file = current_file;
57− menu->lineno = zconf_lineno();
54+ menu->filename = cur_filename;
55+ menu->lineno = cur_lineno;
5856
5957 *last_entry_ptr = menu;
6058 last_entry_ptr = &menu->next;
6159 current_entry = menu;
62− if (sym)
60+ if (sym) {
6361 menu_add_symbol(P_SYMBOL, sym, NULL);
62+ list_add_tail(&menu->link, &sym->menus);
63+ }
6464 }
6565
6666 struct menu *menu_add_menu(void)
@@ -134,8 +134,8 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr, · 67 unmodified lines
134134 prop = xmalloc(sizeof(*prop));
135135 memset(prop, 0, sizeof(*prop));
136136 prop->type = type;
137− prop->file = current_file;
138− prop->lineno = zconf_lineno();
137+ prop->filename = cur_filename;
138+ prop->lineno = cur_lineno;
139139 prop->menu = current_entry;
140140 prop->expr = expr;
141141 prop->visible.expr = dep;
@@ -307,12 +307,6 @@ void menu_finalize(struct menu *parent) · 165 unmodified lines
307307 }
308308 }
309309 }
310− /* set the type of the remaining choice values */
311− for (menu = parent->list; menu; menu = menu->next) {
312− current_entry = menu;
313− if (menu->sym && menu->sym->type == S_UNKNOWN)
314− menu_set_type(sym->type);
315− }
316310
317311 /*
318312 * Use the choice itself as the parent dependency of
@@ -567,9 +561,6 @@ void menu_finalize(struct menu *parent) · 248 unmodified lines
567561 if (sym->type == S_UNKNOWN)
568562 menu_warn(parent, "config symbol defined without type");
569563
570− if (sym_is_choice(sym) && !parent->prompt)
571− menu_warn(parent, "choice must have a prompt");
572−
573564 /* Check properties connected to this symbol */
574565 sym_check_prop(sym);
575566 sym->flags |= SYMBOL_WARNED;
@@ -676,7 +667,7 @@ struct menu *menu_get_parent_menu(struct menu *menu) · 100 unmodified lines
676667 static void get_def_str(struct gstr *r, struct menu *menu)
677668 {
678669 str_printf(r, "Defined at %s:%d\n",
679− menu->file->name, menu->lineno);
670+ menu->filename, menu->lineno);
680671 }
681672
682673 static void get_dep_str(struct gstr *r, struct expr *expr, const char *prefix)
@@ -777,6 +768,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, · 94 unmodified lines
777768 struct list_head *head)
778769 {
779770 struct property *prop;
771+ struct menu *menu;
780772
781773 if (sym && sym->name) {
782774 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
@@ -793,17 +785,17 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, · 10 unmodified lines
793785 }
794786
795787 /* Print the definitions with prompts before the ones without */
796− for_all_properties(sym, prop, P_SYMBOL) {
797− if (prop->menu->prompt) {
798− get_def_str(r, prop->menu);
799− get_prompt_str(r, prop->menu->prompt, head);
788+ list_for_each_entry(menu, &sym->menus, link) {
789+ if (menu->prompt) {
790+ get_def_str(r, menu);
791+ get_prompt_str(r, menu->prompt, head);
800792 }
801793 }
802794
803− for_all_properties(sym, prop, P_SYMBOL) {
804− if (!prop->menu->prompt) {
805− get_def_str(r, prop->menu);
806− get_dep_str(r, prop->menu->dep, " Depends on: ");
795+ list_for_each_entry(menu, &sym->menus, link) {
796+ if (!menu->prompt) {
797+ get_def_str(r, menu);
798+ get_dep_str(r, menu->dep, " Depends on: ");
807799 }
808800 }
809801
scripts/kconfig/nconf.c+1−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <strings.h>
1212 #include <stdlib.h>
1313
14+#include "list.h"
1415 #include "lkc.h"
1516 #include "mnconf-common.h"
1617 #include "nconf.h"
scripts/kconfig/parser.y+76−49
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313
1414 #include "lkc.h"
1515 #include "internal.h"
16+#include "preprocess.h"
1617
1718 #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
1819
@@ -27,8 +28,6 @@ static void zconf_error(const char *err, ...); · 8 unmodified lines
2728 static bool zconf_endtoken(const char *tokenname,
2829 const char *expected_tokenname);
2930
30−struct symbol *symbol_hash[SYMBOL_HASHSIZE];
31−
3231 struct menu *current_menu, *current_entry;
3332
3433 %}
@@ -95,12 +94,12 @@ struct menu *current_menu, *current_entry; · 60 unmodified lines
9594 %type <expr> if_expr
9695 %type <string> end
9796 %type <menu> if_entry menu_entry choice_entry
98−%type <string> word_opt assign_val
97+%type <string> assign_val
9998 %type <flavor> assign_op
10099
101100 %destructor {
102101 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
103− $$->file->name, $$->lineno);
102+ $$->filename, $$->lineno);
104103 if (current_menu == $$)
105104 menu_end_menu();
106105 } if_entry menu_entry choice_entry
@@ -143,19 +142,19 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL · 36 unmodified lines
143142 {
144143 $2->flags |= SYMBOL_OPTIONAL;
145144 menu_add_entry($2);
146− printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name);
145+ printd(DEBUG_PARSE, "%s:%d:config %s\n", cur_filename, cur_lineno, $2->name);
147146 };
148147
149148 config_stmt: config_entry_start config_option_list
150149 {
151− printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
150+ printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
152151 };
153152
154153 menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL
155154 {
156155 $2->flags |= SYMBOL_OPTIONAL;
157156 menu_add_entry($2);
158− printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name);
157+ printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", cur_filename, cur_lineno, $2->name);
159158 };
160159
161160 menuconfig_stmt: menuconfig_entry_start config_option_list
@@ -164,7 +163,7 @@ menuconfig_stmt: menuconfig_entry_start config_option_list · 2 unmodified lines
164163 current_entry->prompt->type = P_MENU;
165164 else
166165 zconfprint("warning: menuconfig statement without prompt");
167− printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
166+ printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
168167 };
169168
170169 config_option_list:
@@ -177,15 +176,13 @@ config_option_list: · 6 unmodified lines
177176 config_option: type prompt_stmt_opt T_EOL
178177 {
179178 menu_set_type($1);
180− printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
181− zconf_curname(), zconf_lineno(),
182− $1);
179+ printd(DEBUG_PARSE, "%s:%d:type(%u)\n", cur_filename, cur_lineno, $1);
183180 };
184181
185182 config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
186183 {
187184 menu_add_prompt(P_PROMPT, $2, $3);
188− printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
185+ printd(DEBUG_PARSE, "%s:%d:prompt\n", cur_filename, cur_lineno);
189186 };
190187
191188 config_option: default expr if_expr T_EOL
@@ -193,27 +190,26 @@ config_option: default expr if_expr T_EOL · 1 unmodified line
193190 menu_add_expr(P_DEFAULT, $2, $3);
194191 if ($1 != S_UNKNOWN)
195192 menu_set_type($1);
196− printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
197− zconf_curname(), zconf_lineno(),
193+ printd(DEBUG_PARSE, "%s:%d:default(%u)\n", cur_filename, cur_lineno,
198194 $1);
199195 };
200196
201197 config_option: T_SELECT nonconst_symbol if_expr T_EOL
202198 {
203199 menu_add_symbol(P_SELECT, $2, $3);
204− printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
200+ printd(DEBUG_PARSE, "%s:%d:select\n", cur_filename, cur_lineno);
205201 };
206202
207203 config_option: T_IMPLY nonconst_symbol if_expr T_EOL
208204 {
209205 menu_add_symbol(P_IMPLY, $2, $3);
210− printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
206+ printd(DEBUG_PARSE, "%s:%d:imply\n", cur_filename, cur_lineno);
211207 };
212208
213209 config_option: T_RANGE symbol symbol if_expr T_EOL
214210 {
215211 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
216− printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
212+ printd(DEBUG_PARSE, "%s:%d:range\n", cur_filename, cur_lineno);
217213 };
218214
219215 config_option: T_MODULES T_EOL
@@ -226,18 +222,23 @@ config_option: T_MODULES T_EOL · 6 unmodified lines
226222
227223 /* choice entry */
228224
229−choice: T_CHOICE word_opt T_EOL
225+choice: T_CHOICE T_EOL
230226 {
231− struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);
227+ struct symbol *sym = sym_lookup(NULL, SYMBOL_CHOICE);
232228 sym->flags |= SYMBOL_NO_WRITE;
233229 menu_add_entry(sym);
234230 menu_add_expr(P_CHOICE, NULL, NULL);
235− free($2);
236− printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
231+ printd(DEBUG_PARSE, "%s:%d:choice\n", cur_filename, cur_lineno);
237232 };
238233
239234 choice_entry: choice choice_option_list
240235 {
236+ if (!current_entry->prompt) {
237+ fprintf(stderr, "%s:%d: error: choice must have a prompt\n",
238+ current_entry->filename, current_entry->lineno);
239+ yynerrs++;
240+ }
241+
241242 $$ = menu_add_menu();
242243 };
243244
@@ -245,7 +246,7 @@ choice_end: end · 1 unmodified line
245246 {
246247 if (zconf_endtoken($1, "choice")) {
247248 menu_end_menu();
248− printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
249+ printd(DEBUG_PARSE, "%s:%d:endchoice\n", cur_filename, cur_lineno);
249250 }
250251 };
251252
@@ -262,27 +263,25 @@ choice_option_list: · 10 unmodified lines
262263 choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
263264 {
264265 menu_add_prompt(P_PROMPT, $2, $3);
265− printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
266+ printd(DEBUG_PARSE, "%s:%d:prompt\n", cur_filename, cur_lineno);
266267 };
267268
268269 choice_option: logic_type prompt_stmt_opt T_EOL
269270 {
270271 menu_set_type($1);
271− printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
272− zconf_curname(), zconf_lineno(), $1);
272+ printd(DEBUG_PARSE, "%s:%d:type(%u)\n", cur_filename, cur_lineno, $1);
273273 };
274274
275275 choice_option: T_OPTIONAL T_EOL
276276 {
277277 current_entry->sym->flags |= SYMBOL_OPTIONAL;
278− printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
278+ printd(DEBUG_PARSE, "%s:%d:optional\n", cur_filename, cur_lineno);
279279 };
280280
281281 choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
282282 {
283283 menu_add_symbol(P_DEFAULT, $2, $3);
284− printd(DEBUG_PARSE, "%s:%d:default\n",
285− zconf_curname(), zconf_lineno());
284+ printd(DEBUG_PARSE, "%s:%d:default\n", cur_filename, cur_lineno);
286285 };
287286
288287 type:
@@ -304,7 +303,7 @@ default: · 15 unmodified lines
304303
305304 if_entry: T_IF expr T_EOL
306305 {
307− printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
306+ printd(DEBUG_PARSE, "%s:%d:if\n", cur_filename, cur_lineno);
308307 menu_add_entry(NULL);
309308 menu_add_dep($2);
310309 $$ = menu_add_menu();
@@ -314,7 +313,7 @@ if_end: end · 3 unmodified lines
314313 {
315314 if (zconf_endtoken($1, "if")) {
316315 menu_end_menu();
317− printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
316+ printd(DEBUG_PARSE, "%s:%d:endif\n", cur_filename, cur_lineno);
318317 }
319318 };
320319
@@ -330,7 +329,7 @@ menu: T_MENU T_WORD_QUOTE T_EOL · 9 unmodified lines
330329 {
331330 menu_add_entry(NULL);
332331 menu_add_prompt(P_MENU, $2, NULL);
333− printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
332+ printd(DEBUG_PARSE, "%s:%d:menu\n", cur_filename, cur_lineno);
334333 };
335334
336335 menu_entry: menu menu_option_list
@@ -342,7 +341,7 @@ menu_end: end · 5 unmodified lines
342341 {
343342 if (zconf_endtoken($1, "menu")) {
344343 menu_end_menu();
345− printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
344+ printd(DEBUG_PARSE, "%s:%d:endmenu\n", cur_filename, cur_lineno);
346345 }
347346 };
348347
@@ -357,7 +356,7 @@ menu_option_list: · 8 unmodified lines
357356
358357 source_stmt: T_SOURCE T_WORD_QUOTE T_EOL
359358 {
360− printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
359+ printd(DEBUG_PARSE, "%s:%d:source %s\n", cur_filename, cur_lineno, $2);
361360 zconf_nextfile($2);
362361 free($2);
363362 };
@@ -368,7 +367,7 @@ comment: T_COMMENT T_WORD_QUOTE T_EOL · 4 unmodified lines
368367 {
369368 menu_add_entry(NULL);
370369 menu_add_prompt(P_COMMENT, $2, NULL);
371− printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
370+ printd(DEBUG_PARSE, "%s:%d:comment\n", cur_filename, cur_lineno);
372371 };
373372
374373 comment_stmt: comment comment_option_list
@@ -383,7 +382,7 @@ comment_option_list: · 8 unmodified lines
383382
384383 help_start: T_HELP T_EOL
385384 {
386− printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
385+ printd(DEBUG_PARSE, "%s:%d:help\n", cur_filename, cur_lineno);
387386 zconf_starthelp();
388387 };
389388
@@ -408,7 +407,7 @@ help: help_start T_HELPTEXT · 18 unmodified lines
408407 depends: T_DEPENDS T_ON expr T_EOL
409408 {
410409 menu_add_dep($3);
411− printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
410+ printd(DEBUG_PARSE, "%s:%d:depends on\n", cur_filename, cur_lineno);
412411 };
413412
414413 /* visibility option */
@@ -455,9 +454,6 @@ symbol: nonconst_symbol · 40 unmodified lines
455454 | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); }
456455 ;
457456
458−word_opt: /* empty */ { $$ = NULL; }
459− | T_WORD
460−
461457 /* assignment statement */
462458
463459 assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }
@@ -477,8 +473,11 @@ assign_val: · 13 unmodified lines
477473
478474 void conf_parse(const char *name)
479475 {
480− struct symbol *sym;
481− int i;
476+ struct menu *menu;
477+
478+ autoconf_cmd = str_new();
479+
480+ str_printf(&autoconf_cmd, "\ndeps_config := \\\n");
482481
483482 zconf_initscan(name);
484483
@@ -488,13 +487,28 @@ void conf_parse(const char *name) · 3 unmodified lines
488487 yydebug = 1;
489488 yyparse();
490489
490+ /*
491+ * FIXME:
492+ * cur_filename and cur_lineno are used even after yyparse();
493+ * menu_finalize() calls menu_add_symbol(). This should be fixed.
494+ */
495+ cur_filename = "<none>";
496+ cur_lineno = 0;
497+
498+ str_printf(&autoconf_cmd,
499+ "\n"
500+ "$(autoconfig): $(deps_config)\n"
501+ "$(deps_config): ;\n");
502+
503+ env_write_dep(&autoconf_cmd);
504+
491505 /* Variables are expanded in the parse phase. We can free them here. */
492506 variable_all_del();
493507
494508 if (yynerrs)
495509 exit(1);
496510 if (!modules_sym)
497− modules_sym = sym_find( "n" );
511+ modules_sym = &symbol_no;
498512
499513 if (!menu_has_prompt(&rootmenu)) {
500514 current_entry = &rootmenu;
@@ -502,10 +516,23 @@ void conf_parse(const char *name) · 1 unmodified line
502516 }
503517
504518 menu_finalize(&rootmenu);
505− for_all_symbols(i, sym) {
506− if (sym_check_deps(sym))
519+
520+ menu = &rootmenu;
521+ while (menu) {
522+ if (menu->sym && sym_check_deps(menu->sym))
507523 yynerrs++;
524+
525+ if (menu->list) {
526+ menu = menu->list;
527+ continue;
528+ }
529+
530+ while (!menu->next && menu->parent)
531+ menu = menu->parent;
532+
533+ menu = menu->next;
508534 }
535+
509536 if (yynerrs)
510537 exit(1);
511538 conf_set_changed(true);
@@ -520,11 +547,11 @@ static bool zconf_endtoken(const char *tokenname, · 8 unmodified lines
520547 yynerrs++;
521548 return false;
522549 }
523− if (current_menu->file != current_file) {
550+ if (strcmp(current_menu->filename, cur_filename)) {
524551 zconf_error("'%s' in different file than '%s'",
525552 tokenname, expected_tokenname);
526553 fprintf(stderr, "%s:%d: location of the '%s'\n",
527− current_menu->file->name, current_menu->lineno,
554+ current_menu->filename, current_menu->lineno,
528555 expected_tokenname);
529556 yynerrs++;
530557 return false;
@@ -536,7 +563,7 @@ static void zconfprint(const char *err, ...) · 5 unmodified lines
536563 {
537564 va_list ap;
538565
539− fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
566+ fprintf(stderr, "%s:%d: ", cur_filename, cur_lineno);
540567 va_start(ap, err);
541568 vfprintf(stderr, err, ap);
542569 va_end(ap);
@@ -548,7 +575,7 @@ static void zconf_error(const char *err, ...) · 5 unmodified lines
548575 va_list ap;
549576
550577 yynerrs++;
551− fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
578+ fprintf(stderr, "%s:%d: ", cur_filename, cur_lineno);
552579 va_start(ap, err);
553580 vfprintf(stderr, err, ap);
554581 va_end(ap);
@@ -557,7 +584,7 @@ static void zconf_error(const char *err, ...) · 2 unmodified lines
557584
558585 static void yyerror(const char *err)
559586 {
560− fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
587+ fprintf(stderr, "%s:%d: %s\n", cur_filename, cur_lineno, err);
561588 }
562589
563590 static void print_quoted_string(FILE *out, const char *str)
scripts/kconfig/preprocess.c+13−10
@@ -9,10 +9,11 @@ · 8 unmodified lines
99 #include <stdlib.h>
1010 #include <string.h>
1111
12+#include "array_size.h"
13+#include "internal.h"
1214 #include "list.h"
1315 #include "lkc.h"
14−
15−#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
16+#include "preprocess.h"
1617
1718 static char *expand_string_with_args(const char *in, int argc, char *argv[]);
1819 static char *expand_string(const char *in);
@@ -21,7 +22,7 @@ static void __attribute__((noreturn)) pperror(const char *format, ...) · 2 unmodified lines
2122 {
2223 va_list ap;
2324
24− fprintf(stderr, "%s:%d: ", current_file->name, yylineno);
25+ fprintf(stderr, "%s:%d: ", cur_filename, yylineno);
2526 va_start(ap, format);
2627 vfprintf(stderr, format, ap);
2728 va_end(ap);
@@ -87,14 +88,17 @@ static char *env_expand(const char *name) · 59 unmodified lines
8788 return xstrdup(value);
8889 }
8990
90−void env_write_dep(FILE *f, const char *autoconfig_name)
91+void env_write_dep(struct gstr *s)
9192 {
9293 struct env *e, *tmp;
9394
9495 list_for_each_entry_safe(e, tmp, &env_list, node) {
95− fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value);
96− fprintf(f, "%s: FORCE\n", autoconfig_name);
97− fprintf(f, "endif\n");
96+ str_printf(s,
97+ "\n"
98+ "ifneq \"$(%s)\" \"%s\"\n"
99+ "$(autoconfig): FORCE\n"
100+ "endif\n",
101+ e->name, e->value);
98102 env_del(e);
99103 }
100104 }
@@ -119,7 +123,7 @@ static char *do_error_if(int argc, char *argv[]) · 18 unmodified lines
119123
120124 static char *do_filename(int argc, char *argv[])
121125 {
122− return xstrdup(current_file->name);
126+ return xstrdup(cur_filename);
123127 }
124128
125129 static char *do_info(int argc, char *argv[])
@@ -181,8 +185,7 @@ static char *do_shell(int argc, char *argv[]) · 55 unmodified lines
181185 static char *do_warning_if(int argc, char *argv[])
182186 {
183187 if (!strcmp(argv[0], "y"))
184− fprintf(stderr, "%s:%d: %s\n",
185− current_file->name, yylineno, argv[1]);
188+ fprintf(stderr, "%s:%d: %s\n", cur_filename, yylineno, argv[1]);
186189
187190 return xstrdup("");
188191 }
scripts/kconfig/preprocess.h+19−0
@@ -0,0 +1,19 @@
1+/* SPDX-License-Identifier: GPL-2.0-only */
2+#ifndef PREPROCESS_H
3+#define PREPROCESS_H
4+
5+enum variable_flavor {
6+ VAR_SIMPLE,
7+ VAR_RECURSIVE,
8+ VAR_APPEND,
9+};
10+
11+struct gstr;
12+void env_write_dep(struct gstr *gs);
13+void variable_add(const char *name, const char *value,
14+ enum variable_flavor flavor);
15+void variable_all_del(void);
16+char *expand_dollar(const char **str);
17+char *expand_one_token(const char **str);
18+
19+#endif /* PREPROCESS_H */
scripts/kconfig/qconf.cc+1−1
@@ -1058,7 +1058,7 @@ void ConfigInfoView::menuInfo(void) · 1057 unmodified lines
10581058 stream << "<br><br>";
10591059 }
10601060
1061− stream << "defined at " << _menu->file->name << ":"
1061+ stream << "defined at " << _menu->filename << ":"
10621062 << _menu->lineno << "<br><br>";
10631063 }
10641064 }
scripts/kconfig/symbol.c+22−27
@@ -9,23 +9,27 @@ · 8 unmodified lines
99 #include <string.h>
1010 #include <regex.h>
1111
12+#include "internal.h"
1213 #include "lkc.h"
1314
1415 struct symbol symbol_yes = {
1516 .name = "y",
1617 .curr = { "y", yes },
18+ .menus = LIST_HEAD_INIT(symbol_yes.menus),
1719 .flags = SYMBOL_CONST|SYMBOL_VALID,
1820 };
1921
2022 struct symbol symbol_mod = {
2123 .name = "m",
2224 .curr = { "m", mod },
25+ .menus = LIST_HEAD_INIT(symbol_mod.menus),
2326 .flags = SYMBOL_CONST|SYMBOL_VALID,
2427 };
2528
2629 struct symbol symbol_no = {
2730 .name = "n",
2831 .curr = { "n", no },
32+ .menus = LIST_HEAD_INIT(symbol_no.menus),
2933 .flags = SYMBOL_CONST|SYMBOL_VALID,
3034 };
3135
@@ -160,9 +164,8 @@ static void sym_set_changed(struct symbol *sym) · 128 unmodified lines
160164 static void sym_set_all_changed(void)
161165 {
162166 struct symbol *sym;
163− int i;
164167
165− for_all_symbols(i, sym)
168+ for_all_symbols(sym)
166169 sym_set_changed(sym);
167170 }
168171
@@ -475,9 +478,8 @@ void sym_calc_value(struct symbol *sym) · 306 unmodified lines
475478 void sym_clear_all_valid(void)
476479 {
477480 struct symbol *sym;
478− int i;
479481
480− for_all_symbols(i, sym)
482+ for_all_symbols(sym)
481483 sym->flags &= ~SYMBOL_VALID;
482484 conf_set_changed(true);
483485 sym_calc_value(modules_sym);
@@ -803,14 +805,7 @@ bool sym_is_changeable(struct symbol *sym) · 319 unmodified lines
803805 return sym->visible > sym->rev_dep.tri;
804806 }
805807
806−static unsigned strhash(const char *s)
807−{
808− /* fnv32 hash */
809− unsigned hash = 2166136261U;
810− for (; *s; s++)
811− hash = (hash ^ *s) * 0x01000193;
812− return hash;
813−}
808+HASHTABLE_DEFINE(sym_hashtable, SYMBOL_HASHSIZE);
814809
815810 struct symbol *sym_lookup(const char *name, int flags)
816811 {
@@ -826,9 +821,9 @@ struct symbol *sym_lookup(const char *name, int flags) · 9 unmodified lines
826821 case 'n': return &symbol_no;
827822 }
828823 }
829− hash = strhash(name) % SYMBOL_HASHSIZE;
824+ hash = strhash(name);
830825
831− for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
826+ hash_for_each_possible(sym_hashtable, symbol, node, hash) {
832827 if (symbol->name &&
833828 !strcmp(symbol->name, name) &&
834829 (flags ? symbol->flags & flags
@@ -846,9 +841,9 @@ struct symbol *sym_lookup(const char *name, int flags) · 11 unmodified lines
846841 symbol->name = new_name;
847842 symbol->type = S_UNKNOWN;
848843 symbol->flags = flags;
844+ INIT_LIST_HEAD(&symbol->menus);
849845
850− symbol->next = symbol_hash[hash];
851− symbol_hash[hash] = symbol;
846+ hash_add(sym_hashtable, &symbol->node, hash);
852847
853848 return symbol;
854849 }
@@ -868,9 +863,9 @@ struct symbol *sym_find(const char *name) · 13 unmodified lines
868863 case 'n': return &symbol_no;
869864 }
870865 }
871− hash = strhash(name) % SYMBOL_HASHSIZE;
866+ hash = strhash(name);
872867
873− for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
868+ hash_for_each_possible(sym_hashtable, symbol, node, hash) {
874869 if (symbol->name &&
875870 !strcmp(symbol->name, name) &&
876871 !(symbol->flags & SYMBOL_CONST))
@@ -930,7 +925,7 @@ struct symbol **sym_re_search(const char *pattern) · 53 unmodified lines
930925 if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
931926 return NULL;
932927
933− for_all_symbols(i, sym) {
928+ for_all_symbols(sym) {
934929 if (sym->flags & SYMBOL_CONST || !sym->name)
935930 continue;
936931 if (regexec(&re, sym->name, 1, match, 0))
@@ -1041,42 +1036,42 @@ static void sym_check_print_recursive(struct symbol *last_sym) · 104 unmodified lines
10411036 }
10421037 if (stack->sym == last_sym)
10431038 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
1044− prop->file->name, prop->lineno);
1039+ prop->filename, prop->lineno);
10451040
10461041 if (sym_is_choice(sym)) {
10471042 fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1048− menu->file->name, menu->lineno,
1043+ menu->filename, menu->lineno,
10491044 sym->name ? sym->name : "<choice>",
10501045 next_sym->name ? next_sym->name : "<choice>");
10511046 } else if (sym_is_choice_value(sym)) {
10521047 fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1053− menu->file->name, menu->lineno,
1048+ menu->filename, menu->lineno,
10541049 sym->name ? sym->name : "<choice>",
10551050 next_sym->name ? next_sym->name : "<choice>");
10561051 } else if (stack->expr == &sym->dir_dep.expr) {
10571052 fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
1058− prop->file->name, prop->lineno,
1053+ prop->filename, prop->lineno,
10591054 sym->name ? sym->name : "<choice>",
10601055 next_sym->name ? next_sym->name : "<choice>");
10611056 } else if (stack->expr == &sym->rev_dep.expr) {
10621057 fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
1063− prop->file->name, prop->lineno,
1058+ prop->filename, prop->lineno,
10641059 sym->name ? sym->name : "<choice>",
10651060 next_sym->name ? next_sym->name : "<choice>");
10661061 } else if (stack->expr == &sym->implied.expr) {
10671062 fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
1068− prop->file->name, prop->lineno,
1063+ prop->filename, prop->lineno,
10691064 sym->name ? sym->name : "<choice>",
10701065 next_sym->name ? next_sym->name : "<choice>");
10711066 } else if (stack->expr) {
10721067 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1073− prop->file->name, prop->lineno,
1068+ prop->filename, prop->lineno,
10741069 sym->name ? sym->name : "<choice>",
10751070 prop_get_type_name(prop->type),
10761071 next_sym->name ? next_sym->name : "<choice>");
10771072 } else {
10781073 fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
1079− prop->file->name, prop->lineno,
1074+ prop->filename, prop->lineno,
10801075 sym->name ? sym->name : "<choice>",
10811076 prop_get_type_name(prop->type),
10821077 next_sym->name ? next_sym->name : "<choice>");
scripts/kconfig/tests/choice_randomize/Kconfig+22−0
@@ -0,0 +1,22 @@
1+choice
2+ prompt "choose A or B"
3+
4+config A
5+ bool "A"
6+
7+config B
8+ bool "B"
9+
10+endchoice
11+
12+choice
13+ prompt "choose X or Y"
14+ depends on B
15+
16+config X
17+ bool "X"
18+
19+config Y
20+ bool "Y"
21+
22+endchoice
scripts/kconfig/tests/choice_randomize/__init__.py+34−0
@@ -0,0 +1,34 @@
1+# SPDX-License-Identifier: GPL-2.0-only
2+"""
3+Randomize all dependent choices
4+
5+This is a somewhat tricky case for randconfig; the visibility of one choice is
6+determined by a member of another choice. Randconfig should be able to generate
7+all possible patterns.
8+"""
9+
10+
11+def test(conf):
12+
13+ expected0 = False
14+ expected1 = False
15+ expected2 = False
16+
17+ for i in range(100):
18+ assert conf.randconfig(seed=i) == 0
19+
20+ if conf.config_matches('expected_config0'):
21+ expected0 = True
22+ elif conf.config_matches('expected_config1'):
23+ expected1 = True
24+ elif conf.config_matches('expected_config2'):
25+ expected2 = True
26+ else:
27+ assert False
28+
29+ if expected0 and expected1 and expected2:
30+ break
31+
32+ assert expected0
33+ assert expected1
34+ assert expected2
scripts/kconfig/tests/choice_randomize/expected_config0+6−0
@@ -0,0 +1,6 @@
1+#
2+# Automatically generated file; DO NOT EDIT.
3+# Main menu
4+#
5+CONFIG_A=y
6+# CONFIG_B is not set
scripts/kconfig/tests/choice_randomize/expected_config1+8−0
@@ -0,0 +1,8 @@
1+#
2+# Automatically generated file; DO NOT EDIT.
3+# Main menu
4+#
5+# CONFIG_A is not set
6+CONFIG_B=y
7+CONFIG_X=y
8+# CONFIG_Y is not set
scripts/kconfig/tests/choice_randomize/expected_config2+8−0
@@ -0,0 +1,8 @@
1+#
2+# Automatically generated file; DO NOT EDIT.
3+# Main menu
4+#
5+# CONFIG_A is not set
6+CONFIG_B=y
7+# CONFIG_X is not set
8+CONFIG_Y=y
scripts/kconfig/tests/choice_randomize2/Kconfig+32−0
@@ -0,0 +1,32 @@
1+choice
2+ prompt "This is always invisible"
3+ depends on n
4+
5+config DUMMY
6+ bool "DUMMY"
7+
8+endchoice
9+
10+choice
11+ prompt "Choose A or B"
12+
13+config A
14+ bool "A"
15+
16+config B
17+ bool "B"
18+
19+endchoice
20+
21+config FOO
22+ bool "FOO"
23+ depends on A
24+
25+choice
26+ prompt "Choose X"
27+ depends on FOO
28+
29+config X
30+ bool "X"
31+
32+endchoice
scripts/kconfig/tests/choice_randomize2/__init__.py+18−0
@@ -0,0 +1,18 @@
1+# SPDX-License-Identifier: GPL-2.0-only
2+"""
3+Randomize choices with correct dependencies
4+
5+When shuffling a choice may potentially disrupt certain dependencies, symbol
6+values must be recalculated.
7+
8+Related Linux commits:
9+ - c8fb7d7e48d11520ad24808cfce7afb7b9c9f798
10+"""
11+
12+
13+def test(conf):
14+ for i in range(20):
15+ assert conf.randconfig(seed=i) == 0
16+ assert (conf.config_matches('expected_config0') or
17+ conf.config_matches('expected_config1') or
18+ conf.config_matches('expected_config2'))
scripts/kconfig/tests/choice_randomize2/expected_config0+8−0
@@ -0,0 +1,8 @@
1+#
2+# Automatically generated file; DO NOT EDIT.
3+# Main menu
4+#
5+CONFIG_A=y
6+# CONFIG_B is not set
7+CONFIG_FOO=y
8+CONFIG_X=y
scripts/kconfig/tests/choice_randomize2/expected_config1+7−0
@@ -0,0 +1,7 @@
1+#
2+# Automatically generated file; DO NOT EDIT.
3+# Main menu
4+#
5+CONFIG_A=y
6+# CONFIG_B is not set
7+# CONFIG_FOO is not set
scripts/kconfig/tests/choice_randomize2/expected_config2+6−0
@@ -0,0 +1,6 @@
1+#
2+# Automatically generated file; DO NOT EDIT.
3+# Main menu
4+#
5+# CONFIG_A is not set
6+CONFIG_B=y
scripts/kconfig/tests/conftest.py+10−6
@@ -154,12 +154,10 @@ class Conf: · 153 unmodified lines
154154 defconfig_path = os.path.join(self._test_dir, defconfig)
155155 return self._run_conf('--defconfig={}'.format(defconfig_path))
156156
157− def _allconfig(self, mode, all_config):
157+ def _allconfig(self, mode, all_config, extra_env={}):
158158 if all_config:
159159 all_config_path = os.path.join(self._test_dir, all_config)
160− extra_env = {'KCONFIG_ALLCONFIG': all_config_path}
161− else:
162− extra_env = {}
160+ extra_env['KCONFIG_ALLCONFIG'] = all_config_path
163161
164162 return self._run_conf('--{}config'.format(mode), extra_env=extra_env)
165163
@@ -195,13 +193,19 @@ class Conf: · 29 unmodified lines
195193 """
196194 return self._allconfig('alldef', all_config)
197195
198− def randconfig(self, all_config=None):
196+ def randconfig(self, all_config=None, seed=None):
199197 """Run randconfig.
200198
201199 all_config: fragment config file for KCONFIG_ALLCONFIG (optional)
200+ seed: the seed for randconfig (optional)
202201 returncode: exit status of the Kconfig executable
203202 """
204− return self._allconfig('rand', all_config)
203+ if seed is not None:
204+ extra_env = {'KCONFIG_SEED': hex(seed)}
205+ else:
206+ extra_env = {}
207+
208+ return self._allconfig('rand', all_config, extra_env=extra_env)
205209
206210 def savedefconfig(self, dot_config):
207211 """Run savedefconfig.
scripts/kconfig/tests/err_recursive_dep/expected_stderr+11−11
@@ -1,10 +1,10 @@
1−Kconfig:11:error: recursive dependency detected!
2−Kconfig:11: symbol B is selected by B
1+Kconfig:5:error: recursive dependency detected!
2+Kconfig:5: symbol A depends on A
33 For a resolution refer to Documentation/kbuild/kconfig-language.rst
44 subsection "Kconfig recursive dependency limitations"
55
6−Kconfig:5:error: recursive dependency detected!
7−Kconfig:5: symbol A depends on A
6+Kconfig:11:error: recursive dependency detected!
7+Kconfig:11: symbol B is selected by B
88 For a resolution refer to Documentation/kbuild/kconfig-language.rst
99 subsection "Kconfig recursive dependency limitations"
1010
@@ -14,9 +14,9 @@ Kconfig:21: symbol C2 depends on C1 · 3 unmodified lines
1414 For a resolution refer to Documentation/kbuild/kconfig-language.rst
1515 subsection "Kconfig recursive dependency limitations"
1616
17−Kconfig:32:error: recursive dependency detected!
18−Kconfig:32: symbol D2 is selected by D1
17+Kconfig:27:error: recursive dependency detected!
1918 Kconfig:27: symbol D1 depends on D2
19+Kconfig:32: symbol D2 is selected by D1
2020 For a resolution refer to Documentation/kbuild/kconfig-language.rst
2121 subsection "Kconfig recursive dependency limitations"
2222
@@ -26,13 +26,13 @@ Kconfig:42: symbol E2 is implied by E1 · 3 unmodified lines
2626 For a resolution refer to Documentation/kbuild/kconfig-language.rst
2727 subsection "Kconfig recursive dependency limitations"
2828
29−Kconfig:60:error: recursive dependency detected!
30−Kconfig:60: symbol G depends on G
29+Kconfig:49:error: recursive dependency detected!
30+Kconfig:49: symbol F1 default value contains F2
31+Kconfig:51: symbol F2 depends on F1
3132 For a resolution refer to Documentation/kbuild/kconfig-language.rst
3233 subsection "Kconfig recursive dependency limitations"
3334
34−Kconfig:51:error: recursive dependency detected!
35−Kconfig:51: symbol F2 depends on F1
36−Kconfig:49: symbol F1 default value contains F2
35+Kconfig:60:error: recursive dependency detected!
36+Kconfig:60: symbol G depends on G
3737 For a resolution refer to Documentation/kbuild/kconfig-language.rst
3838 subsection "Kconfig recursive dependency limitations"
scripts/kconfig/util.c+36−11
@@ -7,25 +7,50 @@ · 6 unmodified lines
77 #include <stdarg.h>
88 #include <stdlib.h>
99 #include <string.h>
10+
11+#include "hashtable.h"
1012 #include "lkc.h"
1113
14+unsigned int strhash(const char *s)
15+{
16+ /* fnv32 hash */
17+ unsigned int hash = 2166136261U;
18+
19+ for (; *s; s++)
20+ hash = (hash ^ *s) * 0x01000193;
21+ return hash;
22+}
23+
24+/* hash table of all parsed Kconfig files */
25+static HASHTABLE_DEFINE(file_hashtable, 1U << 11);
26+
27+struct file {
28+ struct hlist_node node;
29+ char name[];
30+};
31+
1232 /* file already present in list? If not add it */
13−struct file *file_lookup(const char *name)
33+const char *file_lookup(const char *name)
1434 {
1535 struct file *file;
36+ size_t len;
37+ int hash = strhash(name);
1638
17− for (file = file_list; file; file = file->next) {
18− if (!strcmp(name, file->name)) {
19− return file;
20− }
21− }
39+ hash_for_each_possible(file_hashtable, file, node, hash)
40+ if (!strcmp(name, file->name))
41+ return file->name;
2242
23− file = xmalloc(sizeof(*file));
43+ len = strlen(name);
44+ file = xmalloc(sizeof(*file) + len + 1);
2445 memset(file, 0, sizeof(*file));
25− file->name = xstrdup(name);
26− file->next = file_list;
27− file_list = file;
28− return file;
46+ memcpy(file->name, name, len);
47+ file->name[len] = '\0';
48+
49+ hash_add(file_hashtable, &file->node, hash);
50+
51+ str_printf(&autoconf_cmd, "\t%s \\\n", name);
52+
53+ return file->name;
2954 }
3055
3156 /* Allocate initial growable string */
scripts/mod/modpost.c+3−1
@@ -1050,7 +1050,9 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, · 1049 unmodified lines
10501050 sec_mismatch_count++;
10511051
10521052 warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n",
1053− modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, tosym, tosec);
1053+ modname, fromsym,
1054+ (unsigned int)(faddr - (from ? from->st_value : 0)),
1055+ fromsec, tosym, tosec);
10541056
10551057 if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
10561058 if (match(tosec, mismatch->bad_tosec))
scripts/package/builddeb+12−38
@@ -24,24 +24,10 @@ if_enabled_echo() { · 23 unmodified lines
2424 fi
2525 }
2626
27−create_package() {
28− export DH_OPTIONS="-p${1}"
29−
30− dh_installdocs
31− dh_installchangelogs
32− dh_compress
33− dh_fixperms
34− dh_gencontrol
35− dh_md5sums
36− dh_builddeb -- ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS}
37−}
38−
3927 install_linux_image () {
4028 pname=$1
4129 pdir=debian/$1
4230
43− rm -rf ${pdir}
44−
4531 # Only some architectures with OF support have this target
4632 if is_enabled CONFIG_OF_EARLY_FLATTREE && [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
4733 ${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install
@@ -109,8 +95,6 @@ install_linux_image () { · 61 unmodified lines
10995 install_linux_image_dbg () {
11096 pdir=debian/$1
11197
112− rm -rf ${pdir}
113−
11498 # Parse modules.order directly because 'make modules_install' may sign,
11599 # compress modules, and then run unneeded depmod.
116100 while read -r mod; do
@@ -140,8 +124,6 @@ install_kernel_headers () { · 23 unmodified lines
140124 pdir=debian/$1
141125 version=${1#linux-headers-}
142126
143− rm -rf $pdir
144−
145127 "${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}"
146128
147129 mkdir -p $pdir/lib/modules/$version/
@@ -151,8 +133,6 @@ install_kernel_headers () { · 3 unmodified lines
151133 install_libc_headers () {
152134 pdir=debian/$1
153135
154− rm -rf $pdir
155−
156136 $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr
157137
158138 # move asm headers to /usr/include/<libc-machine>/asm to match the structure
@@ -161,21 +141,15 @@ install_libc_headers () { · 2 unmodified lines
161141 mv "$pdir/usr/include/asm" "$pdir/usr/include/${DEB_HOST_MULTIARCH}"
162142 }
163143
164−rm -f debian/files
165−
166−packages_enabled=$(dh_listpackages)
167−
168−for package in ${packages_enabled}
169−do
170− case ${package} in
171− *-dbg)
172− install_linux_image_dbg "${package}";;
173− linux-image-*|user-mode-linux-*)
174− install_linux_image "${package}";;
175− linux-libc-dev)
176− install_libc_headers "${package}";;
177− linux-headers-*)
178− install_kernel_headers "${package}";;
179− esac
180− create_package "${package}"
181−done
144+package=$1
145+
146+case "${package}" in
147+*-dbg)
148+ install_linux_image_dbg "${package}";;
149+linux-image-*|user-mode-linux-*)
150+ install_linux_image "${package}";;
151+linux-libc-dev)
152+ install_libc_headers "${package}";;
153+linux-headers-*)
154+ install_kernel_headers "${package}";;
155+esac
scripts/package/debian/rules+54−9
@@ -11,28 +11,73 @@ ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))) · 10 unmodified lines
1111 MAKEFLAGS += -j$(NUMJOBS)
1212 endif
1313
14+# When KBUILD_VERBOSE is undefined (presumably you are directly working with
15+# the debianized tree), show verbose logs unless DEB_BUILD_OPTION=terse is set.
16+ifeq ($(origin KBUILD_VERBOSE),undefined)
17+ ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
18+ export KBUILD_VERBOSE := 1
19+ else
20+ Q := @
21+ endif
22+endif
23+
1424 revision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version)))
1525 CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-)
1626 make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE))
1727
28+binary-targets := $(addprefix binary-, image image-dbg headers libc-dev)
29+
30+all-packages = $(shell dh_listpackages)
31+image-package = $(filter linux-image-% user-%, $(filter-out %-dbg, $(all-packages)))
32+image-dbg-package = $(filter %-dbg, $(all-packages))
33+libc-dev-package = $(filter linux-libc-dev, $(all-packages))
34+headers-package = $(filter linux-headers-%, $(all-packages))
35+
36+mk-files = $(patsubst binary-%,debian/%.files,$1)
37+package = $($(@:binary-%=%-package))
38+
39+# DH_OPTION is an environment variable common for all debhelper commands.
40+# We could 'export' it, but here it is passed from the command line to clarify
41+# which package is being processed in the build log.
42+DH_OPTIONS = -p$(package)
43+
44+define binary
45+ $(Q)dh_testdir $(DH_OPTIONS)
46+ $(Q)dh_testroot $(DH_OPTIONS)
47+ $(Q)dh_prep $(DH_OPTIONS)
48+ $(Q)+$(MAKE) $(make-opts) run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb $(package)'
49+ $(Q)dh_installdocs $(DH_OPTIONS)
50+ $(Q)dh_installchangelogs $(DH_OPTIONS)
51+ $(Q)dh_compress $(DH_OPTIONS)
52+ $(Q)dh_fixperms $(DH_OPTIONS)
53+ $(Q)dh_gencontrol $(DH_OPTIONS) -- -f$(call mk-files,$@)
54+ $(Q)dh_md5sums $(DH_OPTIONS)
55+ $(Q)dh_builddeb $(DH_OPTIONS) -- $(addprefix -Z,$(KDEB_COMPRESS))
56+endef
57+
58+.PHONY: $(binary-targets)
59+$(binary-targets): build-arch
60+ $(Q)truncate -s0 $(call mk-files,$@)
61+ $(if $(package),$(binary))
62+
1863 .PHONY: binary binary-indep binary-arch
1964 binary: binary-arch binary-indep
2065 binary-indep: build-indep
21−binary-arch: build-arch
22− $(MAKE) $(make-opts) \
23− run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb'
66+binary-arch: $(binary-targets)
67+ $(Q)cat $(call mk-files,$^) > debian/files
2468
2569 .PHONY: build build-indep build-arch
2670 build: build-arch build-indep
2771 build-indep:
2872 build-arch:
29− $(MAKE) $(make-opts) olddefconfig
30− $(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all
73+ $(Q)$(MAKE) $(make-opts) olddefconfig
74+ $(Q)$(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all
3175
3276 .PHONY: clean
3377 clean:
34− rm -rf debian/files debian/linux-* debian/deb-env.vars*
35− $(MAKE) ARCH=$(ARCH) clean
78+ $(Q)dh_clean
79+ $(Q)rm -rf debian/deb-env.vars* debian/*.files
80+ $(Q)$(MAKE) ARCH=$(ARCH) clean
3681
3782 # If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed
3883 # directly. Run 'dpkg-architecture --print-set --print-format=make' to
@@ -41,6 +86,6 @@ ifndef DEB_HOST_ARCH · 2 unmodified lines
4186 include debian/deb-env.vars
4287
4388 debian/deb-env.vars:
44− dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp
45− mv $@.tmp $@
89+ $(Q)dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp
90+ $(Q)mv $@.tmp $@
4691 endif
scripts/package/kernel.spec+37−11
@@ -61,11 +61,37 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS · 60 unmodified lines
6161 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
6262 cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
6363 cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
64+if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
65+ %{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install
66+fi
6467 ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
6568 %if %{with_devel}
6669 %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
6770 %endif
6871
72+{
73+ for x in System.map config kernel modules.builtin \
74+ modules.builtin.modinfo modules.order vmlinuz; do
75+ echo "/lib/modules/%{KERNELRELEASE}/${x}"
76+ done
77+
78+ for x in alias alias.bin builtin.alias.bin builtin.bin dep dep.bin \
79+ devname softdep symbols symbols.bin; do
80+ echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}"
81+ done
82+
83+ for x in System.map config vmlinuz; do
84+ echo "%ghost /boot/${x}-%{KERNELRELEASE}"
85+ done
86+
87+ if [ -d "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" ];then
88+ echo "/lib/modules/%{KERNELRELEASE}/dtb"
89+ find "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" -printf "%%%ghost /boot/dtb-%{KERNELRELEASE}/%%P\n"
90+ fi
91+
92+ echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
93+} > %{buildroot}/kernel.list
94+
6995 %clean
7096 rm -rf %{buildroot}
7197
@@ -78,23 +104,23 @@ for file in vmlinuz System.map config; do · 6 unmodified lines
78104 cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"
79105 fi
80106 done
107+if [ -d "/lib/modules/%{KERNELRELEASE}/dtb" ] && \
108+ ! diff -rq "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" >/dev/null 2>&1; then
109+ rm -rf "/boot/dtb-%{KERNELRELEASE}"
110+ cp -r "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}"
111+fi
112+if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then
113+ /usr/sbin/depmod %{KERNELRELEASE}
114+fi
81115
82116 %preun
83−if [ -x /sbin/new-kernel-pkg ]; then
84−new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img
85−elif [ -x /usr/bin/kernel-install ]; then
117+if [ -x /usr/bin/kernel-install ]; then
86118 kernel-install remove %{KERNELRELEASE}
87119 fi
88120
89−%postun
90−if [ -x /sbin/update-bootloader ]; then
91−/sbin/update-bootloader --remove %{KERNELRELEASE}
92−fi
93−
94−%files
121+%files -f %{buildroot}/kernel.list
95122 %defattr (-, root, root)
96−/lib/modules/%{KERNELRELEASE}
97−%exclude /lib/modules/%{KERNELRELEASE}/build
123+%exclude /kernel.list
98124
99125 %files headers
100126 %defattr (-, root, root)
tools/lib/bpf/Makefile+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
22 # Most of this file is copied from tools/lib/traceevent/Makefile
33
44 RM ?= rm
5−srctree = $(abs_srctree)
5+srctree := $(realpath $(srctree))
66
77 VERSION_SCRIPT := libbpf.map
88 LIBBPF_VERSION := $(shell \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t