3

I rebuild the kernel based on the git sources. These are the steps that I take:

  1. git clone git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git
  2. cd ubuntu-focal
  3. vi debian.master/changelog
  4. apply patches
  5. fakeroot debian/rules clean binary-headers binary-generic

If I then apply another patch and want to compile the same version again, I get an error because certain folders are not empty. I can issue 'fakeroot debian/rules clean' to solve that, but then I need to compile the whole kernel.

Is there a way to recompiling only the changed files and build the debs based on that? It seems a trivial thing I just haven't figured out yet.

Sam Van den Eynde
  • 296
  • 1
  • 3
  • 13
  • Kernel subsystems and modules are compiled separately before being merged into the kernel. I just want to avoid recompiling the exact same source code for the source files that haven't changed. – Sam Van den Eynde Jan 31 '20 at 18:35
  • I never did figure out how to do an incremental kernel compile the Ubuntu way. I do it almost always with the upstream git source. Method described here. – Doug Smythies Feb 01 '20 at 04:40
  • Do dch -i and compile. There should be no problems. I always do it this way. – Pilot6 Feb 24 '20 at 21:51
  • That would not work. Redid the test:
    mv: cannot move '/git/linux-stable-5.5/debian/linux-modules-5.5.3-050503-generic/lib/modules/5.5.3-050503-generic/kernel' to '/git/linux-stable-5.5/debian/linux-modules-extra-5.5.3-050503-generic/lib/modules/5.5.3-050503-generic/kernel/kernel': Directory not empty debian/rules.d/2-binary-arch.mk:113: recipe for target 'install-generic' failed make: *** [install-generic] Error 1
    – Sam Van den Eynde Feb 25 '20 at 23:51

1 Answers1

1

So it is not exactly what I was looking for, but as I am mainly looking to save some time and can spare the diskspace I adopted ccache based on this guide.

I use the method described here to compile the kernel, with the exception that I pull in the sources from GregKH's stable tree.

I added this to .bashrc:

export CCACHE_DIR="/scrap/ccache"
export CC="ccache gcc"
export CXX="ccache g++"
export PATH="/usr/lib/ccache:$PATH"

But it seems I have to add the parameter when invoking the build:

CC="ccache gcc" fakeroot debian/rules binary-headers binary-generic

Results after 2 identical builds look good (starting with empty cache then doing a build with everything in cache equals 50% hit rate in total):

cache hit (direct) 20354
cache hit (preprocessed) 81
cache miss 20411
cache hit rate 50.03 %
called for link 94
called for preprocessing 148
unsupported code directive 12
no input file 1329
cleanups performed 0
files in cache 61169
cache size 7.3 GB
max cache size 16.0 GB

Regular Kernel builds took slightly over an hour. The first ccache run (filling the cache) took 95 minutes. The second build 30 minutes. I'm keeping it like this for now.

Sam Van den Eynde
  • 296
  • 1
  • 3
  • 13