From 1e77d0b975ad714dc3c619bdddd949f94ec2fc79 Mon Sep 17 00:00:00 2001 From: David Guibert Date: Thu, 28 Dec 2017 09:11:36 +0100 Subject: [PATCH] kernel 4.14 require libelf to compile modules. [...] make modules -C /nix/store/h1vzl6bq4wif3m8dd1bw2p3fv4shjg3n-linux-4.14.9-dev/lib/modules/4.14.9/build EXTRA_CFLAGS=-Werror-implicit-function-declaration M=/tmp/nix-build-spl-kernel-2017-11-16-4.14.9.drv-0/source/build /nix/store/h1vzl6bq4wif3m8dd1bw2p3fv4shjg3n-linux-4.14.9-dev/lib/modules/4.14.9/source/Makefile:939: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop. This patch introduces kernel.moduleBuildDependencies to avoid the logic "stdenv.lib.optional (stdenv.lib.versionAtLeast kernel.version "4.14") libelf" in multiple places. [dezgeg did some minor tweaks on top] --- .../virtualization/virtualbox/guest-additions/default.nix | 2 +- pkgs/os-specific/linux/kernel/manual-config.nix | 5 ++++- pkgs/os-specific/linux/spl/default.nix | 2 +- pkgs/os-specific/linux/sysdig/default.nix | 2 +- pkgs/os-specific/linux/tp_smapi/default.nix | 2 ++ pkgs/os-specific/linux/virtualbox/default.nix | 2 ++ pkgs/os-specific/linux/zfs/default.nix | 3 ++- 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix index 409187a99fbd..8f789cdf1707 100644 --- a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix +++ b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix @@ -36,7 +36,7 @@ stdenv.mkDerivation { NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration"; - buildInputs = [ patchelf cdrkit makeWrapper dbus ]; + buildInputs = [ patchelf cdrkit makeWrapper dbus ] ++ kernel.moduleBuildDependencies; installPhase = '' mkdir -p $out diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 355fbde62680..e1936495921d 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -49,6 +49,9 @@ let inherit (stdenv.lib) hasAttr getAttr optional optionalString optionalAttrs maintainers platforms; + # Dependencies that are required to build kernel modules + moduleBuildDependencies = stdenv.lib.optional (stdenv.lib.versionAtLeast version "4.14") libelf; + installkernel = writeTextFile { name = "installkernel"; executable=true; text = '' #!${stdenv.shell} -e mkdir -p $4 @@ -85,7 +88,7 @@ let (isModular || (config.isDisabled "FIRMWARE_IN_KERNEL")); in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // { passthru = { - inherit version modDirVersion config kernelPatches configfile; + inherit version modDirVersion config kernelPatches configfile moduleBuildDependencies; }; inherit src; diff --git a/pkgs/os-specific/linux/spl/default.nix b/pkgs/os-specific/linux/spl/default.nix index 387dc2b7c675..f3bd283327c8 100644 --- a/pkgs/os-specific/linux/spl/default.nix +++ b/pkgs/os-specific/linux/spl/default.nix @@ -25,7 +25,7 @@ let patches = [ ./const.patch ./install_prefix.patch ]; - nativeBuildInputs = [ autoreconfHook ]; + nativeBuildInputs = [ autoreconfHook ] ++ optional (kernel != null) kernel.moduleBuildDependencies; hardeningDisable = [ "pic" ]; diff --git a/pkgs/os-specific/linux/sysdig/default.nix b/pkgs/os-specific/linux/sysdig/default.nix index 18d473e21941..71d7e9e1b785 100644 --- a/pkgs/os-specific/linux/sysdig/default.nix +++ b/pkgs/os-specific/linux/sysdig/default.nix @@ -14,7 +14,7 @@ stdenv.mkDerivation rec { buildInputs = [ cmake zlib luajit ncurses perl jsoncpp libb64 openssl curl jq gcc - ]; + ] ++ optional (kernel != null) kernel.moduleBuildDependencies; hardeningDisable = [ "pic" ]; diff --git a/pkgs/os-specific/linux/tp_smapi/default.nix b/pkgs/os-specific/linux/tp_smapi/default.nix index 4fc14a04eeab..c3adcc6cdba9 100644 --- a/pkgs/os-specific/linux/tp_smapi/default.nix +++ b/pkgs/os-specific/linux/tp_smapi/default.nix @@ -13,6 +13,8 @@ stdenv.mkDerivation rec { name = "tp-smapi-${version}"; }; + nativeBuildInputs = kernel.moduleBuildDependencies; + hardeningDisable = [ "pic" ]; makeFlags = [ diff --git a/pkgs/os-specific/linux/virtualbox/default.nix b/pkgs/os-specific/linux/virtualbox/default.nix index 5bec71a10907..72d7690d2f8a 100644 --- a/pkgs/os-specific/linux/virtualbox/default.nix +++ b/pkgs/os-specific/linux/virtualbox/default.nix @@ -7,6 +7,8 @@ stdenv.mkDerivation { "fortify" "pic" "stackprotector" ]; + nativeBuildInputs = kernel.moduleBuildDependencies; + patches = [ ./fix_kerndir.patch ./fix_kbuild.patch diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix index 5ede0a91b291..9b6c9b890cc7 100644 --- a/pkgs/os-specific/linux/zfs/default.nix +++ b/pkgs/os-specific/linux/zfs/default.nix @@ -38,7 +38,8 @@ let patches = extraPatches; - nativeBuildInputs = [ autoreconfHook nukeReferences ]; + nativeBuildInputs = [ autoreconfHook nukeReferences ] + ++ optional (kernel != null) kernel.moduleBuildDependencies; buildInputs = optionals buildKernel [ spl ] ++ optionals buildUser [ zlib libuuid python attr ]