Skip to content

Conversation

@iav
Copy link
Contributor

@iav iav commented Jan 17, 2026

Summary

Since kernel 6.18, make M=scripts/mod/ no longer works due to kbuild changes (commit 13b25489b6f8). The standard make scripts doesn't build scripts/mod (modpost, mk_elfconfig) which are required for DKMS/external module builds.

Solution: In postinst, temporarily add subdir-y += mod to scripts/Makefile before running make scripts. This makes kbuild descend into scripts/mod/ and build modpost with proper dependencies (empty.o → mk_elfconfig → elfconfig.h → modpost).

This approach:

  • Works for both native and cross-compilation scenarios
  • Builds modpost natively on the target system (correct architecture)
  • Uses standard kbuild mechanisms with proper dependency handling
  • No binaries are shipped in the package

Test plan

  • Cross-compiled kernel-headers package on x86_64 for arm64
  • Installed package on arm64 (helios64) - postinst completed successfully
  • Verified modpost/mk_elfconfig are native aarch64 binaries
  • DKMS module (bcachefs) built successfully
  • Module loaded and works

🤖 Generated with Claude Code

@iav iav requested a review from a team as a code owner January 17, 2026 02:25
@github-actions github-actions bot added size/small PR with less then 50 lines 02 Milestone: First quarter release labels Jan 17, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Copied host binaries scripts/mod/modpost and scripts/mod/mk_elfconfig into the kernel headers package, added existence checks, and removed the prior in-tree build invocation (make M=scripts/mod/) from the headers packaging path.

Changes

Cohort / File(s) Summary
Kernel Build Script
lib/functions/compilation/kernel-debs.sh
In kernel_package_callback_linux_headers: copy host binaries scripts/mod/modpost and scripts/mod/mk_elfconfig into the headers package with existence checks; update file-type verification to include those binaries; remove the make M=scripts/mod/ invocation and add explanatory comments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • rpardini
  • igorpecovnik

Poem

🐰 I hopped through scripts with a curious stare,
I packed modpost and mk_elfconfig with care,
No in-tree build, just copies so spry,
Headers now carry the tools that comply,
Happy builds hop onward — carrot-powered! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: fixing the kernel-headers package to build modpost in postinst for DKMS support, which aligns with the core objective of including pre-compiled modpost and mk_elfconfig binaries.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added Needs review Seeking for review Framework Framework components labels Jan 17, 2026
@iav iav marked this pull request as draft January 17, 2026 03:01
@iav iav force-pushed the fix-kernel-headers-modpost-build branch from c4b8b19 to fdbb888 Compare January 17, 2026 04:10
@iav iav changed the title Fix kernel-headers postinst: correct scripts/mod build command Fix kernel-headers package: include modpost and mk_elfconfig binaries Jan 17, 2026
@iav iav marked this pull request as ready for review January 17, 2026 06:35
Copy link
Member

@rpardini rpardini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't include binaries in kernel-headers.
We cross-compile during build (on CI, usually on large amd64 machines, targetting arm64) and there would be an architecture mismatch.
Even if that was not the case, there would be a glibc mismatch.

@iav iav marked this pull request as draft January 18, 2026 06:11
Since kernel 6.18, `make M=scripts/mod/` no longer works due to kbuild
changes (commit 13b25489b6f8). The standard `make scripts` doesn't build
scripts/mod (modpost, mk_elfconfig) which are required for DKMS/external
module builds.

Solution: In postinst, temporarily add `subdir-y += mod` to scripts/Makefile
before running `make scripts`. This makes kbuild descend into scripts/mod/
and build modpost with proper dependencies (empty.o → mk_elfconfig →
elfconfig.h → modpost).

This approach:
- Works for both native and cross-compilation scenarios
- Builds modpost natively on the target system (correct architecture)
- Uses standard kbuild mechanisms with proper dependency handling
- No binaries are shipped in the package

Tested: Cross-compiled on x86_64, installed on arm64 (helios64),
DKMS module (bcachefs) built and loaded successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@iav iav force-pushed the fix-kernel-headers-modpost-build branch from fdbb888 to 0eeec83 Compare January 18, 2026 20:48
@iav iav changed the title Fix kernel-headers package: include modpost and mk_elfconfig binaries Fix kernel-headers package: build modpost in postinst for DKMS support Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Framework Framework components Needs review Seeking for review size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

2 participants