From: Ondrej Mosnáček on gitlab.com Merge Request: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1950
Two small spec file tweaks to reduce the disk space footprint of the kernel build. This is useful for custom/local builds - for example it makes it more feasible to build the kernel on tmpfs (to reduce HDD/SSD wear and speed up the build a bit) or on small VM instances.
Please consider merging so I don't have to carry this in a local branch :slight_smile:
--- redhat/kernel.spec.template | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
From: Ondrej Mosnacek omosnace@redhat.com
kernel.spec.template: avoid keeping two copies of vmlinux
This file is very large, so make sure we only work with one copy of it to reduce disk space requirements.
Signed-off-by: Ondrej Mosnacek omosnace@redhat.com
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template index blahblah..blahblah 100755 --- a/redhat/kernel.spec.template +++ b/redhat/kernel.spec.template @@ -2015,9 +2015,11 @@ BuildKernel() {
# # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm + # (use mv + symlink instead of cp to reduce disk space requirements) # mkdir -p $RPM_BUILD_ROOT%{debuginfodir}/lib/modules/$KernelVer - cp vmlinux $RPM_BUILD_ROOT%{debuginfodir}/lib/modules/$KernelVer + mv vmlinux $RPM_BUILD_ROOT%{debuginfodir}/lib/modules/$KernelVer + ln -s $RPM_BUILD_ROOT%{debuginfodir}/lib/modules/$KernelVer/vmlinux vmlinux if [ -n "%{vmlinux_decompressor}" ]; then eu-readelf -n %{vmlinux_decompressor} | grep "Build ID" | awk '{print $NF}' > vmlinux.decompressor.id # Without build-id the build will fail. But for s390 the build-id
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1950
From: Ondrej Mosnacek omosnace@redhat.com
kernel.spec.template: remove some temporary files early
These are very big, yet not needed after the dependent results have been generated, so we can remove them to reduce disk space requirements of the kernel build.
Signed-off-by: Ondrej Mosnacek omosnace@redhat.com
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template index blahblah..blahblah 100755 --- a/redhat/kernel.spec.template +++ b/redhat/kernel.spec.template @@ -1672,6 +1672,9 @@ BuildKernel() { find arch/$Arch/boot/dts -name '*.dtb' -type f -delete %endif
+ # Remove large intermediate files we no longer need to save space + rm vmlinux.o .tmp_vmlinux.btf + # Start installing the results install -m 644 .config $RPM_BUILD_ROOT/boot/config-$KernelVer install -m 644 .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/config
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1950
From: Jarod Wilson on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1950#note_1081478...
Would it make sense to use a hardlink here instead of a symlink? My only other concern would be someone trying to debug a build failure and finding those intermediate files gone, but I suppose they could hack up the spec to preserve them in that particular use case.
From: Ondrej Mosnáček on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1950#note_1081919...
Would it make sense to use a hardlink here instead of a symlink?
I figured a symlink would be safer, since hardlinks only work between files on the same filesystem. It's not obvious that there is such guarantee for the various build dirs, and even if there was, it's better to minimize such hidden assumptions IMHO.
My only other concern would be someone trying to debug a build failure and
finding those intermediate files gone, but I suppose they could hack up the spec to preserve them in that particular use case.
If the build fails after the `rm`, then the kernel image is already built and there should be no need to work with those files to debug it. And even if the user wants to re-run the make steps for some reason, the build system should be able to rebuild the missing files as needed. So I'd argue the impact would be minimal here.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1950#note_1114646...
@jwilsonrh - can you reply here?
From: Jarod Wilson on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1950#note_1122814...
Okay, fair enough.
kernel@lists.fedoraproject.org