Linux Kernel Toolchain Selection Fixes#390631
Closed
blitz wants to merge 5 commits intoNixOS:masterfrom
Closed
Conversation
Contributor
Author
|
@RossComputerGuy Are you interested in collaborating here? :) |
Contributor
Author
|
Even on 48a0850, |
We had a couple of cases where we used the wrong compiler, let's detect them early.
When the build environment for the configuration and the kernel building differ, make oldconfig might actually change the configuration. This happens for example when the kernel build picks up GCC instead of clang in pkgsLLVM.
This reverts commit 70cc251. This commit caused gcc to be pulled in as a target compiler for pkgsLLVM.
d51b831 to
7837f3d
Compare
7837f3d to
54b69f1
Compare
Contributor
Author
|
The kernels above work now, but without Rust support. |
Cargo is currently broken for cross-compilation setups like pkgsLLVM. There is also some sadness with the bindgen wrapper that isn't solved yet: > BINDGEN rust/bindings/bindings_generated.rs > Unable to generate bindings: clang diagnosed error: error: argument unused during compilation: '-nostdlibinc' [-Wunused-command-line-argument] > > make[3]: *** [../rust/Makefile:311: rust/bindings/bindings_generated.rs] Error 1 > make[3]: *** Deleting file 'rust/bindings/bindings_generated.rs' > make[2]: *** [/build/linux-6.13.7/Makefile:1274: prepare] Error 2 > make[1]: *** [/build/linux-6.13.7/Makefile:251: __sub-make] Error 2 > make[1]: Leaving directory '/build/linux-6.13.7/build' > make: *** [Makefile:251: __sub-make] Error 2 Opt-out of Rust support for now to be able to build the Linux kernel with clang at all.
We get lots of these from the clang-wrapper: Warning: supplying the --target argument to a nix-wrapped compiler may not work correctly - cc-wrapper is currently not designed with multi-target compilers in mind. You may want to use an un-wrapped compiler instead. Let's follow its advice.
54b69f1 to
fbc5923
Compare
Member
|
I need this so I can compile ZFS and use an LLVM built kernel. Any updates? |
Member
|
Applying this diff on top of this: diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index 08d2291d686c..d1a7565f5dbf 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -511,7 +511,7 @@ 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;
+ 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;
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index 77bebfa4a9e9..2f4854fb7266 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -112,9 +112,7 @@ let
rustAvailable = lib.meta.availableOn stdenv.hostPlatform rustc
# Cargo is broken for cross-compilation. See here for context:
# pkgs/development/compilers/rust/cargo.nix
- && !(stdenv.hostPlatform.isx86 && stdenv.buildPlatform != stdenv.hostPlatform)
- # Bindgen and clang don't get along right now.
- && !stdenv.cc.isClang;
+ && !(stdenv.hostPlatform.isx86 && stdenv.buildPlatform != stdenv.hostPlatform);
features = kernelFeatures; # Ensure we know of all extra patches, etc.
};
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index 0b590ad798dd..2b91cdd0aa87 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -459,6 +459,7 @@ let
"HOSTAR=${buildPackages.stdenv.cc.bintools}/bin/${buildPackages.stdenv.cc.targetPrefix}ar"
"HOSTLD=${buildPackages.stdenv.cc.bintools}/bin/${buildPackages.stdenv.cc.targetPrefix}ld"
"ARCH=${stdenv.hostPlatform.linuxArch}"
+ "CFLAGS=-Wno-unused-command-line-argument"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
] ++ (stdenv.hostPlatform.linux-kernel.makeFlags or [])I get this error: |
Contributor
|
This seems to work: (reverted diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index c10d5f6b13b2..3473a3ead8c0 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -245,6 +245,8 @@ lib.makeOverridable (
RUST_LIB_SRC = lib.optionalString withRust rustPlatform.rustLibSrc;
+ BINDGEN_EXTRA_CLANG_ARGS = "-Qunused-arguments";
+
# avoid leaking Rust source file names into the final binary, which adds
# a false dependency on rust-lib-src on targets with uncompressed kernels
KRUSTFLAGS = lib.optionalString withRust "--remap-path-prefix ${rustPlatform.rustLibSrc}=/";
|
13 tasks
Member
|
Thank you for that fix, it builds! I've opened #402198 with the new fixes. |
Contributor
Author
|
Closing in favor of #402198! Thanks for carrying this forward! 🙏🏻 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is another approach to hopefully finally defeat the compiler/toolchain selection bugs in our Linux kernel derivations. See #389485 for a previous approach at fixing this.
I added basic tests that check whether the right compiler is picked up and whether the configfile and kernel build deriviations agree on the toolchain.
To make clang/LLVM toolchains working again, I switched back to explicitly configuring the right tools to use.
Help is very welcome!
From my perspective, the following attributes must work before we can merge this:
Status Overview
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.