-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kconfig/cmake: Improve reconfiguration behavior #22043
kconfig/cmake: Improve reconfiguration behavior #22043
Conversation
1a527ac
to
0887f29
Compare
@SebastianBoe can you review this PR? |
0887f29
to
47a9e4a
Compare
Will review soon. |
This solves part of #9573, but not all of it (as I read 9573). So we need to remove the "fixes #9573" from the description. Steps to reproduce: Build hello world with qemu_cortex_m3. Run menuconfig and enable ADC. Run menuconfig again to try to change another configuration, but see it fail because .config is corrupt.
|
I'd like to test this. Could you give steps to reproduce:
|
That one shouldn't be a problem on the The description for #9573 is about
The fix here is to prevent the checksum from being saved in step 3. |
When the .config is corrupt (by corrupt I mean that when CMake runs with it it does not complete, but instead crashes at some point. This could either be because the Kconfig sources are incorrect and generating invalid configurations, or because the build scripts are incorrect and making wrong assumptions about what kind of Kconfig it could be receiving) it will not be possible to run ninja menuconfig because the build fails before the new ninja build system is generated.
I interpret 9573 about being about the title, and the description just being one example of how 9573 can occur. With this interpretation we can't close it. See also |
47a9e4a
to
02c1cd4
Compare
Hadn't noticed the amendment. Updates the commit description now. Rest fine? |
02c1cd4
to
3868a96
Compare
for path in paths}): | ||
with open(kconfig_list_path, 'w') as out: | ||
for path in sorted({os.path.realpath(os.path.join(kconf.srctree, path)) | ||
for path in kconf.kconfig_filenames}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, the review goes faster when changes are separated from refactorings in different commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because then when looking at refactoring patches I can trivially verify that the changes have no semantic effects.
And when looking at actual changes I won't have to sift through the noise of unrelated refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, did some drive-by-ing and got lazy. Will split better next time.
"on them, like no promptless symbols being " | ||
"assigned") | ||
parser.add_argument("kconfig", | ||
help="Top-level Kconfig file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When kconfig_root is used, the variable name is self-explanatory and no help text is needed.
I prefer this name over kconfig, which could be referring to anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kconfig_root
to me sounds like it refers to $srctree
(the root directory that source
works relative to).
I could call it kconfig_file
though. Should be clear enough. Looks like the C tools do:
$ scripts/kconfig/conf --help
Usage: scripts/kconfig/conf [-s] [option] <kconfig-file>
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot about srctree, yes, kconfig_file will have to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
parser.add_argument("kconfig", | ||
help="Top-level Kconfig file") | ||
parser.add_argument("config_out", | ||
help="Output configuration file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration file is too ambiguous, let's either use the term "Kconfig fragment" or "fragment" to clarify.
Using _out and _in suffixes makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output configuration file is a not a fragment, so probably shouldn't have "fragment" in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, right, I consider the
A=B syntax to be
of the filetype "Kconfig fragment",
but I guess technically fragment also implies that it's just a subset of options.
Then I don't know how to make this clearer, so this will have to do.
scripts/kconfig/kconfig.py
Outdated
help="Output file for list of parsed Kconfig files") | ||
parser.add_argument("configs_in", | ||
nargs="+", | ||
help="Input configuration files") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use the term fragment to be less ambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the help text.
scripts/kconfig/kconfig.py
Outdated
parser.add_argument("conf_fragments", nargs='+') | ||
parser.add_argument("--handwritten-input-configs", | ||
action="store_true", | ||
help="Assume the input configuration files are " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/configuration files/input fragments/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the help text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes requested.
The improvement itself is sane.
There are some issues with the behavior when rerunning CMake in an already initialized build directory: 1. The check for assignments to promptless symbols in configuration fragments isn't run when reconfiguring, because it only runs if zephyr/.config doesn't exist 2. As outlined in zephyrproject-rtos#9573, you can get into situations where zephyr/.config is invalid (e.g. due to being outdated), but menuconfig/guiconfig can't be run to fix it 3. If kconfig.py fails while merging fragments during reconfiguration, it will ignore the fragments during the next reconfiguration and use the existing zephyr/.config instead, because the fragment checksum is calculated and saved before running kconfig.py (Footnote: The input configuration file(s) to kconfig.py can be either a list of configuration fragments, when merging fragments, or just zephyr/.config, if the merged configuration is up-to-date. The output configuration file is always zephyr/.config.) To fix the first two issues, explicitly tell kconfig.py when it's dealing with handwritten configuration input (fragments), via a new --handwritten-input-configs flag. This is more robust than checking whether zephyr/.config exists, which was the old logic. When dealing with handwritten input, there should be no assignments to promptless symbols. Assignments to promptless symbols is expected in zephyr/.config however, because it doubles as configuration output. When running menuconfig/guiconfig, the input configuration is zephyr/.config rather than configuration fragments, so this change also makes sure that menuconfig can always be run as long as zephyr/.config exists and is up-to-date. To fix the last issue, only write the checksum for the configuration fragments if kconfig.py succeeds (which means it wrote a zephyr/.config). Also improve naming a bit, add help texts for the command-line parameters to kconfig.py, and simplify write_kconfig_filenames() by moving logic into it. Partial fix for zephyrproject-rtos#9573, without the part in #issuecomment-469701831. Can still run into issues when e.g. when CMake files can't make sense of settings. Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
3868a96
to
1209796
Compare
Nits fixed. |
There are some issues with the behavior when rerunning CMake in an
already initialized build directory:
The check for assignments to promptless symbols in configuration
fragments isn't run when reconfiguring, because it only runs if
zephyr/.config doesn't exist
As outlined in
The contents of .config should not be able to prevent users from running menuconfig. #9573, you can
get into situations where zephyr/.config is invalid (e.g. due to
being outdated), but menuconfig/guiconfig can't be run to fix it
If kconfig.py fails while merging fragments during reconfiguration,
it will ignore the fragments during the next reconfiguration and use
the existing zephyr/.config instead, because the fragment checksum
is calculated and saved before running kconfig.py
(Footnote: The input configuration file(s) to kconfig.py can be either a
list of configuration fragments, when merging fragments, or just
zephyr/.config, if the merged configuration is up-to-date. The output
configuration file is always zephyr/.config.)
To fix the first two issues, explicitly tell kconfig.py when it's
dealing with handwritten configuration input (fragments), via a new
--handwritten-input-configs flag. This is more robust than checking
whether zephyr/.config exists, which was the old logic.
When dealing with handwritten input, there should be no assignments to
promptless symbols. Assignments to promptless symbols is expected in
zephyr/.config however, because it doubles as configuration output.
When running menuconfig/guiconfig, the input configuration is
zephyr/.config rather than configuration fragments, so this change also
makes sure that menuconfig can always be run as long as zephyr/.config
exists and is up-to-date.
To fix the last issue, only write the checksum for the configuration
fragments if kconfig.py succeeds (which means it wrote a
zephyr/.config).
Also improve naming a bit, add help texts for the command-line
parameters to kconfig.py, and simplify write_kconfig_filenames() by
moving logic into it.
Partial fix for
#9573, without the
part in #issuecomment-469701831. Can still run into issues when e.g.
when CMake files can't make sense of settings.