Skip to content

Commit e9b2edb

Browse files
linux: un-simplify toolchain selection
This reverts commit 70cc251. This commit caused gcc to be pulled in as a target compiler for pkgsLLVM. Co-authored-by: Tristan Ross <tristan.ross@midstall.com>
1 parent a155990 commit e9b2edb

4 files changed

Lines changed: 56 additions & 23 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ let
525525
DRM_AMD_DC_DCN = lib.mkIf (with stdenv.hostPlatform; isx86 || isPower64) (
526526
whenBetween "5.11" "6.4" yes
527527
);
528-
DRM_AMD_DC_FP = whenAtLeast "6.4" yes;
528+
# Not available when using clang
529+
# See: https://github.com/torvalds/linux/blob/172a9d94339cea832d89630b89d314e41d622bd8/drivers/gpu/drm/amd/display/Kconfig#L14
530+
DRM_AMD_DC_FP = lib.mkIf (!stdenv.cc.isClang) (whenAtLeast "6.4" yes);
529531
DRM_AMD_DC_HDCP = whenBetween "5.5" "6.4" yes;
530532
DRM_AMD_DC_SI = whenAtLeast "5.10" yes;
531533

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
lib,
3+
stdenv,
4+
buildPackages,
5+
extraMakeFlags ? [ ],
6+
}:
7+
# Absolute paths for compilers avoid any PATH-clobbering issues.
8+
[
9+
#
10+
# We use the unwrapped compiler, because the clang-wrapper doesn't like -target.
11+
"CC=${lib.getExe stdenv.cc.cc}"
12+
# The wrapper for ld.lld breaks linking the kernel. We use the unwrapped linker as workaround. See:
13+
# https://github.com/NixOS/nixpkgs/issues/321667
14+
"LD=${lib.getExe' stdenv.cc.bintools.bintools "${stdenv.cc.targetPrefix}ld"}"
15+
"AR=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}ar"}"
16+
"NM=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}nm"}"
17+
"STRIP=${lib.getExe' stdenv.cc.bintools.bintools "${stdenv.cc.targetPrefix}strip"}"
18+
"OBJCOPY=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}objcopy"}"
19+
"OBJDUMP=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}objdump"}"
20+
"READELF=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}readelf"}"
21+
"HOSTCC=${lib.getExe' buildPackages.stdenv.cc "${buildPackages.stdenv.cc.targetPrefix}cc"}"
22+
"HOSTCXX=${lib.getExe' buildPackages.stdenv.cc "${buildPackages.stdenv.cc.targetPrefix}c++"}"
23+
"HOSTAR=${lib.getExe' buildPackages.stdenv.cc.bintools "${buildPackages.stdenv.cc.targetPrefix}ar"}"
24+
"HOSTLD=${lib.getExe' buildPackages.stdenv.cc.bintools "${buildPackages.stdenv.cc.targetPrefix}ld"}"
25+
"ARCH=${stdenv.hostPlatform.linuxArch}"
26+
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
27+
]
28+
# Add the built in headers the kernel needs
29+
++ lib.optionals (stdenv.cc.isClang) [
30+
"CFLAGS_MODULE=-I${lib.getLib stdenv.cc.cc}/lib/clang/${lib.versions.major stdenv.cc.cc.version}/include"
31+
"CFLAGS_KERNEL=-I${lib.getLib stdenv.cc.cc}/lib/clang/${lib.versions.major stdenv.cc.cc.version}/include"
32+
]
33+
++ (stdenv.hostPlatform.linux-kernel.makeFlags or [ ])
34+
++ extraMakeFlags

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ let
191191
++ lib.optional (lib.versionAtLeast version "5.2") pahole
192192
++ lib.optionals withRust [
193193
rust-bindgen
194-
rustc
194+
rustc.unwrapped
195195
];
196196

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

204-
makeFlags =
205-
lib.optionals (
206-
stdenv.hostPlatform.linux-kernel ? makeFlags
207-
) stdenv.hostPlatform.linux-kernel.makeFlags
208-
++ extraMakeFlags;
204+
makeFlags = import ./common-flags.nix {
205+
inherit
206+
lib
207+
stdenv
208+
buildPackages
209+
extraMakeFlags
210+
;
211+
};
209212

210213
postPatch = kernel.postPatch + ''
211214
# Patch kconfig to print "###" after every question so that

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ lib.makeOverridable (
170170
++ optional (lib.versionAtLeast version "5.13") zstd
171171
++ optionals withRust [
172172
rustc
173-
rust-bindgen
173+
rust-bindgen.unwrapped
174174
];
175175

176176
in
@@ -230,7 +230,7 @@ lib.makeOverridable (
230230
]
231231
++ optionals withRust [
232232
rustc
233-
rust-bindgen
233+
rust-bindgen.unwrapped
234234
];
235235

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

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

550544
stdenv.mkDerivation (

0 commit comments

Comments
 (0)