linux: expose KBUILD_IMAGE as a property of the kernel#244706
linux: expose KBUILD_IMAGE as a property of the kernel#244706RaitoBezarius wants to merge 8 commits intoNixOS:masterfrom
KBUILD_IMAGE as a property of the kernel#244706Conversation
KBUILD_IMAGE as a property of the kernel
…tall targets Nowadays, most architectures supports `KBUILD_IMAGE` which is set by the architecture-specific Makefile or can be overriden by the user Before that, we were using Makefile "install targets" such as "uinstall" for uImage, "zinstall" for zImage, etc. We move them into a "legacy" list which is used by default if `kernelTarget` is null.
For completeness, this may be needed for some legacy software or to simplify further refactors. Prefer KBUILD_IMAGE and kernelTarget.
Starting 6.1, it is possible to have generic compression for aarch64 and riscv64 via CONFIG_EFI_ZBOOT which implements apparently its own decompression. https://lwn.net/Articles/907679/
This is useful to distinguish between SPARC64 and SPARC whatever, because SPARC64 do support compressed kernels.
Before, we were sending the uncompressed kernel into the dev output. I'm not sure there is a good reason for that, I am moving it in the debug output.
Asserts that either we have a kernel image target or an non-empty install target.
This should probably use also kernel versions
…nd riscv-multiplatform To exercise our KBUILD_IMAGE setup.
895b284 to
4058b55
Compare
| EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER = | ||
| whenOlder "6.2" (whenAtLeast "5.8" yes); # initrd kernel parameter for EFI | ||
| whenOlder "6.2" (whenAtLeast "5.8" yes); # initrd kernel parameter for EFI | ||
| EFI_ZBOOT = whenAtLeast "6.1" yes; # Generic compression support for EFI payloads |
There was a problem hiding this comment.
Will be removed, this is only here for tests.
|
Doesn't look wrong to me but I haven't done any work on the linux package. |
ghost
left a comment
There was a problem hiding this comment.
Nowadays, most architectures supports
KBUILD_IMAGEwhich is
set by the architecture-specific Makefile or can be overriden by the user
This is not true, a lot of them don't.
Please don't do this.
Our kernel builds got broken on both mips64 and powerpc64 by this:
And they're still broken on PowerPC. f521f46 was merged two days afterwards and makes reverting anything before it massive pain because it was such a huge change.
More "works on aarch64 and x86" yolo-merges to our kernel builder make this worse.
First we need to get back to actually having a working kernel expression for the major architectures. Right now we can't even tell if this breaks them because they aren't building in the first place.
|
@ofborg build pkgsCross.powernv.linux |
To be fair, we discussed this with @alyssais and it made sense to have this (because of what I am saying on the lib/systems stuff later on.) I'm fine with trying our best to not break other architectures, but we have to get a design goal here and I think it's hard if we cannot communicate actively in development channels… :P. Let's go back to design board I guess now. My goal here is to get rid of the "kernel's image install target" property that lives in lib/systems which makes few sense. Kernel image install target should be a property of the kernel itself, because not all kernels supports: whateverImage. In this situation, KBUILD_IMAGE gives us a reliable for the consumer to provide the desired image. Install targets are still available if you read the diff, albeit, they are explicitly marked as legacy. Is it sufficient to make them non-legacy and let them co-exist? |
| isRiscV64 = { cpu = { family = "riscv"; bits = 64; }; }; | ||
| isRx = { cpu = { family = "rx"; }; }; | ||
| isSparc = { cpu = { family = "sparc"; }; }; | ||
| isSparc64 = { cpu = { family = "sparc"; bits = 64; }; }; |
There was a problem hiding this comment.
This is independently useful; could you please split it out in a separate PR? I'll merge it. I'm surprised we don't already have this.
There was a problem hiding this comment.
My goal here is to get rid of the "kernel's image install target" property that lives in lib/systems which makes few sense.
Okay, I see where you're going with this.
I support moving this out of lib/systems. That's a great idea. 👍
I don't think we'll ever get rid of it entirely (your PR moves it into a big if-then-else block in manual-config.nix). I'm very much opposed to pretending we can wish it away without upstream's cooperation, because that's just another way of saying "we're gonna break everything that isn't the two most popular CPUs". The Linux kernel build system is old and weird and crusty and totally custom -- they don't use autoconf or meson or even cmake; they invented their own thing. They don't seem to accept "should be buildable on every architecture with the exact same sequence of commands" as a design goal, and unless they do I dont think we should assume that's possible.
Next steps
You've done a lot of good work here; can we scope this down to simply "move kernelTarget/installTarget out of lib/systems and into linux/kernel"? I think that's an easily achievable short-term goal -- except for one problem, see next paragraph -- and once that part of the PR is merged there will be far less material left and it will be easier to focus on it and understand the consequences.
The "one problem"
Here's the one problem: #221707 broke the build on a bunch of non-top-two architectures, and some of them still haven't been fixed. So we have no way to know if your PR causes additional breakage. I find this to be a fairly absurd situation TBH. We really can't merge additional refactorings without knowing if they break things or not. I don't really know what to do here; I messaged @alyssais on IRC to ask what she thinks should be done about this and the reply I got was sort of a shrug and her saying she's taking some time off from nixpkgs. So I really don't know what to do about this.
| @@ -1,3 +1,12 @@ | |||
| let | |||
| # Map of images representations to legacy Makefile targets. | |||
There was a problem hiding this comment.
| # Map of images representations to legacy Makefile targets. | |
| # Map of images representations to Makefile targets; i.e. run | |
| # `make ${defaultMapImageToTargets imageName}` to get `imageName` |
| # easy overrides to stdenv.hostPlatform.linux-kernel members | ||
| , autoModules ? stdenv.hostPlatform.linux-kernel.autoModules or true | ||
| , preferBuiltin ? stdenv.hostPlatform.linux-kernel.preferBuiltin or false | ||
| , kernelTarget ? null |
There was a problem hiding this comment.
| , kernelTarget ? null | |
| , kernelTarget ? defaultKernelTarget |
| (defaultMapImageToTargets.${stdenv.hostPlatform.linux-kernel.target or "vmlinux"}) | ||
| ]; | ||
|
|
||
| # Default kernel target in the case no install target or kernelTarget is mentioned |
There was a problem hiding this comment.
| # Default kernel target in the case no install target or kernelTarget is mentioned | |
| # Default kernel target in the case no installTarget or kernelTarget is mentioned |
| "uImage" = "uinstall"; | ||
| "zImage" = "zinstall"; | ||
| "Image.gz" = "zinstall"; | ||
| "vmlinux" = "install"; |
There was a problem hiding this comment.
| "uImage" = "uinstall"; | |
| "zImage" = "zinstall"; | |
| "Image.gz" = "zinstall"; | |
| "vmlinux" = "install"; | |
| "uImage" = "uinstall"; # U-Boot wrapped image | |
| "zImage" = "zinstall"; # self-extracting images | |
| "Image.gz" = "zinstall"; | |
| "vmlinux" = "install"; # the generic binary image |
| ln -s $dev/lib/modules/${modDirVersion}/build/vmlinux $dev | ||
| mkdir $debug/ | ||
| ln -s $dev/lib/modules/${modDirVersion}/build/vmlinux $debug |
There was a problem hiding this comment.
What's going on here? Seems unrelated. Should this be part of a separate PR?
| outputs = [ "out" "dev" ]; | ||
| outputs = [ "out" "dev" "debug" ]; |
There was a problem hiding this comment.
What's going on here? Seems unrelated. Should this be part of a separate PR?
Description of changes
Instead of the platform, see
lib/systems/examples.nixfor examples (no pun intended).Nowadays, most architectures supports
KBUILD_IMAGEwhich isset by the architecture-specific Makefile or can be overriden by the user
Before that, we were using Makefile install targets such as "uinstall" for uImage,
"zinstall" for zImage, etc.
This PR aims multiple delicate things:
KBUILD_IMAGEknob to build kernel with a desired image using the vanillainstallMakefile target.lib/systems/examples.nixuntil we phase them out by keeping an override knob for Makefile install targets and passing the legacy ones.installTargetforx86,aarch64-multiplatform,riscv64as a first "target" in this PR.Once, we are able to do this, phase 2 is to move up the knob into NixOS to offer the capability to choose the kernel image to advanced users, i.e. compressed or non-compressed kernel.
Phase 3 is to deprecate
lib/systems/examples.nixwhen nixos-hardware is ready to receive them, we will do it with a proper deprecation notice, etc.In the meantime, grabbing #239721 is interesting to test the effects of this PR for platforms that supports UEFI.
Expected results after some work:
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)