Add experimental AutoFDO support (Fix #23)

This commit is contained in:
Lan Tian 2026-01-17 12:35:36 -08:00
parent 359d765c4d
commit 857785a803
No known key found for this signature in database
GPG Key ID: 04E66B6B25A0862B

View File

@ -48,6 +48,14 @@ lib.makeOverridable (
acpiCall ? false,
handheld ? false,
# AutoFDO settings
# AutoFDO hasn't been fully tested. Please report issue if you encounter any.
#
# false - Disable AutoFDO
# true - Enable AutoFDO for profiling performance patterns only
# ./path/to/autofdo/profile: Enable AutoFDO with specified profile
autofdo ? false,
# Build as much components as possible as kernel modules, including disabled ones.
# This can enable unexpected modules, such as nova_core.
# https://github.com/xddxdd/nix-cachyos-kernel/issues/13
@ -59,6 +67,10 @@ lib.makeOverridable (
# Additional args are passed to buildLinux.
...
}@args:
# AutoFDO requires Clang compiler
assert autofdo != false -> lto != "none";
let
helpers = callPackage ../helpers.nix { };
inherit (helpers) stdenvLLVM ltoMakeflags;
@ -129,6 +141,9 @@ lib.makeOverridable (
// (lib.optionalAttrs bbr3 cachySettings.bbr3)
// (lib.optionalAttrs (hugepage != null) cachySettings.hugepage."${hugepage}")
// (lib.optionalAttrs (processorOpt != null) cachySettings.processorOpt.${processorOpt})
// (lib.optionalAttrs (autofdo != false) {
AUTOFDO_CLANG = lib.kernel.yes;
})
))
# Apply user custom settings
@ -155,7 +170,12 @@ lib.makeOverridable (
# Select stdenv/stdenvLLVM based on requested compiler
(args.stdenv or (if lto == "none" then stdenv else stdenvLLVM));
extraMakeFlags = (lib.optionals (lto != "none") ltoMakeflags) ++ (args.extraMakeFlags or [ ]);
extraMakeFlags =
(lib.optionals (lto != "none") ltoMakeflags)
++ lib.optionals (builtins.isPath autofdo) [
"CLANG_AUTOFDO_PROFILE=${autofdo}"
]
++ (args.extraMakeFlags or [ ]);
defconfig = args.defconfig or "cachyos_defconfig";