Commit d3e6c8fc authored by Maximilian Bosch's avatar Maximilian Bosch Committed by Alyssa Ross
Browse files

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/31885EDD-EF6D-4EF1-94CA-276BA7A340B7@kernel.org/T/



Co-authored-by: default avatarAlyssa Ross <hi@alyssa.is>
parent bda6c82a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@

# Configuration
{ lib, stdenv, version
, rustAvailable

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

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

  options = {
+5 −0
Original line number Diff line number Diff line
@@ -108,6 +108,11 @@ let

  commonStructuredConfig = import ./common-config.nix {
    inherit lib stdenv version;
    rustAvailable =
      lib.any (lib.meta.platformMatch stdenv.hostPlatform) rustc.targetPlatforms
      && lib.all (p: !lib.meta.platformMatch stdenv.hostPlatform p) rustc.badTargetPlatforms
      # Known to be broken: https://lore.kernel.org/lkml/31885EDD-EF6D-4EF1-94CA-276BA7A340B7@kernel.org/T/
      && !(stdenv.hostPlatform.isRiscV && stdenv.cc.isGNU);

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