-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kernel: fix cross compilation #33813
Conversation
} // extraMeta; | ||
}; | ||
}; | ||
} // extraMeta; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make sense to me. Why shouldn't extraMeta
be merged with the existing meta
attribute?
flex bison libiberty libaudit makeWrapper pkgconfig ]; | ||
buildInputs = [ elfutils python perl newt slang libunwind binutils zlib ] ++ | ||
flex bison libiberty libaudit makeWrapper pkgconfig python perl ]; | ||
buildInputs = [ elfutils newt slang libunwind binutils zlib ] ++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if these dependencies are all correct.
@@ -58,37 +58,29 @@ let | |||
in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); | |||
|
|||
configfile = stdenv.mkDerivation { | |||
inherit ignoreConfigErrors; | |||
#inherit ignoreConfigErrors; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover ?
arch = hostPlatform.platform.kernelArch; | ||
|
||
# TODO(@Ericson2314): No null next hash break | ||
ignoreConfigErrors = if stdenv.hostPlatform == stdenv.buildPlatform then null else true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "No null next hash break" mean?
Also, I just discovered this breaks builds with config errors, because ignoreConfigErrors
does not get defined when not cross compiling and the scripts assume it is defined.
Use of uninitialized value $ENV{"ignoreConfigErrors"} in string ne at /nix/store/2dajr95g51fajq0jgi3jr4xmacjp3pj0-generate-config.pl line 141.
Quite excited to see some improvements on the kernel as it's the most annoying software to work with on nixos. Getting rid of crossplatform-specific code makes patching easir (I have some patches to handle the kernel config in a simpler way but I could not upstream them because they didn't support cross-platform). |
I rebased locally (you need to pay attention to b1ca851 ) but then I get
which is strange since in repl, hostPlatform.platform does exist. EDIT: nevermind, I had a freaking override in my overlays with a random platform. |
#configWithPlatform = kernelPlatform: import ./common-config.nix | ||
# { inherit stdenv version kernelPlatform extraConfig; | ||
# features = passthru.features; # Ensure we know of all extra patches, etc. | ||
# }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover
I pushed a rebased version with leftover removed https://github.com/teto/nixpkgs/tree/kernel_cross which seems ok for host builds. would be nice to check cross platform. |
Thanks for doing this! |
06faef7
to
80f6b8e
Compare
I rebased and added some new commits to fix some cosmetic issues and remove some dead code left over from the old cross compiling system. Most of these changes were not hash breaking, but I did revert a change @bgamari made to how Another thing I was wondering about is why do we need to ignore config errors when cross compiling? Config errors are already ignored on all non "pc" host platforms, so the only case I can think of where the new cross compiling condition would be used is when cross compiling on Darwin for x86_64 Linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
kernelBaseConfig = cp.kernelBaseConfig; | ||
kernelTarget = cp.kernelTarget; | ||
autoModules = cp.kernelAutoModules; | ||
nativeBuildInputs = [ buildPackages.stdenv.cc perl ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a depsBuildBuild
name = "linux-${version}"; | ||
|
||
enableParallelBuilding = true; | ||
|
||
nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr ] | ||
++ optional (stdenv.platform.kernelTarget == "uImage") ubootTools | ||
nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr buildPackages.stdenv.cc ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildPackages.stdenv.cc should again be a depsBuildBuild.
@@ -23,8 +23,8 @@ stdenv.mkDerivation { | |||
# perf refers both to newt and slang | |||
# binutils is required for libbfd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a libbfd derivation now.
Thanks for the patch.
My understanding is that I need to crosscompile for the same architecture just to override some kernel settings :/ ?! I've never done any crosscompilation, what could be the command to compile the kernel with the previous platform please (in a nix-shell for instance) ? NB: the naming hostPlatform.platform is confusing since hostPlatform looks like a platform already, shouldn't it be renamed to hostSystem or accept directly the platform argument ? |
All the You don't need to cross compile, you can pass |
I managed to come up with |
@teto Yes, the syntax of |
Sorry I am a bit dense, I first tried this: NB: I would like to add your answer to the doc PR I prepare #29944 |
@teto that would be something like $ nix-build -A neovim --arg 'localSystem' 'let lib = (import <nixpkgs/lib>); in lib.recursiveUpdate (lib.systems.elaborate { system = builtins.currentSystem; }) { platform.kernelArch = "arm"; }' '<nixpkgs>' --show-trace But don't do something that drastic. You should only change the local system like that for a refinement of the build platform, e.g. building an ivybridge-specific kernel rather than generic x86_64. For x86_64 -> arm, you are unavoidably cross compiling and should use |
My example was bad, I was more interested in changing the platform like |
@teto no worries and yeah it indeed is cumbersome. So if we were to remove the parameters from platform as you suggested, I'd love, if possible, to make it so the scenario I pointed out is impossible. For example maybe |
hostPlatform=super.lib.platforms.pc64_simplekernel; Also adds command shared by ericson1234 at NixOS#33813 to further customize kernel explaining how to really customize kernel config (apart from extraConfig).
This caused me quite a headache. Can some of you have a look at #34882 ? I'm not good in the cross stuff... |
Presents the options available (linuxManualConfig versus overriding extraConfig, ignoreConfigErrors, autoModules, kernelPreferBuiltin. For advanced hostPlatform customization refer to the commands shared by ericson1234 at NixOS#33813 but it is too advanced to put in the doc.
Presents the options available (linuxManualConfig versus overriding extraConfig, ignoreConfigErrors, autoModules, kernelPreferBuiltin. For advanced hostPlatform customization refer to the commands shared by ericson1234 at #33813 but it is too advanced to put in the doc.
This PR contains rebased versions of patches from #30882 to fix Linux kernel cross compilation.
Specifically, this includes:
5c6473c - kernel: Enable cross compiling
d1ccc5d - kernel: Use build kmod
5e91760 - kernel fixes
e915e4a - kernel: Fix cross-compilation
5e91760 has been squashed into 5c6473c because the changes are closely related.
There are a few things that I'm not sure about, or didn't seem right to me.
In 5c6473c,
pkgs/os-specific/linux/kernel/perf.nix
refers to a patch that no longer exists in master and did not exist in the tree that #30882 is based on. It also seems to revert the fix that was used to replace the patch. This seems like it could be due to a bad rebase at some point, but I wanted to make sure there wasn't another reason.I put a few other concerns as comments on the diff.
I have tested cross building 4.14 kernels for
armv7l
andaarch64
, as well as a nativex86_64
kernel.build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)