linux-testing: Fix arg list too long in modinst

With the default kernel and thus with the build I have tested in
74ec94bfa2e57e2c0beeee0e469de58391d04a7b, we get an error during
modules_install:

make[2]: execvp: /nix/store/.../bin/bash: Argument list too long

I haven't noticed this build until I actually tried booting using this
kernel because make didn't fail here.

The reason this happens within Nix and probably didn't yet surface in
other distros is that programs only have a limited amount of memory
available for storing the environment and the arguments.

Environment variables however are quite common on Nix and thus we
stumble on problems like this way earlier - in this case Linux 4.8 - but
I have noticed this in 4.7-next as well already.

The fix is far from perfect and suffers performance overhead because we
now run grep for every *.mod file instead of passing all *.mod files
into one single invocation of grep.

But comparing the performance overhead (around 1s on my machine) with
the overall build time of the kernel I think the overhead really is
neglicible.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>

aszlig f19c961b e7b2f05d

+27 -6
+14
pkgs/os-specific/linux/kernel/modinst-arg-list-too-long.patch
··· 1 + diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst 2 + index 07650ee..934a7a8 100644 3 + --- a/scripts/Makefile.modinst 4 + +++ b/scripts/Makefile.modinst 5 + @@ -9,7 +9,8 @@ include scripts/Kbuild.include 6 + 7 + # 8 + 9 + -__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 10 + +__modules := $(sort $(foreach f,$(wildcard $(MODVERDIR)/*.mod),$(shell \ 11 + + grep -h '\.ko$$' '$f'))) 12 + modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) 13 + 14 + PHONY += $(modules)
+5
pkgs/os-specific/linux/kernel/patches.nix
··· 74 74 patch = ./mips-ext3-n32.patch; 75 75 }; 76 76 77 + modinst_arg_list_too_long = 78 + { name = "modinst-arglist-too-long"; 79 + patch = ./modinst-arg-list-too-long.patch; 80 + }; 81 + 77 82 ubuntu_fan_4_4 = 78 83 { name = "ubuntu-fan"; 79 84 patch = ./ubuntu-fan-4.4.patch;
+8 -6
pkgs/top-level/all-packages.nix
··· 11185 11185 }; 11186 11186 11187 11187 linux_testing = callPackage ../os-specific/linux/kernel/linux-testing.nix { 11188 - kernelPatches = [ kernelPatches.bridge_stp_helper ] 11189 - ++ lib.optionals ((platform.kernelArch or null) == "mips") 11190 - [ kernelPatches.mips_fpureg_emu 11191 - kernelPatches.mips_fpu_sigill 11192 - kernelPatches.mips_ext3_n32 11193 - ]; 11188 + kernelPatches = [ 11189 + kernelPatches.bridge_stp_helper 11190 + kernelPatches.modinst_arg_list_too_long 11191 + ] ++ lib.optionals ((platform.kernelArch or null) == "mips") [ 11192 + kernelPatches.mips_fpureg_emu 11193 + kernelPatches.mips_fpu_sigill 11194 + kernelPatches.mips_ext3_n32 11195 + ]; 11194 11196 }; 11195 11197 11196 11198 linux_chromiumos_3_14 = callPackage ../os-specific/linux/kernel/linux-chromiumos-3.14.nix {