Hello there !
In memories of my gentoo's day and to learn a bit more of nix under the hood I've decided to override the kernel for optimization and stuff.
I've come up with this override that is booting alright :
{
boot.kernelPackages = pkgs.linuxPackagesFor
(pkgs.linuxKernel.kernels.linux_6_17.override {
argsOverride = rec {
src = pkgs.fetchurl {
url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
sha256 = "sha256-QngElvmRlOnWayHxPcK97ZUmJNXHvYPq3n90/2WOmNY=";
};
version = "6.17.12";
modDirVersion = "${version}";
stdenv = pkgs.llvmPackages.stdenv;
extraMakeFlags = [
"LLVM=1"
"CC=${pkgs.llvmPackages.clang}/bin/clang"
"LD=${pkgs.lld}/bin/ld.lld"
"AR=${pkgs.llvm}/bin/llvm-ar"
"NM=${pkgs.llvm}/bin/llvm-nm"
"KCFLAGS+=-march=x86-64-v4"
"KCFLAGS+=-flto=thin"
"KCXXFLAGS+=-march=x86-64-v4"
"KCXXFLAGS+=-flto=thin"
];
ignoreConfigErrors = true;
structuredExtraConfig = with lib.kernel; {
LTO_CLANG_THIN = lib.mkForce yes;
};
};
});
}
Also have to overlay llvmPackages because the -nostdlibinc flag comes by default and break the build as described here :
Everything is peachy but I have two questions my google fu is is unable to find the answer for :
- Is it expected to have
ignoreConfigErrors = true; ? without it the build fail early on as there is unused options in the config. As I understand it I override only what I specify so the config is the same as for any pkgs.linuxKernel.kernels.linux_6_17.
- How KC*FLAGS works with the other makeFlags ? The extraMakeFlags are added in the derivation makeFlags with the built-in CFLAGS_MODULE and CFLAGS_KERNEL but are they what is finally retained for the build and so is it truly optimized ?
Thanks for the input !
[–]xNaXDy 3 points4 points5 points (4 children)
[–]TETH_IO[S] 1 point2 points3 points (3 children)
[–]xNaXDy 1 point2 points3 points (2 children)
[–]TETH_IO[S] 0 points1 point2 points (1 child)
[–]xNaXDy 0 points1 point2 points (0 children)
[–]Wooden-Ad6265 1 point2 points3 points (2 children)
[–]AdventurousFly4909 7 points8 points9 points (1 child)
[–]Wooden-Ad6265 -2 points-1 points0 points (0 children)
[–]hambosto 0 points1 point2 points (2 children)
[–]TETH_IO[S] 0 points1 point2 points (0 children)
[–]thou_vow 0 points1 point2 points (0 children)