From 7a9b6ac39a34da8661219e00350955f51122eef8 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 28 Oct 2017 15:09:54 -0400 Subject: [PATCH 1/8] kernel: Enable cross compiling --- .../linux/kernel/common-config.nix | 13 ++--- pkgs/os-specific/linux/kernel/generic.nix | 50 ++++++------------- pkgs/os-specific/linux/kernel/linux-4.13.nix | 2 +- pkgs/os-specific/linux/kernel/linux-4.14.nix | 2 +- pkgs/os-specific/linux/kernel/linux-4.4.nix | 2 +- pkgs/os-specific/linux/kernel/linux-4.9.nix | 2 +- .../linux/kernel/linux-beagleboard.nix | 2 +- .../kernel/linux-hardened-copperhead.nix | 2 +- pkgs/os-specific/linux/kernel/linux-mptcp.nix | 2 +- pkgs/os-specific/linux/kernel/linux-rpi.nix | 2 +- .../linux/kernel/linux-samus-4.12.nix | 2 +- .../linux/kernel/linux-testing-bcachefs.nix | 2 +- .../linux/kernel/linux-testing.nix | 2 +- .../linux/kernel/manual-config.nix | 45 ++++++----------- pkgs/os-specific/linux/kernel/perf.nix | 17 +++---- 15 files changed, 53 insertions(+), 94 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 24ae1967570b..82a092cd5393 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -51,7 +51,7 @@ with stdenv.lib; # Bump the maximum number of CPUs to support systems like EC2 x1.* # instances and Xeon Phi. - ${optionalString (stdenv.system == "x86_64-linux" || stdenv.system == "aarch64-linux") '' + ${optionalString (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "aarch64-linux") '' NR_CPUS 384 ''} @@ -347,11 +347,12 @@ with stdenv.lib; SECURITY_SELINUX_BOOTPARAM_VALUE 0 # Disable SELinux by default SECURITY_YAMA? y # Prevent processes from ptracing non-children processes DEVKMEM n # Disable /dev/kmem - ${if versionOlder version "3.14" then '' - CC_STACKPROTECTOR? y # Detect buffer overflows on the stack - '' else '' - CC_STACKPROTECTOR_REGULAR? y - ''} + ${optionalString (! stdenv.hostPlatform.isArm) + (if versionOlder version "3.14" then '' + CC_STACKPROTECTOR? y # Detect buffer overflows on the stack + '' else '' + CC_STACKPROTECTOR_REGULAR? y + '')} ${optionalString (versionAtLeast version "3.12") '' USER_NS y # Support for user namespaces ''} diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index b1df6c54c456..d1733f96c536 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -1,4 +1,4 @@ -{ stdenv, perl, buildLinux +{ stdenv, buildPackages, perl, buildLinux , # The kernel source tarball. src @@ -23,7 +23,7 @@ # symbolic name and `patch' is the actual patch. The patch may # optionally be compressed with gzip or bzip2. kernelPatches ? [] -, ignoreConfigErrors ? stdenv.platform.name != "pc" +, ignoreConfigErrors ? hostPlatform.platform.name != "pc" , extraMeta ? {} , hostPlatform , ... @@ -58,37 +58,29 @@ let in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); configfile = stdenv.mkDerivation { - inherit ignoreConfigErrors; + #inherit ignoreConfigErrors; name = "linux-config-${version}"; generateConfig = ./generate-config.pl; kernelConfig = kernelConfigFun config; - nativeBuildInputs = [ perl ]; + nativeBuildInputs = [ buildPackages.stdenv.cc perl ]; - platformName = stdenv.platform.name; - kernelBaseConfig = stdenv.platform.kernelBaseConfig; - kernelTarget = stdenv.platform.kernelTarget; - autoModules = stdenv.platform.kernelAutoModules; - preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; - arch = stdenv.platform.kernelArch; + platformName = hostPlatform.platform.name; + kernelBaseConfig = hostPlatform.platform.kernelBaseConfig; + kernelTarget = hostPlatform.platform.kernelTarget; + autoModules = hostPlatform.platform.kernelAutoModules; + preferBuiltin = hostPlatform.platform.kernelPreferBuiltin or false; + arch = hostPlatform.platform.kernelArch; + + # TODO(@Ericson2314): No null next hash break + ignoreConfigErrors = if stdenv.hostPlatform == stdenv.buildPlatform then null else true; crossAttrs = let cp = hostPlatform.platform; in { - arch = cp.kernelArch; - platformName = cp.name; - kernelBaseConfig = cp.kernelBaseConfig; - kernelTarget = cp.kernelTarget; - autoModules = cp.kernelAutoModules; - - # Just ignore all options that don't apply (We are lazy). ignoreConfigErrors = true; - - kernelConfig = kernelConfigFun configCross; - - inherit (kernel.crossDrv) src patches preUnpack; }; prePatch = kernel.prePatch + '' @@ -103,7 +95,7 @@ let cd $buildRoot # Get a basic config file for later refinement with $generateConfig. - make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch + make HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch # Create the config file. echo "generating kernel configuration..." @@ -122,11 +114,7 @@ let configfile = configfile.nativeDrv or configfile; - crossConfigfile = configfile.crossDrv or configfile; - config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; - - crossConfig = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; }; passthru = { @@ -134,12 +122,4 @@ let passthru = kernel.passthru // (removeAttrs passthru [ "passthru" ]); }; - addPassthru' = lib.extendDerivation true passthru; - - nativeDrv = addPassthru' kernel.nativeDrv; - - crossDrv = addPassthru' kernel.crossDrv; - -in if kernel ? crossDrv - then nativeDrv // { inherit nativeDrv crossDrv; } - else addPassthru' kernel +in lib.extendDerivation true passthru kernel diff --git a/pkgs/os-specific/linux/kernel/linux-4.13.nix b/pkgs/os-specific/linux/kernel/linux-4.13.nix index 767f7e35422a..506682479c7c 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.13.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.13.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: import ./generic.nix (args // rec { version = "4.13.16"; diff --git a/pkgs/os-specific/linux/kernel/linux-4.14.nix b/pkgs/os-specific/linux/kernel/linux-4.14.nix index bd1f03c76a75..b740dc49f430 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.14.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.14.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: with stdenv.lib; diff --git a/pkgs/os-specific/linux/kernel/linux-4.4.nix b/pkgs/os-specific/linux/kernel/linux-4.4.nix index 7ed69558fb04..a51cd29665f8 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.4.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.4.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: import ./generic.nix (args // rec { version = "4.4.111"; diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix index 9fc7e51cbef2..4efd0cfd5f7c 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.9.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: import ./generic.nix (args // rec { version = "4.9.76"; diff --git a/pkgs/os-specific/linux/kernel/linux-beagleboard.nix b/pkgs/os-specific/linux/kernel/linux-beagleboard.nix index 33885a082d63..7f7a72b43ec8 100644 --- a/pkgs/os-specific/linux/kernel/linux-beagleboard.nix +++ b/pkgs/os-specific/linux/kernel/linux-beagleboard.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: let modDirVersion = "4.9.61"; diff --git a/pkgs/os-specific/linux/kernel/linux-hardened-copperhead.nix b/pkgs/os-specific/linux/kernel/linux-hardened-copperhead.nix index 1ccc152bb289..20ec3a89a735 100644 --- a/pkgs/os-specific/linux/kernel/linux-hardened-copperhead.nix +++ b/pkgs/os-specific/linux/kernel/linux-hardened-copperhead.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: with stdenv.lib; diff --git a/pkgs/os-specific/linux/kernel/linux-mptcp.nix b/pkgs/os-specific/linux/kernel/linux-mptcp.nix index 92b202100a63..9720e3c0e4a8 100644 --- a/pkgs/os-specific/linux/kernel/linux-mptcp.nix +++ b/pkgs/os-specific/linux/kernel/linux-mptcp.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: import ./generic.nix (rec { mptcpVersion = "0.93"; diff --git a/pkgs/os-specific/linux/kernel/linux-rpi.nix b/pkgs/os-specific/linux/kernel/linux-rpi.nix index fb97aa579df0..1efb11435e2f 100644 --- a/pkgs/os-specific/linux/kernel/linux-rpi.nix +++ b/pkgs/os-specific/linux/kernel/linux-rpi.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: let modDirVersion = "4.9.59"; diff --git a/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix b/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix index 32c684668d6b..c65182271dc3 100644 --- a/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix +++ b/pkgs/os-specific/linux/kernel/linux-samus-4.12.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ncurses, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, ncurses, ... } @ args: import ./generic.nix (args // rec { version = "4.12.2"; diff --git a/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix b/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix index a104cc5393c3..ac13835afdd4 100644 --- a/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix +++ b/pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchgit, perl, buildLinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchgit, perl, buildLinux, ... } @ args: import ./generic.nix (args // rec { version = "4.11.2017.08.23"; diff --git a/pkgs/os-specific/linux/kernel/linux-testing.nix b/pkgs/os-specific/linux/kernel/linux-testing.nix index a3570fd11a43..0bbf78e804ec 100644 --- a/pkgs/os-specific/linux/kernel/linux-testing.nix +++ b/pkgs/os-specific/linux/kernel/linux-testing.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchurl, perl, buildLinux, libelf, utillinux, ... } @ args: +{ stdenv, buildPackages, hostPlatform, fetchurl, perl, buildLinux, libelf, utillinux, ... } @ args: import ./generic.nix (args // rec { version = "4.15-rc8"; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index e1936495921d..187c96cd9f94 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,6 +1,6 @@ -{ runCommand, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl -, libelf ? null -, utillinux ? null +{ buildPackages, runCommand, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl +, libelf +, utillinux , writeTextFile, ubootTools , hostPlatform }: @@ -26,19 +26,11 @@ in { src, # Any patches kernelPatches ? [], - # Patches for native compiling only - nativeKernelPatches ? [], - # Patches for cross compiling only - crossKernelPatches ? [], - # The native kernel .config file + # The kernel .config file configfile, - # The cross kernel .config file - crossConfigfile ? configfile, # Manually specified nixexpr representing the config # If unspecified, this will be autodetected from the .config config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), - # Cross-compiling config - crossConfig ? if allowImportFromDerivation then (readConfig crossConfigfile) else config, # Use defaultMeta // extraMeta extraMeta ? {}, # Whether to utilize the controversial import-from-derivation feature to parse the config @@ -61,8 +53,8 @@ let commonMakeFlags = [ "O=$(buildRoot)" - ] ++ stdenv.lib.optionals (stdenv.platform ? kernelMakeFlags) - stdenv.platform.kernelMakeFlags; + ] ++ stdenv.lib.optionals (hostPlatform.platform ? kernelMakeFlags) + hostPlatform.platform.kernelMakeFlags; drvAttrs = config_: platform: kernelPatches: configfile: let @@ -233,13 +225,13 @@ let maintainers.thoughtpolice ]; platforms = platforms.linux; - } // extraMeta; - }; + }; + } // extraMeta; in assert stdenv.lib.versionAtLeast version "4.14" -> libelf != null; assert stdenv.lib.versionAtLeast version "4.15" -> utillinux != null; -stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKernelPatches) configfile) // { +stdenv.mkDerivation ((drvAttrs config hostPlatform.platform kernelPatches configfile) // { name = "linux-${version}"; enableParallelBuilding = true; @@ -253,20 +245,11 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" ]; makeFlags = commonMakeFlags ++ [ - "ARCH=${stdenv.platform.kernelArch}" + "HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc" + "ARCH=${stdenv.hostPlatform.platform.kernelArch}" + ] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ + "CROSS_COMPILE=${stdenv.cc.targetPrefix}" ]; - karch = stdenv.platform.kernelArch; - - crossAttrs = let cp = hostPlatform.platform; in - (drvAttrs crossConfig cp (kernelPatches ++ crossKernelPatches) crossConfigfile) // { - makeFlags = commonMakeFlags ++ [ - "ARCH=${cp.kernelArch}" - "CROSS_COMPILE=$(crossConfig)-" - ]; - - karch = cp.kernelArch; - - nativeBuildInputs = optional (cp.kernelTarget == "uImage") ubootTools; - }; + karch = hostPlatform.platform.kernelArch; }) diff --git a/pkgs/os-specific/linux/kernel/perf.nix b/pkgs/os-specific/linux/kernel/perf.nix index 4bcf6e037e0f..fd21464a2198 100644 --- a/pkgs/os-specific/linux/kernel/perf.nix +++ b/pkgs/os-specific/linux/kernel/perf.nix @@ -23,8 +23,8 @@ stdenv.mkDerivation { # perf refers both to newt and slang # binutils is required for libbfd. nativeBuildInputs = [ asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt - flex bison libiberty libaudit makeWrapper pkgconfig ]; - buildInputs = [ elfutils python perl newt slang libunwind binutils zlib ] ++ + flex bison libiberty libaudit makeWrapper pkgconfig python perl ]; + buildInputs = [ elfutils newt slang libunwind binutils zlib ] ++ stdenv.lib.optional withGtk gtk2; # Note: we don't add elfutils to buildInputs, since it provides a @@ -40,6 +40,10 @@ stdenv.mkDerivation { "-Wno-error=unused-const-variable" "-Wno-error=misleading-indentation" ]; + makeFlags = if stdenv.hostPlatform == stdenv.buildPlatform + then null + else "CROSS_COMPILE=${stdenv.cc.prefix}"; + installFlags = "install install-man ASCIIDOC8=1"; preFixup = '' @@ -47,15 +51,6 @@ stdenv.mkDerivation { --prefix PATH : "${binutils}/bin" ''; - crossAttrs = { - /* I don't want cross-python or cross-perl - - I don't know if cross-python even works */ - propagatedBuildInputs = [ elfutils.crossDrv newt.crossDrv ]; - makeFlags = "CROSS_COMPILE=${stdenv.cc.targetPrefix}"; - elfutils = elfutils.crossDrv; - inherit (kernel.crossDrv) src patches; - }; - meta = { homepage = https://perf.wiki.kernel.org/; description = "Linux tools to profile with performance counters"; From 50e2bb12f6385f4244a6c52bd9ba75015ead392e Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 28 Oct 2017 21:06:18 -0400 Subject: [PATCH 2/8] kernel: Use build kmod --- pkgs/os-specific/linux/kernel/manual-config.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 187c96cd9f94..89fa3c8fa23d 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,4 +1,4 @@ -{ buildPackages, runCommand, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl +{ buildPackages, runCommand, nettools, bc, perl, gmp, libmpc, mpfr, openssl , libelf , utillinux , writeTextFile, ubootTools @@ -97,7 +97,7 @@ let echo "stripping FHS paths in \`$mf'..." sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' done - sed -i Makefile -e 's|= depmod|= ${kmod}/bin/depmod|' + sed -i Makefile -e 's|= depmod|= ${buildPackages.kmod}/bin/depmod|' ''; configurePhase = '' @@ -203,7 +203,7 @@ let find -empty -type d -delete # Remove reference to kmod - sed -i Makefile -e 's|= ${kmod}/bin/depmod|= depmod|' + sed -i Makefile -e 's|= ${buildPackages.kmod}/bin/depmod|= depmod|' '' else optionalString installsFirmware '' make firmware_install $makeFlags "''${makeFlagsArray[@]}" \ $installFlags "''${installFlagsArray[@]}" From b4b04dd29fe25ea8d690e87218c25ee222007c5b Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Mon, 18 Dec 2017 21:17:15 -0500 Subject: [PATCH 3/8] kernel: Fix cross-compilation --- pkgs/os-specific/linux/kernel/manual-config.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 89fa3c8fa23d..1defd4099a61 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -236,8 +236,8 @@ stdenv.mkDerivation ((drvAttrs config hostPlatform.platform kernelPatches config enableParallelBuilding = true; - nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr ] - ++ optional (stdenv.platform.kernelTarget == "uImage") ubootTools + nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr buildPackages.stdenv.cc ] + ++ optional (stdenv.hostPlatform.platform.kernelTarget == "uImage") buildPackages.ubootTools ++ optional (stdenv.lib.versionAtLeast version "4.14") libelf ++ optional (stdenv.lib.versionAtLeast version "4.15") utillinux ; From a09709bf2a6571838aac2a05d7bd123e7a1d4fa9 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Sat, 13 Jan 2018 21:12:06 -0500 Subject: [PATCH 4/8] kernel: don't force ignoreConfigErrors when cross compiling, only set the default --- pkgs/os-specific/linux/kernel/generic.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index d1733f96c536..8ff92ac1a0aa 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -23,7 +23,8 @@ # symbolic name and `patch' is the actual patch. The patch may # optionally be compressed with gzip or bzip2. kernelPatches ? [] -, ignoreConfigErrors ? hostPlatform.platform.name != "pc" +, ignoreConfigErrors ? hostPlatform.platform.name != "pc" || + hostPlatform != stdenv.buildPlatform , extraMeta ? {} , hostPlatform , ... @@ -58,7 +59,7 @@ let in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); configfile = stdenv.mkDerivation { - #inherit ignoreConfigErrors; + inherit ignoreConfigErrors; name = "linux-config-${version}"; generateConfig = ./generate-config.pl; @@ -74,9 +75,6 @@ let preferBuiltin = hostPlatform.platform.kernelPreferBuiltin or false; arch = hostPlatform.platform.kernelArch; - # TODO(@Ericson2314): No null next hash break - ignoreConfigErrors = if stdenv.hostPlatform == stdenv.buildPlatform then null else true; - crossAttrs = let cp = hostPlatform.platform; in { From 285181a1db49a9b95210ac939a1b827866b0ef29 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Mon, 15 Jan 2018 12:41:55 -0500 Subject: [PATCH 5/8] kernel: remove leftover remnants of old cross compiling system --- pkgs/os-specific/linux/kernel/generic.nix | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 8ff92ac1a0aa..816a1363921a 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -44,14 +44,12 @@ let netfilterRPFilter = true; } // features) kernelPatches; - configWithPlatform = kernelPlatform: import ./common-config.nix { - inherit stdenv version kernelPlatform extraConfig; + config = import ./common-config.nix { + inherit stdenv version extraConfig; + kernelPlatform = hostPlatform; features = kernelFeatures; # Ensure we know of all extra patches, etc. }; - config = configWithPlatform stdenv.platform; - configCross = configWithPlatform hostPlatform.platform; - kernelConfigFun = baseConfig: let configFromPatches = @@ -75,12 +73,6 @@ let preferBuiltin = hostPlatform.platform.kernelPreferBuiltin or false; arch = hostPlatform.platform.kernelArch; - crossAttrs = let - cp = hostPlatform.platform; - in { - ignoreConfigErrors = true; - }; - prePatch = kernel.prePatch + '' # Patch kconfig to print "###" after every question so that # generate-config.pl from the generic builder can answer them. @@ -108,9 +100,7 @@ let }; kernel = buildLinux { - inherit version modDirVersion src kernelPatches stdenv extraMeta; - - configfile = configfile.nativeDrv or configfile; + inherit version modDirVersion src kernelPatches stdenv extraMeta configfile; config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; }; From 92083c3f404620b1e0260946f3330848fdbc1e6b Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Mon, 15 Jan 2018 12:47:08 -0500 Subject: [PATCH 6/8] perf: inherit makeFlags from kernel --- pkgs/os-specific/linux/kernel/perf.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/perf.nix b/pkgs/os-specific/linux/kernel/perf.nix index fd21464a2198..5f79e1b2cac6 100644 --- a/pkgs/os-specific/linux/kernel/perf.nix +++ b/pkgs/os-specific/linux/kernel/perf.nix @@ -11,7 +11,7 @@ assert versionAtLeast kernel.version "3.12"; stdenv.mkDerivation { name = "perf-linux-${kernel.version}"; - inherit (kernel) src; + inherit (kernel) src makeFlags; preConfigure = '' cd tools/perf @@ -40,10 +40,6 @@ stdenv.mkDerivation { "-Wno-error=unused-const-variable" "-Wno-error=misleading-indentation" ]; - makeFlags = if stdenv.hostPlatform == stdenv.buildPlatform - then null - else "CROSS_COMPILE=${stdenv.cc.prefix}"; - installFlags = "install install-man ASCIIDOC8=1"; preFixup = '' From 80f6b8e2ba354f85b48622acf56dde86db0c4e29 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Mon, 15 Jan 2018 12:55:24 -0500 Subject: [PATCH 7/8] kernel: revert seemingly incorrect change to extraMeta merging --- pkgs/os-specific/linux/kernel/manual-config.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 1defd4099a61..6c598e50a0aa 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -225,8 +225,8 @@ let maintainers.thoughtpolice ]; platforms = platforms.linux; - }; - } // extraMeta; + } // extraMeta; + }; in assert stdenv.lib.versionAtLeast version "4.14" -> libelf != null; From 7bb3a044be38810e525cde73d591e006b2118095 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Mon, 15 Jan 2018 22:28:45 -0500 Subject: [PATCH 8/8] kernel: fix dependencies --- pkgs/os-specific/linux/kernel/generic.nix | 3 ++- pkgs/os-specific/linux/kernel/manual-config.nix | 3 ++- pkgs/os-specific/linux/kernel/perf.nix | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 816a1363921a..e00bda692b3c 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -64,7 +64,8 @@ let kernelConfig = kernelConfigFun config; - nativeBuildInputs = [ buildPackages.stdenv.cc perl ]; + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ perl ]; platformName = hostPlatform.platform.name; kernelBaseConfig = hostPlatform.platform.kernelBaseConfig; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 6c598e50a0aa..9a7e96094107 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -236,7 +236,8 @@ stdenv.mkDerivation ((drvAttrs config hostPlatform.platform kernelPatches config enableParallelBuilding = true; - nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr buildPackages.stdenv.cc ] + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr ] ++ optional (stdenv.hostPlatform.platform.kernelTarget == "uImage") buildPackages.ubootTools ++ optional (stdenv.lib.versionAtLeast version "4.14") libelf ++ optional (stdenv.lib.versionAtLeast version "4.15") utillinux diff --git a/pkgs/os-specific/linux/kernel/perf.nix b/pkgs/os-specific/linux/kernel/perf.nix index 5f79e1b2cac6..1936f6578b6f 100644 --- a/pkgs/os-specific/linux/kernel/perf.nix +++ b/pkgs/os-specific/linux/kernel/perf.nix @@ -1,6 +1,6 @@ { lib, stdenv, kernel, elfutils, python, perl, newt, slang, asciidoc, xmlto, makeWrapper , docbook_xsl, docbook_xml_dtd_45, libxslt, flex, bison, pkgconfig, libunwind, binutils -, libiberty, libaudit +, libiberty, libaudit, libbfd , zlib, withGtk ? false, gtk2 ? null }: with lib; @@ -21,10 +21,9 @@ stdenv.mkDerivation { ''; # perf refers both to newt and slang - # binutils is required for libbfd. nativeBuildInputs = [ asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt flex bison libiberty libaudit makeWrapper pkgconfig python perl ]; - buildInputs = [ elfutils newt slang libunwind binutils zlib ] ++ + buildInputs = [ elfutils newt slang libunwind libbfd zlib ] ++ stdenv.lib.optional withGtk gtk2; # Note: we don't add elfutils to buildInputs, since it provides a