Skip to content

Commit cfb4fd5

Browse files
committed
linux/common-config: Overhaul Rust for Linux enabling logic
The table with kernel version and compiler requirements only starts from Linux 6.12 now (the previous default), so update the force-enable logic to accommodate users that don't want to follow those suggestions. This includes printing warnings instead of asserting and allowing the force-enable to override both the compiler check and the version (or architecture) check.
1 parent 3f646e1 commit cfb4fd5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let
4545
forceRust = features.rust or false;
4646
# Architecture support collected from HAVE_RUST Kconfig definitions and the following table:
4747
# https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/rust/arch-support.rst
48-
kernelSupportsRust = (
48+
rustByDefault = (
4949
lib.versionAtLeast version "6.12"
5050
&& (
5151
stdenv.hostPlatform.isx86_64
@@ -55,14 +55,13 @@ let
5555
)
5656
);
5757

58-
# Currently only enabling Rust by default on kernel 6.12+,
59-
# which actually has features that use Rust that we want.
60-
defaultRust = lib.versionAtLeast version "6.12" && rustAvailable;
6158
withRust =
62-
assert lib.assertMsg (!(forceRust && !kernelSupportsRust)) ''
63-
Kernel ${version} is not declared as supporting Rust on this host platform and compiler.
64-
'';
65-
(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));
6665

6766
options = {
6867

0 commit comments

Comments
 (0)