Align Kconfiglib output with scripts/kconfig (Linux v6.18)#40
Merged
Conversation
48af478 to
71db1e4
Compare
Rename test_compat.py to test_conformance.py and update all
references (CI, pytest.ini, reltest, README) to use "conformance"
terminology consistently. Add a CI step to build the kernel C
kconfig tools (scripts/kconfig/conf) so conformance tests run
against the real C implementation.
Modernize Kconfig test data to use the preprocessor $(FOO) syntax
instead of the legacy $FOO form. Remove the malformed help token
hack ("--help---") which only applied to pre-2015 kernels.
Retain backward-compatible shims for APIs with active downstream
users:
- load_config(verbose=) / write_config(verbose=): accept with
deprecation warning
- Variable.expanded_value property: delegates to
expanded_value_w_args()
- KCONFIG_STRICT env var: honored as alias for KCONFIG_WARN_UNDEF
- gsource/grsource keywords: mapped to osource/orsource tokens
- $FOO string expansion via expandvars(): preserved in the
quoted-string slow path for backward compatibility
Keep defined_syms with duplicates (symbols defined in multiple
locations appear multiple times) to honor the original API contract;
unique_defined_syms remains the deduplicated variant.
The C kconfig tools have no concept of 'transitional' -- they always write every visible symbol to .config, autoconf.h, and min-config. Remove the is_transitional output suppression from config_string, write_autoconf, _min_config_contents, and sync_deps so Kconfiglib output matches the C tools character-for-character. The is_transitional attribute is preserved for UI display purposes. Harden conformance tests: check for .config existence before comparing, and skip architectures gracefully when the C conf tool fails (e.g. missing cross-toolchain on macOS).
sym_calc_value() in scripts/kconfig/symbol.c unconditionally sets SYMBOL_WRITE when a symbol's implied value (weak_rev_dep) is non-zero, even when direct dependencies gate the actual value to zero. Kconfiglib only set _write_to_conf when both conditions held, causing implied-but-gated symbols to be silently omitted from .config output.
Rework choice handling to match sym_calc_visibility(), sym_calc_choice(), and _menu_finalize() in the v6.18 kernel: - Propagate the choice's 'depends on' expression (not the Choice object) as basedep for member dependencies, matching _menu_finalize() in scripts/kconfig/menu.c. - Remove visibility capping for choice members; return prompt-based visibility directly without mode-dependent adjustment. - Assign y to the selected member, n to others, regardless of the choice's mode (y, m, or n). - Rewrite _selection() with the 4-step resolution from sym_calc_choice(): user selection, default (unless user-rejected), first visible untouched member, last visible member. - Add bidirectional invalidation between choices and members. - Skip choice members in allnoconfig/allyesconfig/allmodconfig to match conf_set_all_new_symbols().
Clamp out-of-range user values to the nearest range bound instead of falling back to defaults, matching sym_validate_range() in scripts/kconfig/symbol.c. Return "0" for INT and "0x0" for HEX when no explicit default exists, matching sym_get_string_default(). Without this, write_min_config() spuriously includes symbols whose value equals the implicit zero default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bring Kconfiglib's .config, autoconf.h, and min-config output into
character-for-character conformance with the C kconfig tools in Linux
v6.18, while preserving backward-compatible API shims for downstream
users (Zephyr, ESP-IDF).
Commits
1. Modernize legacy compatibility and rename conformance tests
test_compat.pytotest_conformance.py; update CI, pytest.ini,reltest, and README to use "conformance" terminology consistently
$FOOto preprocessor$(FOO)syntax--help---, pre-2015 kernels only)scripts/kconfig/confin CI so conformance tests actually executeload_config(verbose=),write_config(verbose=),Variable.expanded_value,KCONFIG_STRICTenv var,gsource/grsourcekeywords,$FOOexpandvars() in the quoted-string slow pathdefined_symswith duplicates to honor the original API contract2. Restore transitional symbol output
The C tools have no concept of "transitional" for file output -- they
always write every visible symbol. Remove the
is_transitionalsuppression from
config_string,write_autoconf,_min_config_contents,and
sync_deps. Harden conformance tests to skip architecturesgracefully when the C conf tool fails (e.g. missing cross-toolchain).
3. Match SYMBOL_WRITE behavior for implied symbols
sym_calc_value()unconditionally setsSYMBOL_WRITEwhenweak_rev_depis non-zero, even when direct dependencies gate theactual value to zero. Kconfiglib omitted such symbols from
.config.4. Align choice semantics with scripts/kconfig (v6.18)
depends onexpression (not the Choice object) as basedep_selection(): user -> default -> first-visible -> last-visibleall*configscripts skip choice members perconf_set_all_new_symbols()5. Match int/hex range and default handling
back to defaults, matching
sym_validate_range()"0"/"0x0"for INT/HEX with no explicit default, matchingsym_get_string_default()