-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Normalize kernel config hash inputs #9277
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughStabilizes kernel configuration hashing by reducing duplicate config-change entries to their last occurrence and adding a toolchain-derived hash; also normalizes kernel option lists by sorting and deduplicating opts arrays and opts_val keys before hashing and applying changes. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@lib/functions/compilation/armbian-kernel.sh`:
- Around line 520-540: The sort invocations that build
opts_n_norm/opts_y_norm/opts_m_norm and opts_val_keys are locale-dependent and
can yield non-deterministic ordering; update the commands that use sort -u and
sort to force a stable C locale (e.g., prefix with LC_ALL=C) so the arrays
(opts_n_norm, opts_y_norm, opts_m_norm, opts_val_keys) and derived
kernel_config_modifying_hashes are built deterministically across environments.
Ensure you apply this change to every occurrence of sort used for these lists in
the block surrounding opts_n_norm/opts_y_norm/opts_m_norm and opts_val_keys.
- Around line 519-540: The variable opts_val_keys is being created in function
scope (global) and should be local like the other arrays; declare opts_val_keys
as a local variable (e.g., add it to the existing local/declare array line with
opts_n_norm/opts_y_norm/opts_m_norm) so it doesn't leak to global scope, then
keep the subsequent mapfile usage and for-loop over opts_val_keys unchanged;
ensure you reference the same symbol names (opts_val_keys, opts_n_norm,
opts_y_norm, opts_m_norm, kernel_config_modifying_hashes) when updating the
declaration.
a8ff3b5 to
9b3d44d
Compare
06adbfe to
f88a095
Compare
Add compiler (gcc/clang) version to the kernel artifact hash to ensure
cache invalidation when the toolchain changes.
- Hash includes KERNEL_COMPILER prefix and compiler version
- Uses only major.minor version (e.g., 13.3), drops patch version
- Falls back to "unknown" if compiler is not available
- Adds -T${hash} component to artifact version string
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f88a095 to
d2cf555
Compare
Summary
Two improvements to kernel artifact hash stability and correctness:
1. Normalize kernel config hash inputs
Problem
The current kernel config hashing makes
kernel_config_modification_hashsensitive to option insertion order, which causes two issues:Unstable hash due to insertion order.
kernel_config_modifying_hashesis populated in hook order; identical final option sets can produce different hashes and artifact versions.Overridden assignments still affect the hash.
If the same option is set multiple times (e.g.
FOO=ythenFOO=n), both entries influence the hash even though only the last value takes effect.Additionally, iteration order for
opts_val(assoc array) can be nondeterministic.Solution
Normalize per-group lists (
opts_n/opts_y/opts_m).Each group is sorted and deduplicated (
sort -u). This makes ordering deterministic and removes duplicates without changing behavior (all values in a group are the same: n/y/m).Deterministic ordering for
opts_val.opts_valkeys are sorted before hashing and before applying to.config.Drop overridden assignments when hashing.
Before computing
kernel_config_modification_hash, only the last value per key is kept, so overridden assignments no longer affect versioning.2. Include toolchain version in kernel artifact hash
Problem
Compiler version (gcc/clang) was not included in the kernel artifact hash. Changing the toolchain would not invalidate the cache, even though different compiler versions produce different binaries.
Solution
KERNEL_COMPILERprefix and compiler version to the hash-T${hash}component to artifact version stringResult
.configstay the sameTests
Not added.
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.