Prefer building using installed kernel and sanitize the generated header file#125
Prefer building using installed kernel and sanitize the generated header file#125alanbach wants to merge 1 commit into
Conversation
e6919cf to
2c3a836
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the build system to generate the Ceph BTF-derived header in a way that is less dependent on the running kernel (helping container/CI builders), and adds a post-processing step to sanitize the generated header for newer toolchains.
Changes:
- Switch Ceph BTF header generation from
/lib/modules/$(uname -r)to selecting an installed kernel under/lib/modules. - Add logic to locate a usable base BTF/vmlinux source from several common paths.
- Sanitize the generated header with
sedto normalize a toolchain-sensitive typedef name.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| kver=$$(find /lib/modules -mindepth 1 -maxdepth 1 -type d -printf '%f\n' 2>/dev/null | sort -V | tail -1); \ | ||
| [ -n "$$kver" ] || { echo "No installed kernels found under /lib/modules" >&2; exit 1; }; \ | ||
| kdir="/lib/modules/$$kver"; \ | ||
| CEPH_KO=$$(find "$$kdir" -type f -name 'ceph.ko*' 2>/dev/null | head -1); \ | ||
| [ -n "$$CEPH_KO" ] || { echo "No ceph.ko* found under $$kdir" >&2; exit 1; }; \ |
| for cand in \ | ||
| "$$kdir/vmlinux" \ | ||
| "/usr/lib/debug/lib/modules/$$kver/vmlinux" \ | ||
| "/usr/lib/debug/boot/vmlinux-$$kver" \ | ||
| "/sys/kernel/btf/vmlinux" \ | ||
| "/boot/vmlinux-$$kver"; do \ | ||
| if [ -r "$$cand" ]; then \ | ||
| base_btf="$$cand"; \ | ||
| break; \ | ||
| fi; \ | ||
| done; \ | ||
| \ |
There was a problem hiding this comment.
+1, this copilot comment has a good point
|
@alanbach |
| for cand in \ | ||
| "$$kdir/vmlinux" \ | ||
| "/usr/lib/debug/lib/modules/$$kver/vmlinux" \ | ||
| "/usr/lib/debug/boot/vmlinux-$$kver" \ | ||
| "/sys/kernel/btf/vmlinux" \ | ||
| "/boot/vmlinux-$$kver"; do \ | ||
| if [ -r "$$cand" ]; then \ | ||
| base_btf="$$cand"; \ | ||
| break; \ | ||
| fi; \ | ||
| done; \ | ||
| \ |
There was a problem hiding this comment.
+1, this copilot comment has a good point
running kernel. This allows building on container based builders such as Github and Gitlab runners. * Sanitize the generated header file to prevent build failures on new toolchains.
2c3a836 to
30ec8a9
Compare
Hello @taodd Thank you so much for the review. I applied the changes from the Copilot review and re-committed the PR. |
Hello @taodd As we are aiming to build packages for major distros, the proposed Makefile change should catch if there are no usable BPF bits available. The rest falls on the packager to make sure correct dependencies are installed. Similar to other build dependencies present. |
Build using installed kernel rather than
running kernel. This allows building on container
based builders such as Github and Gitlab runners.
Sanitize the generated header file to prevent build failures on new tool chains.