Skip to content

Align Kconfiglib output with scripts/kconfig (Linux v6.18)#40

Merged
jserv merged 5 commits intomainfrom
full-compat
Feb 20, 2026
Merged

Align Kconfiglib output with scripts/kconfig (Linux v6.18)#40
jserv merged 5 commits intomainfrom
full-compat

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Feb 19, 2026

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

  • Rename test_compat.py to test_conformance.py; update CI, pytest.ini,
    reltest, and README to use "conformance" terminology consistently
  • Migrate Kconfig test data from legacy $FOO to preprocessor $(FOO) syntax
  • Remove malformed help token hack (--help---, pre-2015 kernels only)
  • Build scripts/kconfig/conf in CI so conformance tests actually execute
  • Retain backward-compatible shims: load_config(verbose=),
    write_config(verbose=), Variable.expanded_value,
    KCONFIG_STRICT env var, gsource/grsource keywords,
    $FOO expandvars() in the quoted-string slow path
  • Keep defined_syms with duplicates to honor the original API contract

2. Restore transitional symbol output

The C tools have no concept of "transitional" for file output -- they
always write every visible symbol. Remove the is_transitional
suppression from config_string, write_autoconf, _min_config_contents,
and sync_deps. Harden conformance tests to skip architectures
gracefully when the C conf tool fails (e.g. missing cross-toolchain).

3. Match SYMBOL_WRITE behavior for implied symbols

sym_calc_value() unconditionally sets SYMBOL_WRITE when
weak_rev_dep is non-zero, even when direct dependencies gate the
actual value to zero. Kconfiglib omitted such symbols from .config.

4. Align choice semantics with scripts/kconfig (v6.18)

  • Propagate depends on expression (not the Choice object) as basedep
  • Prompt-based visibility without mode-dependent capping
  • Members get y/n by selection regardless of choice mode
  • 4-step _selection(): user -> default -> first-visible -> last-visible
  • Bidirectional choice-member invalidation
  • all*config scripts skip choice members per conf_set_all_new_symbols()

5. Match int/hex range and default handling

  • Clamp out-of-range user values to the nearest bound instead of falling
    back to defaults, matching sym_validate_range()
  • Return "0" / "0x0" for INT/HEX with no explicit default, matching
    sym_get_string_default()

cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv jserv force-pushed the full-compat branch 5 times, most recently from 48af478 to 71db1e4 Compare February 20, 2026 05:34
@jserv jserv changed the title Remove backwards-compatibility shims Drop legacy shims and align with scripts/kconfig (Linux v6.18) Feb 20, 2026
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.
@jserv jserv changed the title Drop legacy shims and align with scripts/kconfig (Linux v6.18) Align Kconfiglib output with scripts/kconfig (Linux v6.18) Feb 20, 2026
@sysprog21 sysprog21 deleted a comment from cubic-dev-ai bot Feb 20, 2026
@sysprog21 sysprog21 deleted a comment from cubic-dev-ai bot Feb 20, 2026
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv jserv merged commit e0d14af into main Feb 20, 2026
10 checks passed
@jserv jserv deleted the full-compat branch February 20, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments