-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Deprecate # CONFIG_ is not set #5443
Comments
This behavior actually makes some sense once you know that It's motivated by two things:
The comment will be ignored by Less useful if you're not using |
Closing for now. It won't change upstream in Kconfiglib, and I think maintaining a patch for it might be overkill. Feel free to reopen. |
It might be okay to close. But I would like to understand this better before deciding.
Makes sense, CONFIG_F=n is easy for both humans, make, and Kconfig to understand.
Can you elaborate on what this means? Does Kconfig generate "=n" when the user has input through a GUI, but generate "# is not set" when the negative is due to Kconfig evaluation? Does Kconfig treat "=n" and "# is not set" differently? |
Said differently, what kind of features or use-cases would we lose if we started to use "=n" everywhere. |
@SebastianBoe Kconfig never generates |
Consider this for example:
When At the same time, Kconfig needs to remember that |
It's still fine to manually put a |
Thank you, I understand the situation. For Zephyr, I believe the cleanest solution is to have kconfiglib support a dialect of Kconfig that produced "=n" instead of "is not set". Then users will not be confused about comments having semantics and users will not be confused about there being 2 different syntaxes for the same thing. Having a configuration system that behaves as-expected, and therefore requires as little documentation as possible is extremely important for adoption. Comments having semantics, and multiple syntaxes for the same (in the Zephyr context) thing is not behaving-as-expected. |
@SebastianBoe It's a trivial change on the Kconfiglib side at least. Think this should be enough: diff --git a/kconfiglib.py b/kconfiglib.py
index 96c7d37..ac28131 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -3023,10 +3023,7 @@ class Symbol(object):
if self.orig_type in (BOOL, TRISTATE):
return "{}{}={}\n" \
- .format(self.kconfig.config_prefix, self.name, val) \
- if val != "n" else \
- "# {}{} is not set\n" \
- .format(self.kconfig.config_prefix, self.name)
+ .format(self.kconfig.config_prefix, self.name, val)
if self.orig_type in (INT, HEX):
return "{}{}={}\n" \ It'd still handle |
Yes. This is the main drawback. But IMHO it is worth it. It should be noted that all we are changing is how Kconfig integrates with it's build system. For KBuild it makes sense to generate "is not set", whereas for CMake it makes more sense to generate "=n". This dialect change will not affect in any way any documentation about Kconfig ("is not set" is not actually documented), nor will it affect how input is given to Kconfig. All it changes is the format used to export to CMake. So it is a much less invasive change than the "prefer later defaults" patch for instance. |
Heh, never noticed it wasn't documented. Always amazes me how people can feel comfortable adding stuff like that without thinking it might be a good idea to at least hint at why it's there. Yeah, pretty minimal fallout in that case, and the patch should be simple to maintain, so I'm fine with it. |
Hi, @ulfalizer , there is a bug in extensions.cmake:import_kconfig that would be resolved if this "enhancement" was implemented. Would it be possible to get this prioritized? Also, it might be easier to support this through a feature-flag, than an out-of-tree patch. |
@SebastianBoe The reason To implement it on the CMake side, you'd just have to treat |
If there's some way to get the values into |
The aforementioned bug can be fixed in a straightforward way. This is more about preventing similar issues popping up in the future. I agree about not maintaining a custom patch, which is why I would recommend maintaining a feature-flag / dialect argument kind-of-mechanism. |
I'm hoping the complexity will not be significant, e.g. something like:
|
If it comes up many times in the future, I might be more willing to add it. The reason Kconfiglib has stayed relatively readable (to me anyway, dunno how it reads to others) is that I've tried hard to avoid stuff like dialect flags and one-off features. It tends to add up and come back and bite you, from experience with Kconfiglib 1. |
I have had to explain to many users that
I don't see any reason to believe that this will not continue to pop up and confuse users. |
It's explained in the application development primer at least (better than in Linux, where AFAICT no one bothered to document why Kconfig does that at all). |
It is better to design systems to be self-explanatory so they do not need documentation. We have the opportunity, in this particular case, to achieve this. |
Can't get rid of the standard behavior, and don't like the tradeoff in this case. |
@ulfalizer given that we already maintain our own copy of Kconfiglib in Zephyr, what is the downside of having this change in our |
It's another custom patch to maintain. To be fair, it could be implemented in Changing the CMake script so that it understands the standard Kconfig output format might be the least hacky solution in this case. |
@ulfalizer as @SebastianBoe mentions the issue is also one of support and simplicity. Could you come up with a quick patch for |
This seems to work. It's copy-pasting Get a call to the internal diff --git a/scripts/kconfig/kconfig.py b/scripts/kconfig/kconfig.py
index 6af3edd2cf..32b34059ae 100755
--- a/scripts/kconfig/kconfig.py
+++ b/scripts/kconfig/kconfig.py
@@ -5,7 +5,28 @@ import os
import sys
import textwrap
-from kconfiglib import Kconfig, BOOL, TRISTATE, TRI_TO_STR
+from kconfiglib import Kconfig, Symbol, expr_value, _save_old, BOOL, \
+ TRISTATE, TRI_TO_STR, MENU, COMMENT
+
+
+def write_custom_config(kconf, filename):
+ _save_old(filename)
+
+ with open(filename, "w", encoding="utf-8") as f:
+ for node in kconf.node_iter(unique_syms=True):
+ item = node.item
+
+ if isinstance(node.item, Symbol):
+ if item.orig_type in (BOOL, TRISTATE) and not item.tri_value:
+ f.write("{}{}=n\n".format(kconf.config_prefix, item.name))
+ else:
+ f.write(item.config_string)
+
+ elif expr_value(node.dep) and \
+ ((item is MENU and expr_value(node.visibility)) or
+ item is COMMENT):
+
+ f.write("\n#\n# {}\n#\n".format(node.prompt[0]))
# Warnings that won't be turned into errors (but that will still be printed),
@@ -89,7 +110,7 @@ def main():
100) + "\n")
# Write the merged configuration and the C header
- kconf.write_config(args.dotconfig)
+ write_custom_config(kconf, args.dotconfig)
print("Configuration written to '{}'".format(args.dotconfig))
kconf.write_autoconf(args.autoconf) I'd prefer to make the change in CMake for now. |
LGTM |
Looks not so good to me. Another problem with it is that Could you write a CMake version for comparison? |
There is no "CMake version for comparison" because this is not about fixing a particular instance of the bug but about fixing the whole class of bugs that arises from users assuming that "# CONFIG_FOO is not set" is a comment. |
Menuconfig, and any future tools, will have to also be updated. |
@ulfalizer : Can you update menuconfig as well? |
-1 from my on this enhancement request. if we go this path then we could as well stop saying that we are using kconfig. It is what it is, if you do not like XML, you do not go and change the semantics... |
We are not changing any documented behaviour from Kconfig. We are just making an implementation-defined change. According to Kconfig
disables an option. There is nothing documented about what
means. Therefore choosing to generate FOO=n, instead of
does not diverge us from the language. Although it does diverge us from the accidental In other words, since "# CONFIG_FOO is not set" is not documented, it is reasonable to |
Maybe the solution is just document it? |
No, because that does not resolve this issue. People don't read documentation. But people do I don't understand the push-back here. We write / maintain # this is a comment.
# CONFIG_FOO is not set
# But the above line is not a comment. It is equivalent to
# the below line.
CONFIG_FOO=n This is a no-brainer in trade-off between maintainability and usability to me. |
I would strongly advise not to do this. E.g. our internal firmware build system relies on the fact that Zephyr uses real Kconfig. So we integrate make, and cmake and kconfig that supports a lot of complex configuration. I'm sure there are other users who do this. I agree the syntax isnt nice, but it has a logical rationale behind it. Better to just document that more clearly. If there should be a patch to kconfiglib, maybe have it output a comment header in the generated .config files to state the # CONFIG_ ... is not set explicitly disables the option. |
@jameswalmsley I doubt anything is going to happen on this front as both Ulf and Sebastian are no longer active contributors. |
Closing this issue as we don't plan on making these changes. Can re-open if someone feels like they need this and plan on working on it. |
Some parts of Kconfig treat lines like
# CONFIG_FOO is not set
to have meaning, instead of just being commented out lines as one would expect.
All parts of kconfig that attribute meaning to this construct should be removedand the use-case that it is enabling should be supported with a construct
that does not look like a comment.
Kconfig should generate "=n" instead of "is not set" whenever possible.
In short, don't unnecessarily inherit the Linux kernel's cruft.
Source:
http://lists.openembedded.org/pipermail/openembedded-core/2016-May/120914.html
The text was updated successfully, but these errors were encountered: