Skip to content

Commit f88a223

Browse files
authored
linux/common-config: Adjust some options unavailable on i686 (NixOS#384588)
2 parents 7296c7f + d0d4a8c commit f88a223

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

pkgs/os-specific/linux/kernel/common-config.nix

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,25 @@ let
4343
);
4444

4545
forceRust = features.rust or false;
46-
kernelSupportsRust = lib.versionAtLeast version "6.7";
46+
# Architecture support collected from HAVE_RUST Kconfig definitions and the following table:
47+
# https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/rust/arch-support.rst
48+
rustByDefault = (
49+
lib.versionAtLeast version "6.12"
50+
&& (
51+
stdenv.hostPlatform.isx86_64
52+
|| stdenv.hostPlatform.isLoongArch64
53+
|| stdenv.hostPlatform.isAarch64
54+
|| (stdenv.hostPlatform.isRiscV64 && !stdenv.cc.isGNU)
55+
)
56+
);
4757

48-
# Currently only enabling Rust by default on kernel 6.12+,
49-
# which actually has features that use Rust that we want.
50-
defaultRust = lib.versionAtLeast version "6.12" && rustAvailable;
5158
withRust =
52-
assert lib.assertMsg (!(forceRust && !kernelSupportsRust)) ''
53-
Kernels below 6.7 (the kernel being built is ${version}) don't support Rust.
54-
'';
55-
(forceRust || defaultRust) && kernelSupportsRust;
59+
lib.warnIfNot (forceRust -> rustAvailable)
60+
"force-enabling Rust for Linux without an available rustc"
61+
lib.warnIfNot
62+
(forceRust -> rustByDefault)
63+
"force-enabling Rust for Linux on an unsupported kernel version, host platform or compiler"
64+
(forceRust || (rustAvailable && rustByDefault));
5665

5766
options = {
5867

@@ -1054,7 +1063,7 @@ let
10541063
HIDRAW = yes;
10551064

10561065
# Enable loading HID fixups as eBPF from userspace
1057-
HID_BPF = whenAtLeast "6.3" yes;
1066+
HID_BPF = whenAtLeast "6.3" (whenPlatformHasEBPFJit yes);
10581067

10591068
HID_ACRUX_FF = yes;
10601069
DRAGONRISE_FF = yes;
@@ -1281,7 +1290,7 @@ let
12811290
LIRC = yes;
12821291

12831292
SCHED_CORE = whenAtLeast "5.14" yes;
1284-
SCHED_CLASS_EXT = whenAtLeast "6.12" yes;
1293+
SCHED_CLASS_EXT = whenAtLeast "6.12" (whenPlatformHasEBPFJit yes);
12851294

12861295
LRU_GEN = whenAtLeast "6.1" yes;
12871296
LRU_GEN_ENABLED = whenAtLeast "6.1" yes;

pkgs/os-specific/linux/kernel/generic.nix

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,7 @@ let
109109

110110
commonStructuredConfig = import ./common-config.nix {
111111
inherit lib stdenv version;
112-
rustAvailable =
113-
lib.any (lib.meta.platformMatch stdenv.hostPlatform) rustc.targetPlatforms
114-
&& lib.all (p: !lib.meta.platformMatch stdenv.hostPlatform p) rustc.badTargetPlatforms
115-
# Known to be broken: https://lore.kernel.org/lkml/[email protected]/T/
116-
&& !(stdenv.hostPlatform.isRiscV && stdenv.cc.isGNU);
112+
rustAvailable = lib.meta.availableOn stdenv.hostPlatform rustc;
117113

118114
features = kernelFeatures; # Ensure we know of all extra patches, etc.
119115
};

0 commit comments

Comments
 (0)