summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/manual-config.nix
diff options
context:
space:
mode:
authorTuomas Tynkkynen <tuomas@tuxera.com>2017-10-23 21:28:31 +0300
committerTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>2017-11-17 17:06:52 +0200
commiteb857611378576f96022867a9fd15a7a841e518c (patch)
tree05b753cb6730d4855536b0f66fc4eff5f4587738 /pkgs/os-specific/linux/kernel/manual-config.nix
parent00056e76d0a5c1c05d7ad1064702b3d121cd1b98 (diff)
downloadnixpkgs-eb857611378576f96022867a9fd15a7a841e518c.tar
nixpkgs-eb857611378576f96022867a9fd15a7a841e518c.tar.gz
nixpkgs-eb857611378576f96022867a9fd15a7a841e518c.tar.bz2
nixpkgs-eb857611378576f96022867a9fd15a7a841e518c.tar.lz
nixpkgs-eb857611378576f96022867a9fd15a7a841e518c.tar.xz
nixpkgs-eb857611378576f96022867a9fd15a7a841e518c.tar.zst
nixpkgs-eb857611378576f96022867a9fd15a7a841e518c.zip
kernel: Fix out-of-tree modules on aarch64
https://hydra.nixos.org/build/62813493
Diffstat (limited to 'pkgs/os-specific/linux/kernel/manual-config.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix23
1 files changed, 17 insertions, 6 deletions
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index 28ad5aeca35..f922116ed36 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -158,6 +158,13 @@ let
         cp $buildRoot/{.config,Module.symvers} $dev/lib/modules/${modDirVersion}/build
         make modules_prepare $makeFlags "''${makeFlagsArray[@]}" O=$dev/lib/modules/${modDirVersion}/build
 
+        # Keep some extra files on some arches (powerpc, aarch64)
+        for f in arch/powerpc/lib/crtsavres.o arch/arm64/kernel/ftrace-mod.o; do
+          if [ -f "$buildRoot/$f" ]; then
+            cp $buildRoot/$f $dev/lib/modules/${modDirVersion}/build/$f
+          fi
+        done
+
         # !!! No documentation on how much of the source tree must be kept
         # If/when kernel builds fail due to missing files, you can add
         # them here. Note that we may see packages requiring headers
@@ -165,13 +172,14 @@ let
         # headers on 3.10 though.
 
         chmod u+w -R ../source
-        arch=`cd $dev/lib/modules/${modDirVersion}/build/arch; ls`
+        arch=$(cd $dev/lib/modules/${modDirVersion}/build/arch; ls)
 
-        # Remove unusued arches
-        mv arch/$arch .
-        rm -fR arch
-        mkdir arch
-        mv $arch arch
+        # Remove unused arches
+        for d in $(cd arch/; ls); do
+          if [ "$d" = "$arch" ]; then continue; fi
+          if [ "$arch" = arm64 ] && [ "$d" = arm ]; then continue; fi
+          rm -rf arch/$d
+        done
 
         # Remove all driver-specific code (50M of which is headers)
         rm -fR drivers
@@ -179,6 +187,9 @@ let
         # Keep all headers
         find .  -type f -name '*.h' -print0 | xargs -0 chmod u-w
 
+        # Keep linker scripts (they are required for out-of-tree modules on aarch64)
+        find .  -type f -name '*.lds' -print0 | xargs -0 chmod u-w
+
         # Keep root and arch-specific Makefiles
         chmod u-w Makefile
         chmod u-w arch/$arch/Makefile*