buildLinux: take and propagate extraMakeFlags

This is just for practicity, as it allows users of buildLinux to pass
along extra flags they need in the kernel's make invocation. This makes,
for example, supporting LLVM _much_ easier, and could enable us in the
future to provide clang-built kernels.
This commit is contained in:
Bernardo Meurer 2021-07-11 21:58:16 -07:00
parent 89deec5623
commit ea167e8ccb
No known key found for this signature in database
GPG key ID: F4C0D53B8D14C246
2 changed files with 15 additions and 6 deletions

View file

@ -21,6 +21,9 @@
, # Legacy overrides to the intermediate kernel config, as string
extraConfig ? ""
# Additional make flags passed to kbuild
, extraMakeFlags ? []
, # kernel intermediate config overrides, as a set
structuredExtraConfig ? {}
@ -97,7 +100,7 @@ let
in lib.concatStringsSep "\n" ([baseConfigStr] ++ configFromPatches);
configfile = stdenv.mkDerivation {
inherit ignoreConfigErrors autoModules preferBuiltin kernelArch;
inherit ignoreConfigErrors autoModules preferBuiltin kernelArch extraMakeFlags;
pname = "linux-config";
inherit version;
@ -116,7 +119,8 @@ let
# e.g. "bzImage"
kernelTarget = stdenv.hostPlatform.linux-kernel.target;
makeFlags = lib.optionals (stdenv.hostPlatform.linux-kernel ? makeFlags) stdenv.hostPlatform.linux-kernel.makeFlags;
makeFlags = lib.optionals (stdenv.hostPlatform.linux-kernel ? makeFlags) stdenv.hostPlatform.linux-kernel.makeFlags
++ extraMakeFlags;
prePatch = kernel.prePatch + ''
# Patch kconfig to print "###" after every question so that
@ -136,7 +140,8 @@ let
export HOSTLD=$LD_FOR_BUILD
# Get a basic config file for later refinement with $generateConfig.
make -C . O="$buildRoot" $kernelBaseConfig \
make $makeFlags \
-C . O="$buildRoot" $kernelBaseConfig \
ARCH=$kernelArch \
HOSTCC=$HOSTCC HOSTCXX=$HOSTCXX HOSTAR=$HOSTAR HOSTLD=$HOSTLD \
CC=$CC OBJCOPY=$OBJCOPY OBJDUMP=$OBJDUMP READELF=$READELF \
@ -176,7 +181,7 @@ let
}; # end of configfile derivation
kernel = (callPackage ./manual-config.nix {}) {
inherit version modDirVersion src kernelPatches randstructSeed lib stdenv extraMeta configfile;
inherit version modDirVersion src kernelPatches randstructSeed lib stdenv extraMakeFlags extraMeta configfile;
config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
};

View file

@ -19,6 +19,8 @@ in {
stdenv,
# The kernel version
version,
# Additional kernel make flags
extraMakeFlags ? [],
# The version of the kernel module directory
modDirVersion ? version,
# The kernel source (tarball, git checkout, etc.)
@ -173,7 +175,9 @@ let
"KBUILD_BUILD_VERSION=1-NixOS"
kernelConf.target
"vmlinux" # for "perf" and things like that
] ++ optional isModular "modules";
]
++ optional isModular "modules"
++ extraMakeFlags;
installFlags = [
"INSTALLKERNEL=${installkernel}"
@ -325,7 +329,7 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPat
"ARCH=${stdenv.hostPlatform.linuxArch}"
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
];
] ++ extraMakeFlags;
karch = stdenv.hostPlatform.linuxArch;
})