-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
linux: expose KBUILD_IMAGE as a property of the kernel
#244706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
85d162e
6066eb2
a8aabb8
4a1fa27
e5d500a
d6964c5
4a0d3f4
4058b55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -894,7 +894,8 @@ let | |
|
|
||
| EFI_STUB = yes; # EFI bootloader in the bzImage itself | ||
| 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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be removed, this is only here for tests. |
||
| CGROUPS = yes; # used by systemd | ||
| FHANDLE = yes; # used by systemd | ||
| SECCOMP = yes; # used by systemd >= 231 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,12 @@ | ||||||||||||||||||
| let | ||||||||||||||||||
| # Map of images representations to legacy Makefile targets. | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| defaultMapImageToTargets = { | ||||||||||||||||||
| "uImage" = "uinstall"; | ||||||||||||||||||
| "zImage" = "zinstall"; | ||||||||||||||||||
| "Image.gz" = "zinstall"; | ||||||||||||||||||
| "vmlinux" = "install"; | ||||||||||||||||||
|
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| }; | ||||||||||||||||||
| in | ||||||||||||||||||
| { buildPackages | ||||||||||||||||||
| , callPackage | ||||||||||||||||||
| , perl | ||||||||||||||||||
|
|
@@ -57,6 +66,11 @@ | |||||||||||||||||
| # 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| # FIXME: this should go whenever we can rely on KBUILD_IMAGE to install | ||||||||||||||||||
| # our kernel targets, MIPS is probably the only recent kernel in-tree | ||||||||||||||||||
| # which does not support that yet. | ||||||||||||||||||
| , installTargets ? [ ] | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| , kernelArch ? stdenv.hostPlatform.linuxArch | ||||||||||||||||||
| , kernelTests ? [] | ||||||||||||||||||
| , nixosTests | ||||||||||||||||||
|
|
@@ -92,6 +106,41 @@ let | |||||||||||||||||
| ia32Emulation = true; | ||||||||||||||||||
| } // features) kernelPatches; | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| # Legacy compatibility layer for | ||||||||||||||||||
| # systems relying on `installTarget` | ||||||||||||||||||
| # being a property of the platform. | ||||||||||||||||||
| defaultKernelInstallTargets = [ | ||||||||||||||||||
| stdenv.hostPlatform.linux-kernel.installTarget or | ||||||||||||||||||
| (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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| # We aim to derive the "best" kernel given the current constraints. | ||||||||||||||||||
| defaultKernelTarget = | ||||||||||||||||||
| if stdenv.hostPlatform.isx86 | ||||||||||||||||||
| then "bzImage" | ||||||||||||||||||
| else if stdenv.hostPlatform.isAarch64 | ||||||||||||||||||
| then "Image.gz" | ||||||||||||||||||
| else if (stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isArmv7) | ||||||||||||||||||
| then "vmlinuz" | ||||||||||||||||||
| else if stdenv.hostPlatform.isMips | ||||||||||||||||||
| then "vmlinux" | ||||||||||||||||||
| else if stdenv.hostPlatform.isRiscV | ||||||||||||||||||
| then "Image.xz" | ||||||||||||||||||
| else if stdenv.hostPlatform.isSparc64 | ||||||||||||||||||
| then "Image.gz" | ||||||||||||||||||
| else if stdenv.hostPlatform.isSparc | ||||||||||||||||||
| then "vmlinux" | ||||||||||||||||||
| else if stdenv.hostPlatform.isS390 | ||||||||||||||||||
| then "bzImage" | ||||||||||||||||||
| else if stdenv.hostplatform.isLoongArch64 | ||||||||||||||||||
RaitoBezarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
| then "Image.gz" | ||||||||||||||||||
| else "vmlinux"; | ||||||||||||||||||
|
|
||||||||||||||||||
| finalKernelTarget = if kernelTarget == null then defaultKernelTarget else kernelTarget; | ||||||||||||||||||
| finalInstallTargets = if installTargets != [] then defaultKernelInstallTargets else installTargets; | ||||||||||||||||||
RaitoBezarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
|
||||||||||||||||||
| commonStructuredConfig = import ./common-config.nix { | ||||||||||||||||||
| inherit lib stdenv version; | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -193,6 +242,9 @@ let | |||||||||||||||||
|
|
||||||||||||||||||
| kernel = (callPackage ./manual-config.nix { inherit lib stdenv buildPackages; }) (basicArgs // { | ||||||||||||||||||
| inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile; | ||||||||||||||||||
| kernelTarget = finalKernelTarget; | ||||||||||||||||||
| # kernelTarget has precedence | ||||||||||||||||||
| installTargets = if installTargets != [ ] then finalInstallTargets else [ ]; | ||||||||||||||||||
RaitoBezarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
| pos = builtins.unsafeGetAttrPos "version" args; | ||||||||||||||||||
|
|
||||||||||||||||||
| config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; | ||||||||||||||||||
|
|
@@ -201,6 +253,10 @@ let | |||||||||||||||||
| passthru = basicArgs // { | ||||||||||||||||||
| features = kernelFeatures; | ||||||||||||||||||
| inherit commonStructuredConfig structuredExtraConfig extraMakeFlags isZen isHardened isLibre; | ||||||||||||||||||
|
|
||||||||||||||||||
| kernelTarget = if kernelTarget == null then defaultKernelTarget else kernelTarget; | ||||||||||||||||||
| installTargets = if installTargets != [] then defaultKernelInstallTargets else installTargets; | ||||||||||||||||||
RaitoBezarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
|
||||||||||||||||||
| isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Adds dependencies needed to edit the config: | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,16 @@ in lib.makeOverridable ({ | |||||||
| src, | ||||||||
| # a list of { name=..., patch=..., extraConfig=...} patches | ||||||||
| kernelPatches ? [], | ||||||||
| # KBUILD_IMAGE | ||||||||
| kernelTarget ? null, | ||||||||
| # a list of install targets, e.g. : | ||||||||
| # - uinstall for uImage, U-Boot wrapped image | ||||||||
| # - zinstall for zImage, self-extracting images | ||||||||
| # - install, the generic binary image | ||||||||
|
Comment on lines
+36
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(see suggestion above where I relocated these comments) |
||||||||
| # those targets are legacy and are present | ||||||||
| # only for compatibility with old kernels or MIPS for now. | ||||||||
| # prefer KBUILD_IMAGE instead. | ||||||||
| installTargets ? [], | ||||||||
| # The kernel .config file | ||||||||
| configfile, | ||||||||
| # Manually specified nixexpr representing the config | ||||||||
|
|
@@ -88,14 +98,16 @@ let | |||||||
| isModular = config.isYes "MODULES"; | ||||||||
|
|
||||||||
| kernelConf = stdenv.hostPlatform.linux-kernel; | ||||||||
| target = kernelConf.target or "vmlinux"; | ||||||||
|
|
||||||||
| buildDTBs = kernelConf.DTB or false; | ||||||||
| in | ||||||||
|
|
||||||||
| assert lib.versionOlder version "5.8" -> libelf != null; | ||||||||
| assert lib.versionAtLeast version "5.8" -> elfutils != null; | ||||||||
|
|
||||||||
| # An kernel image target must be explicit as we cannot learn it | ||||||||
| # from the defaults in the different Makefile. | ||||||||
| assert kernelTarget != null || installTargets != []; | ||||||||
|
|
||||||||
|
Comment on lines
+107
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm not sure what situation this |
||||||||
| stdenv.mkDerivation ({ | ||||||||
| pname = "linux"; | ||||||||
| inherit version src; | ||||||||
|
|
@@ -220,6 +232,7 @@ stdenv.mkDerivation ({ | |||||||
| ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ | ||||||||
| "CROSS_COMPILE=${stdenv.cc.targetPrefix}" | ||||||||
| ] ++ (kernelConf.makeFlags or []) | ||||||||
| ++ lib.optional (kernelTarget != null) "KBUILD_IMAGE=${kernelTarget}" | ||||||||
| ++ extraMakeFlags; | ||||||||
|
|
||||||||
| karch = stdenv.hostPlatform.linuxArch; | ||||||||
|
|
@@ -296,12 +309,7 @@ stdenv.mkDerivation ({ | |||||||
| ''; | ||||||||
|
|
||||||||
| # Some image types need special install targets (e.g. uImage is installed with make uinstall) | ||||||||
| installTargets = [ | ||||||||
| (kernelConf.installTarget or ( | ||||||||
| /**/ if target == "uImage" then "uinstall" | ||||||||
| else if target == "zImage" || target == "Image.gz" then "zinstall" | ||||||||
| else "install")) | ||||||||
| ]; | ||||||||
| installTargets = if installTargets == [ ] then [ "install" ] else installTargets; | ||||||||
|
|
||||||||
| postInstall = optionalString isModular '' | ||||||||
| if [ -z "''${dontStrip-}" ]; then | ||||||||
|
|
@@ -332,7 +340,8 @@ stdenv.mkDerivation ({ | |||||||
| cp -HR $buildRoot/$f $dev/lib/modules/${modDirVersion}/build/$f | ||||||||
| fi | ||||||||
| done | ||||||||
| ln -s $dev/lib/modules/${modDirVersion}/build/vmlinux $dev | ||||||||
| mkdir $debug/ | ||||||||
| ln -s $dev/lib/modules/${modDirVersion}/build/vmlinux $debug | ||||||||
|
Comment on lines
-335
to
+344
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's going on here? Seems unrelated. Should this be part of a separate PR? |
||||||||
|
|
||||||||
| # !!! No documentation on how much of the source tree must be kept | ||||||||
| # If/when kernel builds fail due to missing files, you can add | ||||||||
|
|
@@ -424,5 +433,5 @@ stdenv.mkDerivation ({ | |||||||
| } // optionalAttrs (pos != null) { | ||||||||
| inherit pos; | ||||||||
| } // optionalAttrs isModular { | ||||||||
| outputs = [ "out" "dev" ]; | ||||||||
| outputs = [ "out" "dev" "debug" ]; | ||||||||
|
Comment on lines
-427
to
+436
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's going on here? Seems unrelated. Should this be part of a separate PR? |
||||||||
| })) | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.