Merge pull request #16 from sempiternal-aurora/master

Allow FullLTO as a choice
This commit is contained in:
Yuhui Xu 2025-12-28 02:08:40 -08:00 committed by GitHub
commit a3aa71a8eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 30 deletions

View File

@ -16,25 +16,23 @@ builtins.listToAttrs (
pname = "linux-cachyos-latest";
inherit (linux_latest) version src;
configVariant = "linux-cachyos";
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-latest-lto";
inherit (linux_latest) version src;
configVariant = "linux-cachyos";
lto = true;
lto = "thin";
})
(mkCachyKernel {
pname = "linux-cachyos-lts";
inherit (linux) version src;
configVariant = "linux-cachyos-lts";
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-lts-lto";
inherit (linux) version src;
configVariant = "linux-cachyos-lts";
lto = true;
lto = "thin";
})
# Additional CachyOS provided variants
@ -42,81 +40,75 @@ builtins.listToAttrs (
pname = "linux-cachyos-bmq";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-bmq";
lto = false;
cpusched = "bmq";
})
(mkCachyKernel {
pname = "linux-cachyos-bmq-lto";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-bmq";
lto = true;
lto = "thin";
cpusched = "bmq";
})
(mkCachyKernel {
pname = "linux-cachyos-bore";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-bore";
lto = false;
cpusched = "bore";
})
(mkCachyKernel {
pname = "linux-cachyos-bore-lto";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-bore";
lto = true;
lto = "thin";
cpusched = "bore";
})
(mkCachyKernel {
pname = "linux-cachyos-deckify";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-deckify";
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-deckify-lto";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-deckify";
lto = true;
lto = "thin";
})
(mkCachyKernel {
pname = "linux-cachyos-eevdf";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-eevdf";
cpusched = "eevdf";
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-eevdf-lto";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-eevdf";
cpusched = "eevdf";
lto = true;
lto = "thin";
})
(mkCachyKernel {
pname = "linux-cachyos-hardened";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-hardened";
hardened = true;
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-hardened-lto";
inherit (linux_latest) version src;
configVariant = "linux-cachyos-hardened";
hardened = true;
lto = true;
lto = "thin";
})
(mkCachyKernel {
pname = "linux-cachyos-rc";
inherit (linux_testing) version src;
configVariant = "linux-cachyos-rc";
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-rc-lto";
inherit (linux_testing) version src;
configVariant = "linux-cachyos-rc";
lto = true;
lto = "thin";
})
(mkCachyKernel {
pname = "linux-cachyos-rt-bore";
@ -124,7 +116,6 @@ builtins.listToAttrs (
configVariant = "linux-cachyos-rt-bore";
rt = true;
cpusched = "bore";
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-rt-bore-lto";
@ -132,7 +123,7 @@ builtins.listToAttrs (
configVariant = "linux-cachyos-rt-bore";
rt = true;
cpusched = "bore";
lto = true;
lto = "thin";
})
(mkCachyKernel {
pname = "linux-cachyos-server";
@ -141,7 +132,6 @@ builtins.listToAttrs (
cpusched = "eevdf";
hzTicks = "300";
preemptType = "none";
lto = false;
})
(mkCachyKernel {
pname = "linux-cachyos-server-lto";
@ -150,7 +140,7 @@ builtins.listToAttrs (
cpusched = "eevdf";
hzTicks = "300";
preemptType = "none";
lto = true;
lto = "thin";
})
]
)

View File

@ -17,8 +17,9 @@ lib.makeOverridable (
# See https://github.com/CachyOS/linux-cachyos for available values.
configVariant,
# Set to true to enable Clang+ThinLTO.
lto,
# Set to one of "none", "thin" or "full", anything other than "none" uses Clang
# to build the kernel with the selected LTO option
lto ? "none",
# Patches to be applied in patchedSrc phase. This is different from buildLinux's kernelPatches.
prePatch ? "",
@ -53,6 +54,11 @@ lib.makeOverridable (
# Additional args are passed to buildLinux.
...
}@args:
assert lib.assertOneOf "LTO Valid Options" lto [
"none"
"thin"
"full"
];
let
helpers = callPackage ../helpers.nix { };
inherit (helpers) stdenvLLVM ltoMakeflags;
@ -95,7 +101,7 @@ lib.makeOverridable (
'';
};
defaultLocalVersion = if lto then "-cachyos-lto" else "-cachyos";
defaultLocalVersion = if lto == "none" then "-cachyos" else "-cachyos-lto";
cachySettings = callPackage ./cachySettings.nix { };
structuredExtraConfig =
@ -112,10 +118,10 @@ lib.makeOverridable (
OVERLAY_FS_XINO_AUTO = no;
OVERLAY_FS_METACOPY = no;
OVERLAY_FS_DEBUG = no;
})
// (lib.optionalAttrs lto {
LTO_NONE = lib.kernel.no;
LTO_CLANG_THIN = lib.kernel.yes;
LTO_NONE = if lto == "none" then lib.kernel.yes else lib.kernel.no;
LTO_CLANG_THIN = if lto == "thin" then lib.kernel.yes else lib.kernel.no;
LTO_CLANG_FULL = if lto == "full" then lib.kernel.yes else lib.kernel.no;
})
# Apply CachyOS specific settings
@ -149,9 +155,9 @@ lib.makeOverridable (
// {
inherit pname version;
src = patchedSrc;
stdenv = args.stdenv or (if lto then stdenvLLVM else stdenv);
stdenv = args.stdenv or (if lto == "none" then stdenv else stdenvLLVM);
extraMakeFlags = (lib.optionals lto ltoMakeflags) ++ (args.extraMakeFlags or [ ]);
extraMakeFlags = (lib.optionals (lto != "none") ltoMakeflags) ++ (args.extraMakeFlags or [ ]);
defconfig = args.defconfig or "cachyos_defconfig";
@ -163,7 +169,10 @@ lib.makeOverridable (
inherit structuredExtraConfig autoModules;
extraMeta = {
description = "Linux CachyOS Kernel" + lib.optionalString lto " with Clang+ThinLTO";
description =
"Linux CachyOS Kernel"
+ lib.optionalString (lto == "thin") " with Clang+ThinLTO"
+ lib.optionalString (lto == "full") " with Clang+FullLTO";
broken = !stdenv.isx86_64;
}
// (args.extraMeta or { });