From 7a9b6ac39a34da8661219e00350955f51122eef8 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 28 Oct 2017 15:09:54 -0400 Subject: kernel: Enable cross compiling --- pkgs/os-specific/linux/kernel/generic.nix | 50 ++++++++++--------------------- 1 file changed, 15 insertions(+), 35 deletions(-) (limited to 'pkgs/os-specific/linux/kernel/generic.nix') diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index b1df6c54c45..d1733f96c53 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 -- cgit 1.4.1