I am trying to build a specific commit from kernel 5.16.9 fetched from the stable kernel repo. Purpose being that I have to find a bug which first occurred on my machine starting with kernel 5.16.10. I use the following approach:
{ pkgs, ... }:
{
boot.kernelPackages =
let
linux_pkg = { fetchgit, buildLinux, ... } @ args:
buildLinux (args // rec {
version = "5.16.9";
modDirVersion = version;
src = fetchgit
{
url = "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/";
rev = "91fc147";
sha256 = "Dz+CpecLcVU/jA00gCnOenDhL8yYzMxM58uCXcTtzj0=";
};
kernelPatches = [ ];
extraMeta.branch = "5.16";
} // (args.argsOverride or { }));
linux_5-16-9 = pkgs.callPackage linux_pkg { };
in
pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_5-16-9);
}
However the build itself fails with the follow error that I cannot really wrap my head around:
error: builder for '/nix/store/bmmnyw3mimg3x01x9l8v396dn7vbqkj5-linux-5.16.9.drv' failed with exit code 2;
last 10 log lines:
> KSYMS .tmp_vmlinux.kallsyms2.S
> AS .tmp_vmlinux.kallsyms2.S
> LD vmlinux
> /nix/store/pnajkjw1fz03z1x27ski1qbx9n3hd4df-binutils-2.39/bin/ld: warning: .btf.vmlinux.bin.o: missing .note.GNU-stack section implies executable stack
> /nix/store/pnajkjw1fz03z1x27ski1qbx9n3hd4df-binutils-2.39/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
> /nix/store/pnajkjw1fz03z1x27ski1qbx9n3hd4df-binutils-2.39/bin/ld: warning: vmlinux has a LOAD segment with RWX permissions
> BTFIDS vmlinux
> FAILED: load BTF from vmlinux: Invalid argument
> make: *** [../Makefile:1161: vmlinux] Error 255
> make: *** Deleting file 'vmlinux'
For full logs, run 'nix log /nix/store/bmmnyw3mimg3x01x9l8v396dn7vbqkj5-linux-5.16.9.drv'.
How to fix this and get kernel 5.16.9 working? I’ve been googling a bit, but I am not really sure what to do. I found something about compiling the kernel with a different version of pahole
or dwarves
, but I am unsure how to implement that in nix.
I found a suggestion here:
https://lore.kernel.org/dwarves/Ywj6ZcqWsz8Au6qO@kernel.org/T/
The guy on the mailing list mentions this: “Perhaps, .tmp_vmlinux.btf is generated incorrectly? Downgrading dwarves to v1.23 resolves the issue.”
So how would I go about downgrading dwarves
to v1.23 for my kernel build?