Skip to content

Commit d3e6c8f

Browse files
Ma27alyssais
andcommitted
linux: implement rustAvailable condition
* It doesn't matter if `rustc` is available, but if rustc can compile to the hostPlatform. So use a custom condition instead of `availableOn`. * Explicitly exclude the combination of GCC and riscv which is known to be broken[1]. [1] https://lore.kernel.org/lkml/[email protected]/T/ Co-authored-by: Alyssa Ross <[email protected]>
1 parent bda6c82 commit d3e6c8f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Configuration
1313
{ lib, stdenv, version
14+
, rustAvailable
1415

1516
, features ? {}
1617
}:
@@ -34,7 +35,7 @@ let
3435

3536
# Currently only enabling Rust by default on kernel 6.12+,
3637
# which actually has features that use Rust that we want.
37-
defaultRust = lib.versionAtLeast version "6.12" && (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isAarch64);
38+
defaultRust = lib.versionAtLeast version "6.12" && rustAvailable;
3839
withRust = (forceRust || defaultRust) && kernelSupportsRust;
3940

4041
options = {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ let
108108

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

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

0 commit comments

Comments
 (0)