Unverified Commit e9b2edb4 authored by Julian Stecklina's avatar Julian Stecklina Committed by Tristan Ross
Browse files

linux: un-simplify toolchain selection



This reverts commit 70cc2515.

This commit caused gcc to be pulled in as a target compiler for
pkgsLLVM.

Co-authored-by: default avatarTristan Ross <tristan.ross@midstall.com>
parent a1559903
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -525,7 +525,9 @@ let
        DRM_AMD_DC_DCN = lib.mkIf (with stdenv.hostPlatform; isx86 || isPower64) (
          whenBetween "5.11" "6.4" yes
        );
        DRM_AMD_DC_FP = whenAtLeast "6.4" yes;
        # Not available when using clang
        # See: https://github.com/torvalds/linux/blob/172a9d94339cea832d89630b89d314e41d622bd8/drivers/gpu/drm/amd/display/Kconfig#L14
        DRM_AMD_DC_FP = lib.mkIf (!stdenv.cc.isClang) (whenAtLeast "6.4" yes);
        DRM_AMD_DC_HDCP = whenBetween "5.5" "6.4" yes;
        DRM_AMD_DC_SI = whenAtLeast "5.10" yes;

+34 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildPackages,
  extraMakeFlags ? [ ],
}:
# Absolute paths for compilers avoid any PATH-clobbering issues.
[
  #
  # We use the unwrapped compiler, because the clang-wrapper doesn't like -target.
  "CC=${lib.getExe stdenv.cc.cc}"
  # The wrapper for ld.lld breaks linking the kernel. We use the unwrapped linker as workaround. See:
  # https://github.com/NixOS/nixpkgs/issues/321667
  "LD=${lib.getExe' stdenv.cc.bintools.bintools "${stdenv.cc.targetPrefix}ld"}"
  "AR=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}ar"}"
  "NM=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}nm"}"
  "STRIP=${lib.getExe' stdenv.cc.bintools.bintools "${stdenv.cc.targetPrefix}strip"}"
  "OBJCOPY=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}objcopy"}"
  "OBJDUMP=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}objdump"}"
  "READELF=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}readelf"}"
  "HOSTCC=${lib.getExe' buildPackages.stdenv.cc "${buildPackages.stdenv.cc.targetPrefix}cc"}"
  "HOSTCXX=${lib.getExe' buildPackages.stdenv.cc "${buildPackages.stdenv.cc.targetPrefix}c++"}"
  "HOSTAR=${lib.getExe' buildPackages.stdenv.cc.bintools "${buildPackages.stdenv.cc.targetPrefix}ar"}"
  "HOSTLD=${lib.getExe' buildPackages.stdenv.cc.bintools "${buildPackages.stdenv.cc.targetPrefix}ld"}"
  "ARCH=${stdenv.hostPlatform.linuxArch}"
  "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
]
# Add the built in headers the kernel needs
++ lib.optionals (stdenv.cc.isClang) [
  "CFLAGS_MODULE=-I${lib.getLib stdenv.cc.cc}/lib/clang/${lib.versions.major stdenv.cc.cc.version}/include"
  "CFLAGS_KERNEL=-I${lib.getLib stdenv.cc.cc}/lib/clang/${lib.versions.major stdenv.cc.cc.version}/include"
]
++ (stdenv.hostPlatform.linux-kernel.makeFlags or [ ])
++ extraMakeFlags
+9 −6
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ let
        ++ lib.optional (lib.versionAtLeast version "5.2") pahole
        ++ lib.optionals withRust [
          rust-bindgen
          rustc
          rustc.unwrapped
        ];

        RUST_LIB_SRC = lib.optionalString withRust rustPlatform.rustLibSrc;
@@ -201,11 +201,14 @@ let
        kernelBaseConfig =
          if defconfig != null then defconfig else stdenv.hostPlatform.linux-kernel.baseConfig;

        makeFlags =
          lib.optionals (
            stdenv.hostPlatform.linux-kernel ? makeFlags
          ) stdenv.hostPlatform.linux-kernel.makeFlags
          ++ extraMakeFlags;
        makeFlags = import ./common-flags.nix {
          inherit
            lib
            stdenv
            buildPackages
            extraMakeFlags
            ;
        };

        postPatch = kernel.postPatch + ''
          # Patch kconfig to print "###" after every question so that
+10 −16
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ lib.makeOverridable (
        ++ optional (lib.versionAtLeast version "5.13") zstd
        ++ optionals withRust [
          rustc
          rust-bindgen
          rust-bindgen.unwrapped
        ];

      in
@@ -230,7 +230,7 @@ lib.makeOverridable (
        ]
        ++ optionals withRust [
          rustc
          rust-bindgen
          rust-bindgen.unwrapped
        ];

        RUST_LIB_SRC = lib.optionalString withRust rustPlatform.rustLibSrc;
@@ -531,20 +531,14 @@ lib.makeOverridable (
        // extraMeta;
      };

    # Absolute paths for compilers avoid any PATH-clobbering issues.
    commonMakeFlags = [
      "ARCH=${stdenv.hostPlatform.linuxArch}"
      "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
    ]
    ++ lib.optionals (stdenv.isx86_64 && stdenv.cc.bintools.isLLVM) [
      # The wrapper for ld.lld breaks linking the kernel. We use the
      # unwrapped linker as workaround. See:
      #
      # https://github.com/NixOS/nixpkgs/issues/321667
      "LD=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ld"
    ]
    ++ (stdenv.hostPlatform.linux-kernel.makeFlags or [ ])
    ++ extraMakeFlags;
    commonMakeFlags = import ./common-flags.nix {
      inherit
        lib
        stdenv
        buildPackages
        extraMakeFlags
        ;
    };
  in

  stdenv.mkDerivation (