linux_5_2, linux_5_3: fixing nondeterminism

In 5.2 kernel a new mechanism was introduced which embeds the kernel
headers in the kernel image and exposes them in procfs for simplified
use by userland tools.

It was introduced in
https://github.com/torvalds/linux/commit/43d8ce9d65a54846d378545770991e65838981e0
and later modified a bit in
https://github.com/torvalds/linux/commit/f7b101d33046a837c2aa4526cef28a3c785d7af2

The archive containing the header files had nondeterminism through the
header files metadata - specifically `mtime`, but I also decided to
normalize some other aspects just in case.

In our default setup we currently compile this as a module, so to expose
the headers to test the functionality `kheaders` needs to be loaded.

See https://lkml.org/lkml/2019/10/4/1036 and
https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=fixes&id=2cc99c9cdc8fde5e92e34f9655829449cebd3e00

I commented out the documentation part of the patch to make it cleanly apply to
5.2 and 5.3, see remark in the patch itself.
This commit is contained in:
Dima
2019-10-05 09:34:35 +02:00
parent 6be720b3a7
commit bdccffa81c
2 changed files with 89 additions and 1 deletions
@@ -94,7 +94,9 @@ let
patches =
map (p: p.patch) kernelPatches
# Required for deterministic builds along with some postPatch magic.
++ optional (stdenv.lib.versionAtLeast version "4.13") ./randstruct-provide-seed.patch;
++ optional (stdenv.lib.versionAtLeast version "4.13") ./randstruct-provide-seed.patch
# Fixes determinism by normalizing metadata for the archive of kheaders
++ optional (stdenv.lib.versionAtLeast version "5.2") ./gen-kheaders-metadata.patch;
prePatch = ''
for mf in $(find -name Makefile -o -name Makefile.include -o -name install.sh); do